PNG libraries

Tomas Lindquist Olsen tomas at famolsen.dk
Tue Sep 11 11:19:59 PDT 2007


Stewart Gordon wrote:

> 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.

Reading this post made me upload some old code I have laying around. It's
yet another PNG decoder written in D...

Well... Really it's a few libraries. a D image decoder library with PNG, JPG
(through tinyjpeg), basic TGA and broken PCX support.
Also it is static convertions of some of derelict. Namely SDL, OpenGL and
FreeType. The OpenGL binding is not including the extensions. Yet.

Maybe it can be useful to someone so here it is :)

http://code.google.com/p/lindlibs/

(I have been wanting to try out googles project hosting, but eventually this
may be moved to dsource)



More information about the Digitalmars-d mailing list