tags:

views:

1006

answers:

2

I have a sprite loaded from a PNG that has an alpha channel. The image contains an opaque disk, and the rest of it is transparent.

I want to use the color argument of SpriteBatch.Draw(...) to change the tint of the disk. However, the default blending behavior applies the color to the entire sprite, so I end up with an opaque square outline around the tinted disk.

Is there any way to change the blend mode so that transparent pixels are not affected by the color argument?

+1  A: 

I've never seen this happen, and I've been working with transparent PNGs like this since the beginning in XNA. Are you mixing 2D and 3D? If so, your 3D render setting may be confusing SpriteBatch, but I thought SpriteBatch was supposed to set these properly for you. Maybe there's something wrong with the PNG image you're using?

Bill Reiss
A: 

Bill, you're right. I forgot to clear the background in one of the PNGs. The question should be deleted.

kpozin
No, don't delete it! This is what StackOverflow is for. If somebody should run into a similar problem, this QA could actually point them in a direction they didn't think about.
Peter Lillevold
Btw, instead of answering Bill with an "answer" to your own question, use the commenting system.
Peter Lillevold
Sorry, I thought that I needed 50 reputation points to be able to post comments.
kpozin