简体   繁体   中英

ImageList with PNG/Alpha Channel Image

I cannot for the life of me figure out how to create an ImageList control with a PNG file with alpha channel. I would like to use it as the small images in my ListView control.

Describing what I've tried seems overwhelming as I've been working on this for hours. I've searched the web and found virtually nothing on this.

Most things I've tried simply cause the listview to appear without any images.

Then I tried importing the following file into my project as a resource.

Folders.png

Even though I said I'm importing a Bitmap, the Resource Viewer put this resource into a section called PNG. The current version of Visual Studio seems completely baffled by a PNG file.

But right now I cannot even load it into Visual Studio. I get the following error. This error appears to be coming from the resource compiler.

error RC2170 : bitmap res\\Folders.png is not in 3.00 format.

I have recreated the image using IconWorkshop--I'm pretty sure my image is in a current format. Maybe too current for Visual Studio.

Does anyone know how to use PNG/alpha-channel images in an ImageList/ListView?

As xMRi suggested, I was able to make this work by saving my PNG image as a 32-bit/alpha channel BMP file.

Support for the loaded resource had some limitations. For example, CBitmap::GetBitmapDimension returned an empty rectangle. And support for alpha-channel and high quality bitmaps is non existent in Visual Studio.

Nonetheless, if I hard code the image size, it does work. My ListView control correct highlights the image when the item is selected without highlighting the transparent areas. So the alpha channel was correctly recognized.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM