Applying a transparent image to a GUI button

Started by Chrille, Mon 26/07/2010 14:31:28

Previous topic - Next topic

Chrille

I'm trying to create a transparent image for a GUI button through code. I've created a dynamic sprite from part of the background and then used DrawImage on the surface. The problem is where the pink transparent color shows through. Is there any way to avoid this when drawing on a GUI?
GASPOP software
http://www.gaspop.com

Old Guy

Don't know if your problem is related to the one I was having, but maybe this post will help:

Pink Artifacts On Transparent GUI


Chrille

Thanks for the suggestion, it didn't help though.
GASPOP software
http://www.gaspop.com

Ryan Timothy B

Technically you're not drawing on a GUI, you're drawing on a DynamicSprite which then is used by the GUI button. :P

QuoteI've created a dynamic sprite from part of the background
So you're creating a dynamicsprite from the room background by using: DynamicSprite.CreateFromBackground?

Then applying an image to that with drawImage? Is that correct?  If that so, there shouldn't be any pink in that DynamicSprite at all.  Even when you draw a transparent image to it.

Could you elaborate?

Calin Leafshade

do you mind if I ask when you say a 'transparent image', what do you mean exactly?

as far as I know you can make a transparent button just by making the text property empty.

Chrille

Sorry for not being more clear on what I want to do.

What I'm trying to do is create a sprite for a GUI button, making it transparent/translucent(?). I just want this particular button to have that effect without using the GUI.Transparency setting.

Here's the code (roughly)

roomSprite = DynamicSprite.CreateFromBackground (0,0,0,100,50);
displaySprite = DynamicSprite.Create (button.Width, button.Height, true);
displaySurface = displaySprite.GetDrawingSurface();
displaySurface.DrawImage (0, 0, roomSprite.Graphic, 50);
<various code for displaySprite>
button.NormalGraphic = displaySprite.Graphic;

The only problem is that with the displaySprite's alpha setting enabled, DrawImage either has no effect or it ignores the setting and draws the image with full transparency. If I disable the alpha setting, DrawImage draws the image transparent against the default pink transparency color. I guess since there's no alpha channel.

I just read the last entries in the 3.2 RC5 thread and it seems there is a bug involving GUI alpha channel.
GASPOP software
http://www.gaspop.com

GarageGothic

Well, you can't create a transparent button by drawing an image to a blank sprite using transparency. That will indeed show "magic pinK" through the transparency. What I don't really understand is why the background should be drawn transparently in the first place? Wouldn't it make more sense to simply create the displaySprite from the background and then draw whatever else you need on it transparently on top of that?

SMF spam blocked by CleanTalk