Comparison

This is a comparison between libspng and the reference implementation libpng.

Additionally stb_image and lodepng are also compared in terms of features and performance.

Lines of code

libspng is 2.8 kLOC while libpng is ~10 kLOC without the encoder or 18 kLOC in total.

Build

libspng does not have a configuration header, you only have to include spng.c/spng.h in your project.

API

The API is a lot simpler, decoding a PNG file takes 6 function calls, there are no row pointers or callback functions involved.

Error handling

All functions return zero on success and non-zero on error. libpng uses setjmp() for error handling, this makes it difficult to use from other languages such as C++.

Decoding

libspng has a clear way to request a specific output format, with libpng the output format depends on whether you set alpha filler bits, it also has weird defaults such as not converting 16-bit PNG's to host endianness unless png_set_swap() is called.

Features

Feature libspng libpng stb_image lodepng
Decode to RGBA8/16
Decode from stream
Gamma correction
Fuzzed by OSS-Fuzz[1]
Progressive read WIP
Doesn't require zlib
Encoding WIP
Animated PNG WIP [2]
Apple CgBI
  1. OSS-Fuzz improves code reliability with continuous, large-scale fuzz testing.

  2. Third-party patch is available.

Performance

Decode time on x86 (lower is better)

results matching ""

    No results matching ""