Stored images

Jim Hurley jhurley at infostations.com
Mon Feb 10 07:18:00 EST 2003


>
>--__--__--
>
>Message: 11
>Date: Sun, 9 Feb 2003 16:18:32 -0800
>Subject: Re: Storing images
>From: Geoff Canyon <gcanyon at inspiredlogic.com>
>To: use-revolution at lists.runrev.com
>Reply-To: use-revolution at lists.runrev.com
>
>Excellent! I've added this to the wiki at:
>
><http://wiki.macitworks.com/revdocs/ShowingImagesAtMultipleSizes>
>
>If anyone has any additions, refinements, comments, etc., you are all
>able to edit the page freely (no login required). Jim, if you don't
>want it there, feel free to delete it.
>
>gc

Geoff,

Thank you for the kind words and for providing  this service.

I have a couple of addenda to my addendum. I thought I would just put 
them on the wiki. (What does wiki stand for? BTW, I am woefully 
deficient in modern acronyms. YCTODNA--you can't teach an old dog new 
acronyms.) But I noticed password requirements on wiki. How does that 
work?

I should like to add two utilities which take much of the tedium out 
of using a substack to store images to be used as button  icons in 
the main stack.

When you  do this you have a mess of images in one place to be 
matched with image ids located in another place. Very messy and prone 
to error. To simplify, place buttons (of any size--size will be taken 
care of in a preOpenCard handler) and give them the *same* 
(identical) name as the image in the substack. When you are finished 
with the stack run the following setUp utility to match buttons icons 
with image ids:

On setUp
   --A utility to assign the proper image ids in the substack
   -- to the corresponding button in the main stack.

   Lock screen
   repeat with i =1 to the number of cards
     --First get the button name on cards in the main stack
     set the defaultstack to "images"
     go to card i
     repeat with j = 1 to the number of buttons
       put the short name of button j into tButtonName
       --and then go to the substack to get the image id of the
       --image with the same name.
       set the defaultstack to "imagesSubstack"
       if there is an image tButtonName then put the id of image 
tButtonName into tImageID
       --Return to the card button and set its icon to that id,
       --thereby linking the image in the substack to the
       --stack card button of the same name.
       set the defaultstack to "images"
       set the icon of button j to tImageID
     end repeat
   end repeat
   unlock screen
end setUp

And one last (?) utility. You may automate the task of assigning 
width and height properties to the images stored in the  substack 
with the following setImageSizeProperties:


on setImageSizeProperties
   --Utility to set the image size properties (imageSize). First size 
the images using their handles.
   --Run this in the substack.
   repeat with i = 1 to the number of controls
     put the name of control i into tControlName
     if "image" is word 1 of tControlName then
       put the width of image tControlName & comma & \
       the height of image tControlName into tSizeProperty
       set the imageSize of image tControlName to tSizeProperty
     end if
   end repeat
end setImageSizeProperties


And one last caution. In the main stack run as a OpenStack command: 
Start using stack "imagesSubstack"

I confess I don't understand why this is necessary. I had assumed 
that scripts in any substack of the main stack were accessible. But 
apparently not. Any help out there on this issue?

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

And finally, the  preOpenCard script on every image-carrying card:

On PreOpenCard
   resizeImage "myImageOne" , 1.2 --image name and magnification
   resizeImage "myImageTwo" , 0.7
--etc.
end PreOpenCard

Anyone who wants a demo stack is  welcome to it.

And if there is no problem in keeping the images in a separate file, 
it is  easier to just reference the stored image file. But with these 
utilities it isn't as bad as it might be to keep images stack-bound.

Rather far down on my wish list: Allow icons to be assigned by image 
name as will as id.

Whew!

Jim



More information about the use-livecode mailing list