I have to create a Texture2D during runtime. It needs to maintain a transparent background (the texture is a radar image, and it must be drawn over a map). I'm using a Bitmap object on which I draw the texture, and then I save that bitmap to a MemoryStream, and call Texture2D.FromStream() to create the resulting texture. When I do this, the image loses all transparency. How do I prevent this?
Members - Reputation: 2224
Posted 07 August 2014 - 05:26 PM
When you write the texture are you using a shader.
If so what you do is set all alpha to 0.0 then when you have a colour pixel set it's alpha to 1.
It's easy to do with a render target by using clear and setting alpha to 0.0 in the colour you pass to clear.
Members - Reputation: 107
Posted 08 August 2014 - 08:29 AM
I'm not rendering to the texture. I'm rendering to a System.Drawing.Bitmap object. I save that Bitmap into a System.IO.MemoryStream, and then I tell the Texture2D to make itself based on that stream.
Edited by KairisCharm, 08 August 2014 - 08:30 AM.