Page 1 of 1

[SOLVED] Reference an Image to multiple image controls

Posted: Wed Feb 22, 2017 1:04 pm
by Lagi Pittas
HI

I have been using a resources card with lots of graphics imported and referenced by the ID of the graphic in buttons on my main card.

I was wondering if there is a trick to doing the same for images or can we only use a file reference for them or do we need to do a bitblit of some type .

Regards Lagi

Re: Reference Image to multiple image controls

Posted: Wed Feb 22, 2017 1:28 pm
by Lagi Pittas
Hi

I solved it - just stumbled on the text property of an image

If the image on the resources card is called "nocard"

Code: Select all

put the text of image "nocard" of card "xyz" of stack "xyz" into lcImagedata
put lcImagedata into image "MyImageName"
I

The only thing that doesn't make sense is that the imagedata is called the text not the BinData or something more "Right"

Regards Lagi

Re: [SOLVED] Reference an Image to multiple image controls

Posted: Wed Feb 22, 2017 3:03 pm
by Klaus
Hi Lagi,

but this way you will still have some kind of "copy" of the original image in your stack!

So I am not sure I understand your question correctly, since using ICONS in BUTTONS
is the right way to avoid "redundance" with images.


Best

Klaus

Re: [SOLVED] Reference an Image to multiple image controls

Posted: Wed Feb 22, 2017 5:24 pm
by Lagi Pittas
What I have is POS/Cash Register customer side display.

I have an image where I can put" we accept Cards" or "sorry we do n0t accept cards" and I have a configuration file that says which one to show. I was using Buttons with the image before.

I decided to use an image view and in the initialization I check for a file first BEFORE using the image in the resource Card. If there is a file called NOcard.png for example it loads that into the image control rather than using the image from the resource stack. Basically I'm allowing an override just in case someone wants a different image showing instead of "we don't accept credit cards" - saves having to have more images in the stack and is more flexible I think. Doing it this way I can use the resource or the file with 1 single image control. I would think it would be more code using buttons .... unless you know better ;-)

Regards Lagi

Re: [SOLVED] Reference an Image to multiple image controls

Posted: Wed Feb 22, 2017 5:27 pm
by capellan
Probably this question is about how LiveCode implements the concept of image library in the stacks.

Using an image library, you could import a big size image only once in your stacks
(for example a Rembrandt Portrait) and reuse the same image in different sizes,
with different effects (grayscale, blurred, etc), cropped or masked or even repeated
multiple times in the same card or in different cards of your stack. All this recreated
on preopencard starting from a single image...

Livecode still do not have an image library. Each developer have to implement his own.

Re: [SOLVED] Reference an Image to multiple image controls

Posted: Thu Feb 23, 2017 7:12 pm
by jacque
If the image appears only once in the stack then the problem is solved. If it appears multiple times, then choose one image control to be the "master" image and use button icons for the duplicates. This way you have only a single instance that can be used anywhere.

Re: [SOLVED] Reference an Image to multiple image controls

Posted: Thu Feb 23, 2017 11:51 pm
by Lagi Pittas
Hi Jacque,

Yes it's was just a master image which would have different images.
It wasn't to save memory but to allow default images To be part of
Of the standalone but allow external files to override the default images
Works exactly as I envisaged.

Lagi