Search code examples
c++imagewinapipnggdi

How would I load a PNG image using Win32/GDI (no GDI+ if possible)?


Is it possible to load a PNG from a file into an HBITMAP using Win32 GDI functions? If not, what would be the lightest solution without using external libraries (like libpng)?


Solution

  • You can use the Windows Imaging Component to load PNG files (on Windows XP SP2 and later). See MSDN Magazine (original in web archive - a bit better formatting) for an introduction on how to use the API and my blog post for a code sample that loads a PNG from an IStream and converts it to an HBITMAP.