Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring bitmap% get-argb-pixels type in line with documentation/implementation #954

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bdeket
Copy link
Contributor

@bdeket bdeket commented Jul 29, 2020

Sending real values for x and y to bitmap get-argb-pixels exits with an error
(for example)

(send H get-argb-pixels 1. 1. 2 2 (make-bytes 100))
ptr-ref: contract violation
  expected: fixnum?
  given: 2055.0
  argument position: 3rd
  other arguments...:

Note that get/set are not mirrored (set does allow real x and y according to the doc)

looking at racket/draw/bitmap it seems that x and y could be Integer (ie neg. values allowed) but since the docs say otherwise I will stick with this for now

@bdeket bdeket changed the title Bring type in line with documentation/implementation Bring bitmap% get-argb-pixels type in line with documentation/implementation Jul 29, 2020
Copy link
Member

@samth samth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little worried about breaking existing code here.

@@ -481,7 +481,7 @@
(Class #:implements DC<%>
(init [bitmap (Option (Instance Bitmap%))])
[get-argb-pixels
(->* [Real Real Exact-Nonnegative-Integer Exact-Nonnegative-Integer Bytes]
(->* [Exact-Nonnegative-Integer Exact-Nonnegative-Integer Exact-Nonnegative-Integer Bytes]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this intentionally remove an argument?

@bdeket
Copy link
Contributor Author

bdeket commented Jul 29, 2020

no, I removed the argument by mistake :(

The function works fine with negative integers, so I could use Integer instead of Exact-Nonnegative-Integer?
I tested some more rationals and floats, and... they sometimes work, depending on the combination:

  • if both x and y are smaller than 0 they can be any Real
  • if one of them is really big (for my 512x512 image , bigger than 1e15) both can be any Real
    but for all 'normal' combinations having one value not an integer triggers a bytes-set!, or ptr-ref contract violation

In the end it turned out that my real problem is that the type for Bitmap% in racket/draw and images/flomap don't match. And this is PR is not solving this...

@samth samth marked this pull request as draft January 22, 2021 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants