Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Alpha disappearing when I make a texture.


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
4 replies to this topic

#1 KairisCharm   Members   -  Reputation: 107

Like
0Likes
Like

Posted 07 August 2014 - 02:51 PM

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?



Sponsor:

#2 ankhd   Members   -  Reputation: 1325

Like
1Likes
Like

Posted 07 August 2014 - 05:26 PM

Hi.
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.

#3 KairisCharm   Members   -  Reputation: 107

Like
0Likes
Like

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.


#4 KairisCharm   Members   -  Reputation: 107

Like
1Likes
Like

Posted 08 August 2014 - 08:34 AM

Or perhaps you mean that I should ignore the failure to get transparency at that point, move on the the shader phase, and handle alpha there. Is that what you mean?



#5 KairisCharm   Members   -  Reputation: 107

Like
0Likes
Like

Posted 08 August 2014 - 08:47 AM

Evidently that is precisely what you meant. I just tried it, and it worked beautifully. Thank you! You probably saved me a day of beating my head against a wall for no reason.






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