[Q] Exact WarpBlt (etc.) transformation to 1/3 width?

Dan Ingalls Dan.Ingalls at disney.com
Mon Jan 3 20:22:02 UTC 2000


>Is there a (fast) way to shrink the width of a bitmap to 1/3, so that
>*exactly* every third pixel is copied to the resulting bitmap? (Ie. so that
>RrrGggBbb are always merged  exactly into one pixel RGB.)
>
>In other words, can you make sure that eg. WarpBlt doesn't round the value
>of 1/3 in some way so that alignment goes bad? One can assume that the
>source width is an even multiple of 3.

Henrik -

I spent quite a while getting this right for the scaling and rotation operations in class Form.  This required care in choosing the source quadrilateral points, but I believe they are bit-perfect now.  Did you try those routines exactly as presented?  I just now tried out the following demo which picks a rectangle on the screen, blows it up 3x, then shrinks that down by 3x, and displays the result at 0 at 0...

Display restoreAfter:
[[Sensor anyButtonPressed] whileFalse:
	[(((Form fromDisplay: (Sensor cursorPoint extent: 400 at 400))
		magnifyBy: 3.0) magnifyBy: 1/3.0) display]]

This appears to faithfully recreate the orginal form with no artifacts.  By default, it uses smoothing in the shrink direction, but I also patched it to avoid smoothing altogether and the result was equally perfect.

>PS. Since a few bugs have been removed, the results are *really* nice,
>yielding very sharp text even at small sizes (10-12pts). Once that FreeType
>hinting engine is released, of course ;-)

Sounds cool.

	- Dan






More information about the Squeak-dev mailing list