Storing images

Jim Hurley jhurley at infostations.com
Sun Feb 9 18:30:01 EST 2003


I have a small addendum to the Storing Images discussion. If you wish 
to have icons of a given image displayed with varying sizes on 
different cards, there was a way of doing this suggested by Sannyasin 
Sivakatirswami. In his method all images are stored once in a 
substack. Those images then become icons resized on PreOpenCard.

This is  a variation on that method which is just a little simpler 
(it doesn't require a closeCard handler) and produces a nice border 
around the image by simultaneously resizing the  button.

On each card there is a preOpenCard handler:

On preOpenCard
    resizeImage "imageOne", 1.5 --Image name and the degree of magnification
    --Likewise for the other images
end preOpenCard

The handler "resizeImage" is stored in the  stack script of the 
substack and reads as follows:

on resizeImage theImage,theMagnification
   --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 theMagnification*item 1 of theImageSize
   set the height of image theImage to theMagnification* item 2 of theImageSize
   --Set the button size to fit the image size
   set the defaultstack to "images"
   set the width of button theImage to 1.05*theMagnification*item 1 of 
value(theImageSize)
   set the height of button theImage to 1.05*theMagnification*item 2 
of value(theImageSize)
end resizeImage



Where each image has been assigned a "imageSize" property which is 
its default width and height.

The handler will resize the image in the substack, and that image 
becomes the icon in the like-named button in the main stack.

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.

Jim



More information about the use-livecode mailing list