Importing 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
NullSet
Posts: 13
Joined: Fri Dec 28, 2018 12:39 am

Importing an image

Post by NullSet »

Forever the newbie, I've forgotten how to import an image.

To be specific, I've got an image file saved on my hard drive. I know how to display that on a card.

I want to import the image data, so reference to an external file will not be necessary for the image to display on the card. I hope I made that clear enough.

I don't need an elaborate explanation, just the basic idea.

Thanks in advance.

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

Re: Importing an image

Post by Klaus »

Hi Tim,

...
import paint from file "path/to/your/image.jpg"
...

Best

Klaus
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10415
Joined: Fri Feb 19, 2010 10:17 am

Re: Importing an image

Post by richmond62 »

imgImport.jpg
NullSet
Posts: 13
Joined: Fri Dec 28, 2018 12:39 am

Re: Importing an image

Post by NullSet »

Klaus wrote: Mon Mar 11, 2019 7:47 pm ...
import paint from file "path/to/your/image.jpg"
...
That's the ticket! Thanka, Klaus!

Looks like the image data is stored in the image object, not the card or stack. Correct?

Is there a convenient way to save the image data in the card or stack instead? In that case, how do I reference the source in the image object?

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

Re: Importing an image

Post by Klaus »

Hi Tim,
NullSet wrote: Mon Mar 11, 2019 8:27 pmLooks like the image data is stored in the image object, not the card or stack. Correct?
correct.
NullSet wrote: Mon Mar 11, 2019 8:27 pmIs there a convenient way to save the image data in the card or stack instead? In that case, how do I reference the source in the image object?
You can use a custom property of the stack to store the binary image data like:

Code: Select all

...
set the cStoredImage of this stack to url("binfile:path/to/your/image.jpg")
...
Then you can later use it like:

Code: Select all

...
put the cStoredImage of this stack into img "your image here..."
...
Best

Klaus
NullSet
Posts: 13
Joined: Fri Dec 28, 2018 12:39 am

Re: Importing an image

Post by NullSet »

Klaus wrote: Mon Mar 11, 2019 8:38 pm You can use a custom property of the stack to store the binary image data like:
Perfect!

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

Re: Importing an image

Post by Klaus »

NullSet wrote: Mon Mar 11, 2019 8:54 pm
Klaus wrote: Mon Mar 11, 2019 8:38 pm You can use a custom property of the stack to store the binary image data like:
Perfect!
Yes. :D
NullSet
Posts: 13
Joined: Fri Dec 28, 2018 12:39 am

Re: Importing an image

Post by NullSet »

Is there a way to script:

Code: Select all

set the cStoredImage of this stack to url("binfile:path/to/your/image.jpg")
With a dialog box to select the image file I want?

Thanks!

Tim
SparkOut
Posts: 2984
Joined: Sun Sep 23, 2007 4:58 pm

Re: Importing an image

Post by SparkOut »

I would be more specific with code suggestion if not on phone keyboard here, but looking up "answer file" will give you the info you need.
NullSet
Posts: 13
Joined: Fri Dec 28, 2018 12:39 am

Re: Importing an image

Post by NullSet »

SparkOut wrote: Mon Mar 11, 2019 10:39 pm "answer file" will give you the info you need.
I remember now! Rusty!!! Thanks SparkOut :D

Tim
Post Reply