[racket] Artefact when cropping and scaling an image

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Mon Nov 18 19:40:01 EST 2013

Ah. I'm not sure which change affected this, but in the git version from
last night I see a solid red square (and I do see the same thing as you in
5.3.6).

Robby


On Mon, Nov 18, 2013 at 6:36 PM, Daniel Prager <daniel.a.prager at gmail.com>wrote:

> Image attached.
>
> System: Mac, OS X 10.8.5, Racket 5.3.6.
>
> Dan
>
>
> On Tue, Nov 19, 2013 at 11:28 AM, Robby Findler <
> robby at eecs.northwestern.edu> wrote:
>
>> I'm not seeing what you're seeing, I think. Can you send a screenshot (or
>> a pointer to it)?
>>
>> Robby
>>
>>
>> On Mon, Nov 18, 2013 at 5:59 PM, Daniel Prager <daniel.a.prager at gmail.com
>> > wrote:
>>
>>> Why does the following code generate visual artefacts along the right
>>> and bottom
>>> edges of the image?  How do I eliminate it?
>>>
>>> #lang racket
>>> (require 2htdp/image)
>>>
>>> (define (crop-to-aspect-ratio im final-width final-height)
>>>   (let* ([W (image-width im)]
>>>          [H (image-height im)]
>>>          [wh-ratio (/ final-width final-height)]
>>>          [w (* wh-ratio H)]
>>>          [h (/ W wh-ratio)]
>>>          [image (if (<= W w)
>>>                     (crop 0 (/ (- H h) 2) W h im)
>>>                     (crop (/ (- W w) 2) 0 w H im))])
>>>     (freeze (scale (/ final-width (image-width image))
>>>                    image))))
>>>
>>> (scale 5
>>>        (crop-to-aspect-ratio
>>>         (freeze (rectangle 259 356 'solid 'red))
>>>         40 56))
>>>
>>>
>>> Note that the two freeze instructions are essential -- the one in the
>>> crop routine
>>>  forces pixelation, which I want -- and the one in the calling code
>>> simulates starting with a bitmap.
>>>
>>> Thanks
>>>
>>> Dan
>>>
>>> ____________________
>>>   Racket Users list:
>>>   http://lists.racket-lang.org/users
>>>
>>>
>>
>
>
> --
> *Daniel Prager*
> Agile/Lean Coaching, Software Development and Leadership
> Twitter: @agilejitsu <https://twitter.com/agilejitsu>
> Blog: agile-jitsu.blogspot.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131118/61a6872f/attachment.html>

Posted on the users mailing list.