Page 1 of 1

Getting the Source of an image

Posted: Mon Apr 21, 2014 7:30 pm
by exheusden
Looking up imageSource in the Dictionary, I see only how to set the imageSource property. This seems to correspond to the Source field in the Basic Properties list. But how can the contents of Source be accessed in LiveCode: is there a sort of "get imagesource…"?

Re: Getting the Source of an image

Posted: Mon Apr 21, 2014 8:03 pm
by dave.kilroy
Hi

Do you mean 'filename' by any chance?

Code: Select all

set the filename of img "imgTest" to "starbig1.png"
Assuming you have an image file in the same folder as your stack called "starbig1.png", as well as having an image control called "imgTest" then the above script (perhaps placed in a button?) should mean that the image control will display the .png file

Dave

Re: Getting the Source of an image

Posted: Mon Apr 21, 2014 8:12 pm
by dave.kilroy
Ah, just checked the dictionary (which I should have done first) and see that you want to change a character in a field to display an image. The following script will change the first char of field "fldTest" to the same image "imgTest" as before - except that this time I'm using its ID instead of it's name

Code: Select all

 set the imageSource of char 1 of fld "fldTest" to 18347
Is this helping or am I barking up the wrong tree?

Dave

Re: Getting the Source of an image

Posted: Mon Apr 21, 2014 8:33 pm
by exheusden
Ah, okay, so the imageSource or Source is also referred to as filename. Then I should be able to do a "get the filename of image "imageName"".

Many thanks!

Re: Getting the Source of an image

Posted: Mon Apr 21, 2014 10:24 pm
by dave.kilroy
Yep that's it!

Re: Getting the Source of an image

Posted: Tue Apr 22, 2014 4:50 pm
by jacque
Just to clarify for future readers, the "source" of an image in the inspector is something entirely different from an imagesource.

The source of a referenced image is its filename on disk. Imported images have no source, they are part of the stack.

An imagesource refers to the substitution of an image for a character in a field, which allows you to embed images into the field text. An imagesource can't refer to a file on disk, it must use an imported image and is always referenced by either its name or ID.

Re: Getting the Source of an image

Posted: Tue Apr 22, 2014 4:56 pm
by Klaus
Hi Jaqueline,
jacque wrote:An imagesource can't refer to a file on disk, it must use an imported image and is always referenced by either its name or ID.
au contraire, mon amie :D
...
set the imagesource of char 1 of fld 1 to "binfile:path/on disk/to your/image.jpg"
...

Best

Klaus

Re: Getting the Source of an image

Posted: Tue Apr 22, 2014 6:57 pm
by jacque
Interesting. I've never been able to make that work. But I believe you.

Re: Getting the Source of an image

Posted: Tue Apr 22, 2014 7:05 pm
by Klaus
Just tested and works :D
Bildschirmfoto 2014-04-22 um 20.04.02.jpg

Re: Getting the Source of an image

Posted: Tue Apr 22, 2014 7:51 pm
by jacque
Thanks Klaus. I haven't tried it for a long time because it didn't work for me, so I assumed it wasn't supported. Good to know we can do that now. (I should have looked in the dictionary like Dave did, it's listed in there.)