How to Display PNG Files with Alpha Channel?

Started by
3 comments, last by Wudan 19 years ago
Here is my code: CImage img; //Constructor img.Load("Test.png"); //OnDraw img.AlphaBlend(pDC,0,0,width,height,0,0,width,height); the code above doesn't display PNG very well, and there is some mess in the picture. Someone help me!
Advertisement
It's pretty hard to tell what's wrong without seeing the code for CImage::Load and CImage::AlphaBlend, and it's hard to understand what's wrong from the description that it doesn't display it very well and with some mess. It would help if you could post some screenshots of the problem. Also post the code for your load and alphablend functions, and tell us what the alphablend functon's supposed to do. If CImage is a class from some image loading library then tell us which one as well.

PS: When you post your code, put [ source ][ /source ] tags around it (without the spaces inside the brackets) to make it more readable.
CImage is just the ATL::CImage class,
and how to post some screenshots?
Press Printscreen when you have the screen you want to save, then go to Paint, hit paste, and save.
When you load the picture, are you certain you are getting the alpha channel, or that one exists in the picture you're using? Tons of test pictures for different types of png images are available at the libpng website, http://www.libpng.org/

This topic is closed to new replies.

Advertisement