LodePNG

New in 2008: Now also for C!

LodePNG for C (ISO C90) and for C++

LodePNG is a PNG image decoder and encoder, all in one, no dependency or linkage to zlib or libpng required.
It's made for C (ISO C90), and has a C++ wrapper with a more convenient interface on top.

See lodepng.h for documentation.

  • lodepng.cpp: The source file for the C++ version (and after renaming it, for the C version)
  • lodepng.c: Just get lodepng.cpp and rename it to lodepng.c
  • lodepng.h: header for both the C and C++ version.
The above files are sometimes updated to a newer version. Use a "hard" refresh on them in your browser to get the latest version.

LodeZlib

LodeZlib is included in LodePNG and can be used to compress and decompress arbitrary files.
Here too, both a C version, and a C++ wrapper, are available.

picoPNG

There is also picoPNG, which is only the decoder part of LodePNG, wrapped in 1 function using local classes and with all bells and whistles removed so that it's only less than 500 lines of code. This is useful because it can easily be plugged into any C++ source file of small programs that don't want to have more .cpp files nor external dependencies. PicoPNG is available only for C++, not for C.

The function, decodePNG, converts any PNG file data, with any colortype or interlace mode, into a 32-bit image in an std::vector at the output.

picopng.cpp

Example Programs

8 little examples in 1 file

lodepng_examples.c
lodepng_examples.cpp

PngSuite tester (C++)

This tests a PNG decoder on most of the images from the official PngSuite

testsuite.cpp

Translucent border generator (C++)

This gives a PNG a translucent border that can look good on webpages

border.cpp

For example, it turns the image on the left into the image on the right. In IE6 the image on the right will have a non-white background color (this color can be chosen with the program), in other browsers it's the color of this page.

D Port

Lutger Blijdestijn made a port of LodePNG to the D programming language. It can be found here (direct link doesn't work):

http://lutger.ifastnet.com/lodepng/lpng07082007.zip

History

  • 2005: LodePNG created for C++, it could only decode PNGs.
  • 2006: Many interface changes, fixes and improvements.
  • 2007: Full PNG and Zlib encoder and compressor added.
  • 2008: Converted all the code to C instead of C++, with a C++ wrapper around it.


Some other projects
Copyright (c) 2005-2008 by Lode Vandevenne. All rights reserved.