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