Getting the Source of an image
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Getting the Source of an image
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…"?
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: Getting the Source of an image
Hi
Do you mean 'filename' by any chance?
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
Do you mean 'filename' by any chance?
Code: Select all
set the filename of img "imgTest" to "starbig1.png"
Dave
"...this is not the code you are looking for..."
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: Getting the Source of an image
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
Is this helping or am I barking up the wrong tree?
Dave
Code: Select all
set the imageSource of char 1 of fld "fldTest" to 18347
Dave
"...this is not the code you are looking for..."
Re: Getting the Source of an image
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!
Many thanks!
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: Getting the Source of an image
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.
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
HyperActive Software | http://www.hyperactivesw.com
Re: Getting the Source of an image
Hi Jaqueline,
...
set the imagesource of char 1 of fld 1 to "binfile:path/on disk/to your/image.jpg"
...
Best
Klaus
au contraire, mon amiejacque 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.

...
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
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
HyperActive Software | http://www.hyperactivesw.com
Re: Getting the Source of an image
Just tested and works 

Re: Getting the Source of an image
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
HyperActive Software | http://www.hyperactivesw.com