PNG libraries
Stewart Gordon
smjg_1998 at yahoo.com
Tue Sep 11 10:28:43 PDT 2007
There's been some talk about image format libraries. And the odd specific
PNG library.
I've thought a bit about specific PNG libraries lately, considering such
things as the extensibility of the format, which I'm thinking of making use
of.
Libpng is the reference implementation of PNG. The C-based API seems on the
cumbersome side. I've a recollection of hearing that libpng has an OO C++
interface, but if there is an official one then I can't seem to find it. I
have, however, found png++, which is a layer over libpng but seems to be at
an early stage of development.
http://savannah.nongnu.org/projects/pngpp
The other one I've noticed is Lodepng, which was written in C++ but has been
ported to D. It supports a small handful of ancillary chunks, but still
doesn't provide access to any chunks it doesn't understand or even preserve
them between loading and saving.
I think D could benefit from a full-featured PNG editing library. I can see
a few possible approaches:
(a) Get together some bindings for libpng, and write an OO layer in D on top
of it. OOTB, libpng uses setjmp for error handling - we'd need to change
this.
(b) Improve one of the libraries such as Lodepng. I don't know to what
extent that would work.
(c) Write a PNG library from scratch, designed from the start to support
editing rather than merely loading and saving the image data itself. I've
got some design ideas already. We could still use existing compression and
CRC implementations.
FWIW I've written a program of just under 200 lines that generates a PNG.
The encoding logic itself is less than 100 lines (with the help of
std.zlib), but that's only to encode 24-bit RGB. Obviously a PNG library of
any sort would need to support the whole range of colour models and depths.
Thoughts?
Stewart.
More information about the Digitalmars-d
mailing list