Hi,
how can I resize a form to a specific width and height by either stretching it on one axis or cropping it on the other axis.
I create the form with Form class>>fromBinaryStream: from a background image (.jpg)
The messages in Form don't really seem to help or am I missing an obvious one?
Thanks, Matthias
On 12.01.2009, at 00:16, Matthias Korn wrote:
Hi,
how can I resize a form to a specific width and height by either stretching it on one axis or cropping it on the other axis.
Forms are fixed-size. The way you do it is by creating a new form of the desired extent and depth, and then copying (a part of) the old form into the new form, possibly scaling the pixels while doing so.
This is done by class BitBlt (for "bit block transfer") and its extension WarpBlt (which can do scaling and rotation too).
There are convenience methods hiding the details of form creation, BitBlt, and WarpBlt in class Form. E.g. "copy: aRectangle" does cropping, and "magnify: aRectangle by: aPoint smoothing: anInteger" does cropping and scaling.
BitBlt also does bit-depth conversion, color-remapping, statistics, and other image manipulations. It's well worth learning about :)
- Bert -
Hi Bert,
thanks for your hint.
I tried WarpBlt class>>rotate:degrees:center:scaleBy:smoothing: and it worked as expected. But I also found that I just had a slight mistake and my initial try with Form>>magnifyBy: and aPoint (with x and y scaling) was actually also successful. I am using this now.
Thanks, Matthias
P.S.: I had to fix Form>>magnifyBy: in my Squeak version as it initially did not work with Points as advertised.
Am Mon, 12 Jan 2009 11:45:43 +0100 schrieb Bert Freudenberg bert@freudenbergs.de:
On 12.01.2009, at 00:16, Matthias Korn wrote:
Hi,
how can I resize a form to a specific width and height by either stretching it on one axis or cropping it on the other axis.
Forms are fixed-size. The way you do it is by creating a new form of the desired extent and depth, and then copying (a part of) the old form into the new form, possibly scaling the pixels while doing so.
This is done by class BitBlt (for "bit block transfer") and its extension WarpBlt (which can do scaling and rotation too).
There are convenience methods hiding the details of form creation, BitBlt, and WarpBlt in class Form. E.g. "copy: aRectangle" does cropping, and "magnify: aRectangle by: aPoint smoothing: anInteger" does cropping and scaling.
BitBlt also does bit-depth conversion, color-remapping, statistics, and other image manipulations. It's well worth learning about :)
- Bert -
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
beginners@lists.squeakfoundation.org