Jump to content
  • Advertisement
Sign in to follow this  
Shock

PNG loading problem ( transparency issue )

This topic is 4511 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heya all, I am trying to load a 32 Bit PNG file. I created the file in photoshop and it has transparent parts. I am using my own image loader ( using libpng ). When I load this and use it, the transparent areas are light blue! But wait, before you say "there's a problem with your loader code". I used D3DX to load the image...same result! So I went and: Open with windows image viewer: Transparency is correct Open with windows paint: Transparency is light blue! I don't know what is wrong. I tried different exporters to! When I use Paint Shop Pro the transparent sections become black. Any advice? I did not turn any alpha blending settings on in D3D. Do I have to? I tried this same thing using 32Bit TGA / DDS and the transparency works perfectly without enabling alpha related states. Please help, Thanks! - Shock

Share this post


Link to post
Share on other sites
Advertisement
when you created your image in photoshop did you actually create an alpha channel?... or did you just have transparent parts on you layer....

Share this post


Link to post
Share on other sites
Does Dx even use transparent layer information? Or does it have to have a transparent color key set (that's the way it worked in DirectDraw Version 6) - cause all images get loaded to a in memory bitmap format regardless of source, and I don't think the in memory format has "transparency" ... just colors and color keys (applied while bliting).

Share this post


Link to post
Share on other sites
Since you have loaded the image, you need to tell Direct3D how to handle the rendering of the image. You have to do some kind of alpha blending.
something like this.

Device.RenderState.SourceBlend = Blend.SourceAlpha;
Device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
Device.RenderState.AlphaBlendEnable = true;



I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!