Page 1 of 1

Wait for image to load with set filename

Posted: Thu Apr 11, 2013 9:44 pm
by CenturyMan1979
Hey All,

So I am creating an image at runtime then setting the filename to a local file then I reasize it to a certain size. Is there a way to determine when the image is fully loaded and ready to manipulate. For really large images it seems to set the filename and then set the width and height but then the image actually loads in fully and the width and height are changed back to the original width and height of the image.

I tried this which I thought would work but I am seeing the same results,

Code: Select all

create invisible image in pTarget
put the long id of the last image of pTarget into tID
set the threeD of tID to false
set the width of tID to 1 --Set initial image size
set the filename of tID to pFile
wait until the width of tID <> 1
set the width of tID to XXX  -- Set image to some width value, not always the same
set the height of tID to xxx -- Set image to some height value, not always the same
Thanks for taking the time to look at my issue.

Re: Wait for image to load with set filename

Posted: Thu Apr 11, 2013 11:33 pm
by bn
Hi CenturyMan1979,

I think what you are after is the lockLoc of the image.

I tried this with an image of 3264 × 2448 pixel and it kept the size down to 400x400 as per script, going from and to the card.

If you don't lockLoc an image it will resize upon returning to the card.

Code: Select all

 lock screen
   create invisible image in pTarget
   put the long id of the last image of pTarget into tID
   set the threeD of tID to false
   -- set the width of tID to 1 --Set initial image size seems not necessary
   set the filename of tID to pFile
   -- wait until the width of tID <> 1 -- not necessary
   set the width of tID to 400  -- Set image to some width value, not always the same
   set the height of tID to 400 -- Set image to some height value, not always the same
   set the visible of tID to true

   set the lockLoc of tID to true -- this locks the size of the image down

   unlock screen
If you want to import large images into a stack but you don't want the unused width and height (= memory) you can reduce the size of the image to the actual displayed size by issuing

Code: Select all

set the imageData of image "myImage" to the imageData of image "myImage"
although this seems paradoxical it is the way to reduce the size of the image to its displayed size. If you do that you don't need lockLoc anymore since coming back to the card will not resize the image since the displayed size is the real size. If you set the imageData of the image to the imageData of itself it will no longer be a referenced image but an imported image.

Look at the comments in the script.

Kind regards
Bernd

Re: Wait for image to load with set filename

Posted: Fri Apr 12, 2013 4:12 pm
by CenturyMan1979
Hey Bernd,

The lockLoc is just what I needed. The weird part is this was all within the same card so you would think the width and height would stay to what I set it to.

I also had tried setting the imageData to reduce the size but then I was getting no images showing which again was weird (also yes I did set the visible of the image, just forgot to add that line to my original post). But since the images are just being loaded into an invisible group to be used as an image export then purged right after I don't think there will be a need reduce the imageData.