Jump to content
  • Advertisement
Sign in to follow this  
arthurlotuz

Transparent background, blending

This topic is 2096 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys. I'm not really experienced with graphics, and been having some issues. I have a couple of textures that have black backgrounds, but some of the actual texture is kind of transparent and shows a bit of the black behind it. This way, when I try to set ColorKey to black, it just fails to get the whole thing transparent.

I would like to know if there's a drawing technique in which the different tones of black on the image would be removed and set as transparent. I'm not really sure if I'm being clear enough, so sorry about that.

This is a sample image:

status8.png

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure I understood your issue (the image didn't really help), but it seems to me like what you are looking for is alpha channel. With ColorKey you can have only a single color set as transparent, if you set it to 0,0,0 (black) then ONLY perfectly black pixels will be transparent. With alpha channel you can control the transparency with great flexibility.
The most common texture formats with alpha channel are PNG and TGA.

Share this post


Link to post
Share on other sites
What I'm talking about is, I got an image like that one, and I want to turn black into transparent. That simple. I understood that ColorKey is used when you have rough edges and no transparency on the image, so you only need to remove exact color matches.

You mean that to obtain transparency on an image such as that one, I will have to edit the image, and not do it through XNA?

(even thought I still haven't found a way to change that black background efficiently on Adobe Fireworks)

# Well, actually now I found a way to do this efficiently on Fireworks X.X

Selecting the image, Inverting the colors so the background is white. Adding Convert to Alpha filter on the image so white is now alpha. Flatenning the image and then Inverting colors once again, to get transparent background.

I just couldn't find a way around this on the image editor before and decided to ask here for ways to do it by code. Edited by Arthur Souza

Share this post


Link to post
Share on other sites
I think you could achieve this by drawing the proper BlendState. Something like this:

BlendState bs = new BlendState()
{
ColorSourceBlend = Blend.SourceColor,
ColorDestinationBlend = Blend.InverseSourceColor,
};

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!