1

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?

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
  • 1
    Googling "is not in 3.00 format" show many results. – Jabberwocky Sep 23 '14 at 07:22
  • 1
    Are you aware that Visual Studio does not natively support PNG files? I use them in a project, but, as [this](http://stackoverflow.com/questions/1024761/visual-studio-2008-resource-editor-is-annoying-with-pngs) SO post indicates, I had to call them "RCDATA". – rrirower Sep 23 '14 at 12:39
  • @MichaelWalz: Yes, I found results. I even found a link to a website that would supposedly convert the image to 3.00, which I tried but didn't work. What I can't find is why I'm getting this error. Why would a new image made using newer software not be in the right format, or why Visual Studio seems so stupid with these type of images. – Jonathan Wood Sep 23 '14 at 14:55
  • @rrirower: Yes, I didn't see that question, and it looks relevant. Thanks. – Jonathan Wood Sep 23 '14 at 14:56
  • Why not using a BMP 32bit with alpha channel. This works perfect. – xMRi Sep 24 '14 at 07:40

1 Answers1

0

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.

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466