Death-WOLF

I loaded a 2D Texture from a file, the picture format is bmp for example, it present just a 2D fighter with a blue background, is there some way to display it with a transparent background (indicate that the blue color is transparent), without using a png with alpha

Help please, I don't have time to modify all the sprites in photoshop :)

Best regards



Re: XNA Game Studio Express 2D Texture transparency

Bill Reiss

If you make the background magenta (R=255, G=0, B=255) it will be made transparent using the default spritebatch settings.




Re: XNA Game Studio Express 2D Texture transparency

Jkat98

Or you can make it a PNG with a transparent background (better looking when using antialiasing etc).



Re: XNA Game Studio Express 2D Texture transparency

Death-WOLF

Not working, I used a bmp image with a magenta background. AlphaBlending is also used :

this .spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
sprite.Draw(myTexture, null, null, myPosition, Color.White);
this .spriteBatch.End();

the sprite, graphic device ..ect is initialized with the most simple way, is there any changes that I must do !!





Re: XNA Game Studio Express 2D Texture transparency

Bill Reiss

This should work, I just tried it again to make sure it still works in the 1.0 release, I'm using the red_ball.bmp and the code from my blog entry here:

http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!133.entry

maybe your magenta is slightly off color






Re: XNA Game Studio Express 2D Texture transparency

Death-WOLF

Great man. Can I configurate the spritebatch settings to take another background color as transparent
instead of the magenta color !!




Re: XNA Game Studio Express 2D Texture transparency

Bill Reiss

If you look at this thread:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=888798&SiteID=1

Shawn talks about coding a custom texture processor and it looks like you should be able to do this and key on a different color for your transparency. From his post it looks like it's a build time (in the content pipeline) where the transparency is handled. Maybe Shawn could post some more details on how to do this

EDIT: Looks like Shawn posted some code on how to do this on his blog, the post is here:

https://blogs.gotdotnet.com/shawnhar/archive/2006/11/22/customizing-how-models-build-their-textures.aspx

Bill