Resizing a form to specific width and height

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Resizing a form to specific width and height

Matthias Korn-4
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
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Resizing a form to specific width and height

Jerome Peace
[Newbies] Resizing a form to specific width and height
Matthias Korn matthias.korn at uni-siegen.de
Sun Jan 11 23:16:02 UTC 2009

Matthias,

If you have a 3.9 or later image look at ThumbnailImageMorph>>newThumbnail: for details.

In building that I created a Point>scaleTo:(anExtent)  method which returns a scale factor
for the proper reduction of the receiving extent. It preserves the aspect ratio up to a certain limit
then it will squash things a bit.

Any morph can have a snapshot taken via Shift-clicking on the Viewer handle ( The Cyan handle with the eyeball icon ).

Thumbnails can be shrunk or enlarged. And their red menu allows you to select a pop-up option.
The pop-up option shows the original image while the mouse is held down on top of the thumbnail.
I got the idea from Scott Wallace who may be better known for the Universe Package System.

You may find the thumbnails are all you need.

Yours in curiosity and service, --Jerome Peace

>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



     
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Resizing a form to specific width and height

Bert Freudenberg
In reply to this post by Matthias Korn-4
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
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Resizing a form to specific width and height

Matthias Korn-4
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 <[hidden email]>:

> 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
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners


--
Matthias Korn
Institut für Wirtschaftsinformatik
Fachbereich 5
Universität Siegen
Telefon: +49 (0) 271 / 23 67 660
Mobil: +49 (0) 176 / 700 17 17 8
Uni: +49 (0) 271/ 740 - 3382
eMail: [hidden email]
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners