<div dir="ltr">Why does the following code generate visual artefacts along the right and bottom<div>edges of the image? How do I eliminate it?</div><div><br></div><div><div>#lang racket</div><div>(require 2htdp/image)</div>
<div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>(define (crop-to-aspect-ratio im final-width final-height)</div></div><div><div> (let* ([W (image-width im)]</div></div><div><div>
[H (image-height im)]</div></div><div><div> [wh-ratio (/ final-width final-height)]</div></div><div><div> [w (* wh-ratio H)]</div></div><div><div> [h (/ W wh-ratio)]</div></div><div><div>
[image (if (<= W w)</div>
</div><div><div> (crop 0 (/ (- H h) 2) W h im)</div></div><div><div> (crop (/ (- W w) 2) 0 w H im))])</div></div><div><div> (freeze (scale (/ final-width (image-width image))</div>
</div><div><div> image))))</div></div><div><div><br></div></div><div><div>(scale 5</div></div><div><div> (crop-to-aspect-ratio</div></div><div><div> (freeze (rectangle 259 356 'solid 'red))</div>
</div><div><div> 40 56))</div></div></blockquote><div><div><br></div><div>Note that the two freeze instructions are essential -- the one in the crop routine</div><div> forces pixelation, which I want -- and the one in the calling code simulates starting with a bitmap.</div>
<div><br></div><div>Thanks </div><div><br></div><div>Dan</div><div dir="ltr"><div style="font-family:arial;font-size:small"></div></div>
</div></div>