Semi-transparent PNG file processing method for CImage class display

Source: Internet
Author: User

original link: http://blog.sina.com.cn/s/blog_4070692f010003gy.htmlPre-fill: I did not think this post seems to be a lot of people look at ... It seems everyone is depressed by this PNG. The code that displays the PNG is actually very simple, declaring a CImage variable, which is used when initializing. Load () reads the external PNG image and then uses it in the OnPaint (). Draw () to make it.  I put the source code in the Mofile, without executable files, if you can trust me please download to see it:)http://pickup.mofile.com/0460431090939353file name: Mfchello.rarSize: 41KB  In addition, do not expect to cimage.loadfromresource that waste firewood function ... Trace it in to see if it is actually called the LoadImage of Windows Management. This function describes the first line as follows:the loadimage function loads an icon, cursor, animated cursor, or bitmap.There is no support for image types other than BMP!   with the CImage class you can display translucent images in MFC, which is much better than cbitmap, masking masks and the like. Online a search "VC" "Translucent" "PNG", a large pile of data, but it is generally talked about cimage support PNG Translucent, needless to say, it is like eating so simple things like no need to say ...  but pinch, I go to use cimage do, do the PNG clear background is transparent, program also no problem, even traced to:: AlphaBlend (..), but the display of the image is pure white. Do not say translucent, even full transparency is not. What else can I do in this step?  later to find a different page logo, is in PNG format. Look inside Photoshop, the background is transparent, try it. It's a result! The area around the logo that is feathered is translucent, and the pure transparent part of the background color is displayed in white. What does that mean?

Try it:

1. Create a new file in PS with the background color selected transparently :

2. After you have pasted the picture, create a new layer. Move the new layer to the bottom, fill it with black, and set the transparency of the layer to 1%; With a mention, the transparency I set for the "shadow layer" in the middle is 30%. Well, save it as PNG, there's nothing special here.

3. The effect, so!  Translucent Success!!! Don't say my picture is white, so it's not translucent ... The base color can be made out of other colors.

Appendix: This is what I do png, you can right-click Save it. However, because the layers are merged, there is no reference value. Only CImage can use it.

Conclusion: It is probably a purely transparent background instead of being opaque ... Do not know is deliberately so set or bug, anyway, is to find a lot of trouble for me. And also found no solution to the information, depressed. So put out to share, I do not know whether in a certain month a certain day by who search ... Desolate Ah ...

Semi-transparent PNG file processing method for CImage class display

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.