[racket] Artefact when cropping and scaling an image
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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131118/49c63701/attachment.html>