Putting an image into a custom property and then retrieving it.

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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10094
Joined: Fri Feb 19, 2010 10:17 am

Putting an image into a custom property and then retrieving it.

Post by richmond62 » Thu Aug 04, 2022 8:55 pm

It's the 'Richmond goes gyte in the summer' section, again, again, again . . .

You have been warned: tune out all those for whom this is strong meat. :shock:

So, for no obvious good reason at all (that's a lie, and you can work out what the reason is)
I decided to pop an image into a custom property of a graphic object like this:

Code: Select all

on mouseUp
   set the P1 of grc "holder" to img "BFF"
end mouseUp
Here's the image:
-
Baby_Face__Finlayson.jpg
BFF
Baby_Face__Finlayson.jpg (41.88 KiB) Viewed 2036 times
-
So; that seems all very straightforward:
-
SShot 2022-08-04 at 22.52.49.png
-
BUT, the big and burning Q is how to retrieve that image later on . . .

I tried this:

Code: Select all

on mouseUp
put the imageData of the P1 of grc "holder" into tDATA
   set the imageData of img "XPIK" to tDATA
end mouseUp
and got a 'right bluey'.

Ultimately my idea is that is might be more convenient to store images as customproperties than as images qua images
in a stack.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: Putting an image into a custom property and then retrieving it.

Post by bn » Thu Aug 04, 2022 9:14 pm

Richmond,

try

Code: Select all

on mouseUp
   put  the P1 of grc "holder" into tDATA
   set the text of img "XPIK" to tDATA
end mouseUp
Kind regards
Bernd

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

Re: Putting an image into a custom property and then retrieving it.

Post by SparkOut » Thu Aug 04, 2022 9:23 pm

I'm not sure that it's any more convenient to store an image in a stack as a custom property rather than, er... an image, but having stored the image in the P1 custom property you can display that binary data by setting the, er... text of the destination image object.

Code: Select all

set the text of img "XPIK" to the P1 of grc "holder" 
[edit]and so I get outklaussed by Bernd this time! :lol: [/edit]

[edit again]
You could of course store the imageData in the first place

Code: Select all

set the P1 of grc "holder" to the imageData of img "BFF"
and then retrieve by

Code: Select all

set the imageData of img "XPIK" to the P1 of grc "holder"
Either way, you will have to be conscious of the size and position of the destination image after it has been filled, and then maybe move or resize accordingly
[/edit again]

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

Re: Putting an image into a custom property and then retrieving it.

Post by richmond62 » Fri Aug 05, 2022 8:33 am

You're the man, Bernd: Thank you so much.
-
CP.jpg
-
https://www.dropbox.com/s/wb0z1gqyl809u ... e.zip?dl=0

Post Reply