Storing images
Jim Hurley
jhurley at infostations.com
Mon Feb 10 22:47:01 EST 2003
>Jim Hurley wrote:
>
>> And just so all this info is in one place I will repeat the primary
>> utility used in the stack script of the substack
>>
>> on resizeImage theImage,theRatio
>> --Reset the image size on the substack card to the desired size
>> set the defaultStack to "imagesSubstack"
>> put the imageSize of image theImage into theImageSize
>> set the width of image theImage to theRatio*item 1 of theImageSize
>> set the height of image theImage to theRatio* item 2 of theImageSize
>
>Actually, it isn't even necessary to store the original image size in a
>custom property. Rev will automatically save the size so that the script
>doesn't have to track it. The formattedwidth and formattedheight of the
>image retain the original dimensions. You can use those properties to
>get the original size, and toss out a few lines of extra scripting besides:
>
>set the width of image theImage to theRatio*the formattedWidth of img
>theImage
>set the height of image theImage to theRatio*the formattedHeight of img
>theImage
>
>--
>Jacqueline Landman Gay | jacque at hyperactivesw.com
>HyperActive Software | http://www.hyperactivesw.com
Jacqueline,
I was unaware of this. Thanks for the info.
It isn't exactly what I would like to use however. The formattedWidth
(and height) appear to be the original width (and height) of the
imported image. What I find useful is to rezise the images (using the
handles) to a size which will be close to the "normal" size used
throughout the stack. This makes it much easier to choose a value
for theRatio magnifier. The formattedWidth is often much larger than
the sizes to be used in the stack, even substantially larger than the
window.
There is some danger of distorting the proportions in this hand
operation. In this case using the formattedWidth (and Height) would
be safer.
And I like the suggestion made by Mark Mitchell (below).
>
> mark mitchell wrote:
>Jim wrote:
>
>> The button whose icon is the image is also resized to just fit (just
>> a little bit extra--1.05--makes for a little better appearance)
>> around the image as a border. You can have your cake and a border too.
>
>Funny how we think differently. I have always achieved the same effect
>by setting the image size to the size of the button then Minus a bit.
>This keeps the visible buttons the same size as your initial layout.
>Usually 5 is sufficient to subtract. But the actual amount you need to
>subtract depends on how large a border your button has. Buttons can be
>set to have thick borders, and colored too, which make nice image
>'frames'.
>
>mark mitchell
>Japan
>
In Mark's method one would size the button (using the handles) on a
given card to be the desired size of the eventual image; this is
usually the easiest way to make the adjustment, easier than
experimenting with a magnifying factor.
There is a small potential problem with proportions however. If the
hand chosen button proportions are not the same as those of the
image, the image will be distorted if one "sets the image size to the
size of the button" (minus a little bit.)
What I thought one might do is position and size the button as best
one can by hand and then, by script, adjust the button proportions to
be the same proportions as the image and only then set the button
icon to the image id.
So a revised resizeImage handler would look like this. (Where I have
kept the button *width* fixed and adjusted the button height to fit
the proportions of the incoming image.) (Remember, the button name
must be the same as the image name.)
on resizeImageRevised theImage
--First get the button width
put the width of button theImage into theButtonWidth
--Reset the image size on the substack card
--so that it will fit inside the button without distortion.
set the defaultStack to "imagesSubstack"
put the imageSize of image theImage into theImageSize
put item 1 of theImageSize into theNewImageWidth
put theButtonWidth/theNewImageWidth into theRatio
set the width of image theImage to .94*theRatio*item 1 of theImageSize
set the height of image theImage to .94*theRatio* item 2 of theImageSize
--Adjust the button height to match the proportions of the image.
set the defaultstack to "images"
set the height of button theImage to theRatio*item 2 of (theImageSize)
end resizeImageRevised
I use a 3D button. But there are many variations possible with border
widths and colors as Mark suggested if the button is not 3D.
There are perhaps occasions where the previous resizeImage handler
would be useful, occasions where the image might grow in size rather
than be fixed to the button size.
For example, using the following OpenCard (not preOpenCard) handler:
on OpenCard
repeat with growthFactor =1 to 30
resizeImage "flame", 0.1 * growthFactor
end repeat
end openCard
produces a flame image which swells to a "raging inferno" as the card
is opened.
But I'm sure others will find their own variations on this theme.
Jim
--
Jim Hurley
More information about the use-livecode
mailing list