Jump to content

  • Log In with Google      Sign In   
  • Create Account


Transparent background, blending


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Arthur Souza   Members   -  Reputation: 1414

Like
0Likes
Like

Posted 22 September 2012 - 09:48 PM

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:

Posted Image

A.

Lotus - Action RPG In development http://www.gamedev.n...die-rpg-engine/ |
Personal blog In Portuguese: lotuzgames.wordpress.com |


Sponsor:

#2 Tom KQT   Members   -  Reputation: 1502

Like
0Likes
Like

Posted 23 September 2012 - 02:54 AM

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.

#3 Arthur Souza   Members   -  Reputation: 1414

Like
0Likes
Like

Posted 23 September 2012 - 09:45 AM

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, 23 September 2012 - 10:25 AM.

A.

Lotus - Action RPG In development http://www.gamedev.n...die-rpg-engine/ |
Personal blog In Portuguese: lotuzgames.wordpress.com |


#4 phil_t   Crossbones+   -  Reputation: 3164

Like
0Likes
Like

Posted 23 September 2012 - 11:03 AM

I think you could achieve this by drawing the proper BlendState. Something like this:

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS