Storing images

Sannyasin Sivakatirswami katir at hindu.org
Fri Feb 7 00:51:01 EST 2003


Maybe i am missing something about what you are trying to do... and 
maybe this option you already know...

anyway, to  add yet another option which works perfectly, does not 
require that you reference images files from disk, allows for dynamic 
resizing of all images on the fly, displays all instances as btn icons 
as many  times and with whatever sizes as you want, whenever you want 
them,  but with only one "copy"  of the actual image data in the 
(sub)stack:

In substack "Alphabet" (which the user never sees or knows about... 
it's just a library stack) I have imported very large images of 
characters needed for elsewhere at any time at any size, generally only 
smaller versions so that the image quality is never reduced.  Each 
image in the "alphabet" stack (library/resource whatever)  has a custom 
property set named "mySize' which contains the width and height pair 
for its original size as imported.

mySize 			

     200,400

in mainstack "Lessons"  are these handlers which do math against this 
property of the image:

on resizeImage theRatio theImage
   set the defaultStack to "alphabet"
   set the width of image id theImage to theRatio * item 1 of the mySize 
of image id  theImage
   set the height of image id theImage to theRatio * item 2 of the   
mySize of image id  theImage
end resizeImage

on restoreImageSize theImage
   set the defaultStack to "alphabet"
   set the width of image id  theImage to  item 1 of the mySize of image 
id  theImage
   set the height of image id  theImage to  item 2 of the mySize of 
image id  theImage
end restoreImageSize

on say,  card 3,  of stack" Lessons",  a preopencard handler make the 
size change request(s) before display, where the sizes of  18 of the 
characters are being displayed at .17 of their original size on that 
particular card.  When leaving the card the images are resized to their 
original size so that any subsequent ratio changes for usage in other 
contexts are always working from the known original size. ID's have 
been preset to match the needs for this context where the ordinal 
position in the alphabet corresponds to the ordinals 2001,2002, etc. 
just to make it easier to remember and script:

on preopenCard
   repeat with x = 1 to 18
     resizeImage .17,  (2000+x)  ## we pass the size change and the 
image ID
   end repeat
end preopenCard
on closeCard
   repeat with x = 1 to 18
     restoreimagesize  (2000+x)
   end repeat
end closeCard

Viola, when opening the card, all the "images" which are actually btns 
icons for buttons 1 -18 on this cared are all showing a small versions 
of the image.

And its fast also... no overhead delay opening the card.

does that help? Convoluted? Yes perhaps, but in terms of space 
overhead, especially for web delivery, having only a single instance of 
the image data actuall present keeps file sizes way down and you don't 
have to hassle with keep image externally.

On Wednesday, February 5, 2003, at 07:42 AM, Björnke von Gierke wrote:

> This thread confuses me, so I made some experiments, to clarify all 
> this for me, I will list the results of them here (if this is useful 
> for any of you then that is your own fault!):
>
> setting the icon:
> set the icon of button "foo" to image "bar"




More information about the use-livecode mailing list