backgroundcolor for transparent images

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bamakojeff
Posts: 33
Joined: Tue Dec 06, 2022 6:53 pm

backgroundcolor for transparent images

Post by bamakojeff » Fri Feb 21, 2025 8:34 pm

If I put an image with has a transparent background on a field, then the backgroundcolor of the field shows through properly. And if I change the backgroundcolor of the field, then the new backgroundcolor shows through. This also works correctly if I use the "set imagesource" command to replace a character with an image. The field's backgroundcolor shows through the transparent background of the image which has been inserted for a specific character using the "set imagesource" command.

But if I change the backgroundcolor of the character which has been replaced by the transparent image, the new backgroundcolor does not come through the transparent areas of the image; it remains the color of the field's backgroundcolor rather than the character's backgroundcolor.

Code: Select all

put "12345" into fld "Field"
set the backgroundcolor of fld "FIeld" to "yellow"
So now I have the text "12345" with a yellow background

Code: Select all

set the imagesource of char 3 of fld "Field" to 1111
Now I see the text "12" followed by image 1111 followed by the text "45" in the field. The yellow field backgroundcolor comes through the transparent areas of image 1111.

Code: Select all

set the backgroundcolor of char 1 to -1 of fld "Field" to "red"
Now the background of the text "12" and "45" is red, but the background of image 1111 is still yellow, the field's backgroundcolor, rather than the character's backgroundcolor.

This also happens if you set the backgroundcolor at the character level first and then set the imagesource. The color which shows through the image's transparent areas is the field's backgroundcolor, not the character's.

Livecode correctly sees the character's backgroundcolor is "red".

Code: Select all

put the backgroundcolor of char 3 of fld "field"
returns "255,0,0" (red). But that's not what you see through the transparent areas of the image in that character's place. You see yellow.

Any ideas how to get a transparent image to show the character's backgroundcolor if it is set rather than the field's backgroundcolor?

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

Re: backgroundcolor for transparent images

Post by Klaus » Fri Feb 21, 2025 8:44 pm

Hi Jeff,

did you try to set the bgcolor to empty before setting to a new color?
And/or maybe re-set the imagesource?

Just guessing... :)

Best

Klaus

bamakojeff
Posts: 33
Joined: Tue Dec 06, 2022 6:53 pm

Re: backgroundcolor for transparent images

Post by bamakojeff » Fri Feb 21, 2025 9:36 pm

Two excellent suggestions, Klaus. I did try them both when working on this problem, and I just tried them again to be sure. Unfortunately, no luck. The background of the transparent image stubbornly always shows the field's bgcolor, not the character's.

Thanks for tossing some ideas out.

Jeff

Post Reply