Getting the Source of an image

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
exheusden
Posts: 170
Joined: Fri Oct 09, 2009 5:03 pm
Contact:

Getting the Source of an image

Post 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…"?
dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Getting the Source of an image

Post 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
"...this is not the code you are looking for..."
dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Getting the Source of an image

Post 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
"...this is not the code you are looking for..."
exheusden
Posts: 170
Joined: Fri Oct 09, 2009 5:03 pm
Contact:

Re: Getting the Source of an image

Post 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!
dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Getting the Source of an image

Post by dave.kilroy »

Yep that's it!
"...this is not the code you are looking for..."
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Getting the Source of an image

Post 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Getting the Source of an image

Post 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
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Getting the Source of an image

Post by jacque »

Interesting. I've never been able to make that work. But I believe you.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Getting the Source of an image

Post by Klaus »

Just tested and works :D
Bildschirmfoto 2014-04-22 um 20.04.02.jpg
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Getting the Source of an image

Post 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.)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Post Reply