[PNG:TDG cover]

[PNG icon] PNG: The Definitive Guide: Source Code

Chapters 13, 14 and 15 of PNG: The Definitive Guide discuss three cross-platform demo programs that show how to use the libpng reference library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is a very simple example that that shows how a standard file-viewer might use libpng, while the second is designed to process streaming data and shows how a web browser might be written. wpng is a simple command-line program that reads binary PPM files (the ``raw'' RGB subset of NetPBM) and converts them to PNG.

The source code for all three demo programs currently compiles under Unix, OpenVMS and 32-bit Windows. It has been tested with gcc 2.7.x, 2.8.1 and 2.95.3 under Linux, Solaris, Irix and FreeBSD, and with Microsoft Visual C++ 5.0 under Windows 95, 98 and NT. (OpenVMS modifications and testing were done by Martin Zinser, and FreeBSD testing was done by Miguel Angel Vicente.) Instructions for compiling the programs are included in the README file and are summarized at the top of the makefiles; Makefile.unx is the Unix version, Makefile.w32 is (you guessed it!) the version for 32-bit Windows, and makevms.com is the build script for OpenVMS. libpng and zlib are required; see the libpng home page for links to source code and binaries.

[rpng2 -bgpat 11]

Other than the difference in line endings and packaging, the contents of the two archives are identical. In particular, both archives include both makefiles, but libpng and zlib are not included. (You can find pointers to them on the libpng home page.) If and when the programs are ported to other operating systems, Greg will update the archives with the new ports.

Binaries for Windows, Linux, FreeBSD, Solaris, Irix, and SCO OpenServer are also available:


Here are half-scale screenshots of all 16 of rpng2's automatically generated background patterns, plus two of its 16 million solid background colors. Three of the individual patterns can be clicked on to see their full-scale versions, and the entire group is available as a 379k full-scale PNG image. The diamond-shaped pattern was created by Adam M. Costello, and the radial/spiral color-bars are courtesy of Pieter S. van der Meulen.

[rpng2 -bgpat 1-16, -bgcolor #ffe2af and #92ff00]
[rpng2 -bgpat 8] [rpng2 -bgpat 14] [rpng2 -bgpat 16] [no link]


License

The source code to the demo programs may be used and distributed freely (even if you didn't buy the book--but feel free to do so at any time), subject to the terms of the following BSD-like license:

Copyright (c) 1998-2001 Greg Roelofs. All rights reserved.

This software is provided "as is," without warranty of any kind, express or implied. In no event shall the author or contributors be held liable for any damages arising in any way from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. Redistributions of source code must retain the above copyright notice, disclaimer, and this list of conditions.
  2. Redistributions in binary form must reproduce the above copyright notice, disclaimer, and this list of conditions in the documentation and/or other materials provided with the distribution.
  3. All advertising materials mentioning features or use of this software must display the following acknowledgment:

    This product includes software developed by Greg Roelofs and contributors for the book, "PNG: The Definitive Guide," published by O'Reilly and Associates.

[rpng2 -bgpat 4]


Here are the other web pages related to PNG: The Definitive Guide:


[primary site hosted by SourceForge.net] Last modified 30 April 2006.

Copyright © 1999-2006 Greg Roelofs.