thumnail problem.

Joern Eyrich Joern.Eyrich at brokat.com
Thu Jul 5 11:24:55 UTC 2001


Vince Mazo wrote:
> 
> ----- Original Message -----
> From: "Ned Konz" <ned at bike-nomad.com>
> To: <squeak at cs.uiuc.edu>
> Sent: Tuesday, July 03, 2001 5:37 PM
> Subject: Re: thumnail problem.
> 
> > On Tuesday 03 July 2001 02:51, Vince Mazo wrote:
> > > I want to display an image (gif or jpg) in a rectangle which size is
> fixed.
> > > MorphThumbnail seems tp be good but I don't want it to handle grab
> event.
> > > Moreover, I just want the image to be smaller in the thumbnail, if the
> > > source image is smaller than the thumbnail, it should not be resized...
> > >
> > > Is there a better morph to do that? Or what should I do to make the
> morph
> > > work better?
> >
> > I don't know what you mean by 'don't want it to handle grab event'. If you
> > don't want someone to drag it around, just make it sticky.
> >
> 
> It means that I don't want it to "launch" the real morph(I just need the
> thumbnail picture).
> I ' ve played around with InterpolatingImageMorph but I'm not too sure about
> this one...
> (it seems quite slow with jpeg)

I was a bit puzzled, too. It seems MorphThumbnail is some special purpose thing that presents an image of a morph, and, when clicked, replaces itself by the original morph

Maybe you want class Thumbnail instead:
(Thumbnail new maxWidth: 1000 minHeight: 100; makeThumbnailFromForm: (Form fromUser)) openInWorld
(if you don't adjust minHeight, it will first be scaled down to 24 pixels of height, if you make the thumbnail bigger afterwards, it looks awful)

However, this does still scale up smaller sources. Taking a SketchMorph as Karl suggested, you might do:

size _ 100 at 100.
form _ Form fromUser.
(form extent max: size) > size ifFalse: [ | form2 | form2 _ Form extent: size. form displayOn: form2. form _ form2].
"(form extent max: size) > size ifFalse: [ form _ form copy: (0 at 0 extent: size)]."
thumbnail _ SketchMorph withForm: form.
thumbnail extent: size; openInWorld.

the third line creates an empty form of the desired minimum size and copies the source into it (you could also center it etc. if you liked) if the source is smaller than the intended thumbnail; the commented out version gives you transparency in the parts not covered by the source image, as opposed to default background collor in the first version

If I understand it correctly, the InterpolatingImageMorph would only buy you something if you scaled anything *up*, which, if I understand you correctly, you never want to do.

HTH,
Joern





More information about the Squeak-dev mailing list