[racket] Artefact when cropping and scaling an image

From: Daniel Prager (daniel.a.prager at gmail.com)
Date: Mon Nov 18 19:36:47 EST 2013

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/20131119/2a12c737/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: crop-and-scale-artefact.png
Type: image/png
Size: 14139 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20131119/2a12c737/attachment-0001.png>

Posted on the users mailing list.