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

jnm2 picture jnm2 · Dec 31, 2010 · Viewed 40.6k times · Source

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)?

Answer

Bradley Grainger picture Bradley Grainger · Dec 31, 2010

You can use the Windows Imaging Component to load PNG files (on Windows XP SP2 and later). See MSDN Magazine 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.