[SOLVED] Reference an Image to multiple image controls

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
Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 366
Joined: Mon Jun 10, 2013 1:32 pm

[SOLVED] Reference an Image to multiple image controls

Post by Lagi Pittas » Wed Feb 22, 2017 1:04 pm

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
Last edited by Lagi Pittas on Wed Feb 22, 2017 1:34 pm, edited 1 time in total.

Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 366
Joined: Mon Jun 10, 2013 1:32 pm

Re: Reference Image to multiple image controls

Post by Lagi Pittas » Wed Feb 22, 2017 1:28 pm

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

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

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

Post by Klaus » Wed Feb 22, 2017 3:03 pm

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

Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 366
Joined: Mon Jun 10, 2013 1:32 pm

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

Post by Lagi Pittas » Wed Feb 22, 2017 5:24 pm

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

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

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

Post by capellan » Wed Feb 22, 2017 5:27 pm

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.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

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

Post by jacque » Thu Feb 23, 2017 7:12 pm

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

Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 366
Joined: Mon Jun 10, 2013 1:32 pm

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

Post by Lagi Pittas » Thu Feb 23, 2017 11:51 pm

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

Post Reply