Last post Sep 03, 2015 03:44 PM by Landon Huang
Aug 04, 2015 02:52 PM|mdaga|LINK
I am using the ATL:CImage class to decode png images.
But the images are getting converted to RGBA (4 byte per pixel) images when loaded.
img.Load((LPCTSTR)("test.png")); // 8bit grayscale
after a successful load the m_nBPP member is 32 (aka 4 byte) and the m_bHasAlphaChannel is true. But they sould be 8 and false.
Due to the implicit conversion we need to convert the RGBA back to 8BPP manually. I am processing more than 400 images. So this is a major slow down for the application.
On Visual Studio forum I read that this is an issue in the GDI+ as its implicityly converting all grayscale PNG images to 32bpp ARGB.Please let me know if there is a work around for this.Thanks
Sep 03, 2015 03:44 PM|Landon Huang|LINK
You're right about this being by design for GDI+. "All grayscale PNG images are converted to 32bpp ARGB" as explained here:
This means if you don't want to load as 32-bit and convert back, you could use a PNG library such as LibPng (libpng.org/pub/png/libpng.html), Leadtools (leadtools.com) or LodePNG (lodev.org/lodepng)