typed-racket icon indicating copy to clipboard operation
typed-racket copied to clipboard

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

Open bdeket opened this issue 5 years ago • 1 comments

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 avatar Jul 29 '20 17:07 bdeket

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...

bdeket avatar Jul 29 '20 20:07 bdeket