8

That there is no simple way to read a PNG file into a memory bitmap in native Windows seemed impossible, but after much googling I'm beginning to believe it. The libpng/zlib combination is just too big. Any third-party libraries Win32 libraries out there for reading a PNG?

Edit: The boost::gil::png solution is much more complex than I'd hoped, too. Just need a single call that takes a file name and fills a memory buffer with pixels.

I. J. Kennedy
  • 24,725
  • 16
  • 62
  • 87
  • 1
    Duplicate? See here http://stackoverflow.com/questions/366768/convert-bitmap-to-png-in-memory-in-c-win32/538742 – Preet Sangha Sep 08 '09 at 01:32
  • The core OS API should not necessarily have built in support for reading and writing multiple image types. There are many third party libraries for this kind of thing. – Ed S. Sep 08 '09 at 02:05
  • 1
    Ed, I don't understand your comment in light of the fact that I was asking specifically about third-party libraries. – I. J. Kennedy Sep 08 '09 at 04:07

4 Answers4

18

Or of course you could use GDI+ - The Bitmap object takes a string constructor and loads the specified file into memory. That way you don't need any external libraries, just that which comes with windows.

Tyler
  • 28,498
  • 11
  • 90
  • 106
Larry Osterman
  • 16,086
  • 32
  • 60
1

libgd is an excellent library that can be used in Windows and has bindings for many popular languages.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
0

There is some built-in stuff you can use: IImgCtx and on later versions of windows you also have WIC

Anders
  • 97,548
  • 12
  • 110
  • 164
-1

I have successfully used libpng to do this.

Adam Pierce
  • 33,531
  • 22
  • 69
  • 89