Load External Image Data Not Working

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
CenturyMan1979
Posts: 86
Joined: Tue May 15, 2012 5:56 pm

Load External Image Data Not Working

Post by CenturyMan1979 » Thu Mar 07, 2013 9:47 pm

Hey All,

I seem to be having an issue with loading external image data and then setting that data to an image object. Here is what I am trying to do,

// Load Image Data Script (this seems to work fine and has the image data stored in the variable)
put URL("binfile:"&tAppPath & "ImageFile.png" ) into tImgData

// Code to display the image data (This creates an image but image does not show)
create invisible image
put the long id of the last image into tID
set the imageData of tID to tImgData
set the width of tID to the cScaledWidth of tID
set the height of tID to the cScaledHeight of tID
set the loc of tID to the cScaledLoc of tID
set the visible of tID to true

It may seem that I am doing something incorrect here and was hoping someone can point me into the right direction.

Klaus
Posts: 14213
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Load External Image Data Not Working

Post by Klaus » Thu Mar 07, 2013 10:10 pm

Hi CenturyMan1979,

you can only set "the imagedata" if the image where you put this into has the exact dimensions!
as the original image where the image data comes from! Know what I mean?

...
put URL("binfile:"&tAppPath & "ImageFile.png" ) into tImgData

## This will have the DEFAULT size (width/height) for newly created images and obvioulsy NOT the size of the "ImageFile.png"
create invisible image

put the long id of last image into tID

## This also does not work, no idea why...
## put tImgData into tID

## This does work:
put tImgData into last img
...

Best

Klaus

CenturyMan1979
Posts: 86
Joined: Tue May 15, 2012 5:56 pm

Re: Load External Image Data Not Working

Post by CenturyMan1979 » Thu Mar 07, 2013 10:26 pm

Thanks Klaus that worked a charm. Also found this to work also,

// Code to display the image data (This creates an image but image does not show)
create invisible image
put the long id of the last image into tID
put the short id of tID into tShortID
put tImgData into image id tShortID
set the width of tID to the cScaledWidth of tID
set the height of tID to the cScaledHeight of tID
set the loc of tID to the cScaledLoc of tID
set the visible of tID to true

I am creating a slide show application and I am locking the screen with a dissolve visual effect. When I would get to a slide that had a really large dimension image there was a noticeable delay in displaying the slide. I thought loading the image data before going into the slideshow would fix this but the issue remains the same. Next I am going to try loading these images into a seperate card and copy them over to the current card when running the slide show to see if that will work.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Load External Image Data Not Working

Post by sturgis » Thu Mar 07, 2013 10:43 pm

Not that it matters since you have things working, but you can "set the text of image "myimage" to tImgData

Much more forgiving than setting the imagedata.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7394
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Load External Image Data Not Working

Post by jacque » Fri Mar 08, 2013 7:43 am

Even shorter, you can just put the url content into an image:

put url ("binfile:" & tImgPathOnDisk) into image 1

Unless I'm dealing with pixels on screen, I avoid the term "imageData". It doesn't mean what you think.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply