3

Is there any c function that allow me to convert a raw image to a PNG file? Preferably, I don't need to pull in a big library for that.

Thank you.

lucius
  • 2,179
  • 7
  • 28
  • 26

4 Answers4

13

I do not believe so. On the other hand, libpng isn't a huge library.

Not Sure
  • 5,873
  • 3
  • 23
  • 29
5

Have you tried the libpng library?

http://www.libpng.org/pub/png/libpng.html

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
1

I'm not sure what you mean by "raw image", but I've found LodePNG easy to work with. http://members.gamedev.net/lode/projects/LodePNG/ There's an example showing you how to encode some raw data to a png

Tobbe
  • 3,282
  • 6
  • 41
  • 53
1

See a related question: Convert bitmap to PNG in-memory in C++ (win32)

The short answer is that GDI+ can convert a bitmap image to PNG (with some limitations), so if you're on Windows it's an option that's even more minimal than libPNG.

Community
  • 1
  • 1
Assaf Lavie
  • 73,079
  • 34
  • 148
  • 203