Blame contrib/gregbook/README

Packit 0ba690
                     ===========================
Packit 0ba690
                      PNG: The Definitive Guide
Packit 0ba690
                     ===========================
Packit 0ba690
Packit 0ba690
                             Source Code
Packit 0ba690
Packit 0ba690
Chapters 13, 14 and 15 of "PNG: The Definitive Guide" discuss three free,
Packit 0ba690
cross-platform demo programs that show how to use the libpng reference
Packit 0ba690
library:  rpng, rpng2 and wpng.  rpng and rpng2 are viewers; the first is
Packit 0ba690
a very simple example that that shows how a standard file-viewer might use
Packit 0ba690
libpng, while the second is designed to process streaming data and shows
Packit 0ba690
how a web browser might be written.  wpng is a simple command-line program
Packit 0ba690
that reads binary PGM and PPM files (the ``raw'' grayscale and RGB subsets
Packit 0ba690
of PBMPLUS/NetPBM) and converts them to PNG.
Packit 0ba690
Packit 0ba690
The source code for all three demo programs currently compiles under
Packit 0ba690
Unix, OpenVMS, and 32-bit Windows.  (Special thanks to Martin Zinser,
Packit 0ba690
zinser@decus.de, for making the necessary changes for OpenVMS and for
Packit 0ba690
providing an appropriate build script.)  Build instructions can be found
Packit 0ba690
below.
Packit 0ba690
Packit 0ba690
Files:
Packit 0ba690
Packit 0ba690
   README             this file
Packit 0ba690
   LICENSE            terms of distribution and reuse (BSD-like or GNU GPL)
Packit 0ba690
   COPYING            GNU General Public License (GPL)
Packit 0ba690
Packit 0ba690
   Makefile.unx       Unix makefile
Packit 0ba690
   Makefile.w32       Windows (MSVC) makefile
Packit 0ba690
   makevms.com        OpenVMS build script
Packit 0ba690
Packit 0ba690
   rpng-win.c         Windows front end for the basic viewer
Packit 0ba690
   rpng-x.c           X Window System (Unix, OpenVMS) front end
Packit 0ba690
   readpng.c          generic back end for the basic viewer
Packit 0ba690
   readpng.h          header file for the basic viewer
Packit 0ba690
Packit 0ba690
   rpng2-win.c        Windows front end for the progressive viewer
Packit 0ba690
   rpng2-x.c          X front end for the progressive viewer
Packit 0ba690
   readpng2.c         generic back end for the progressive viewer
Packit 0ba690
   readpng2.h         header file for the progressive viewer
Packit 0ba690
Packit 0ba690
   wpng.c             generic (text) front end for the converter
Packit 0ba690
   writepng.c         generic back end for the converter
Packit 0ba690
   writepng.h         header file for the converter
Packit 0ba690
Packit 0ba690
   toucan.png         transparent PNG for testing (by Stefan Schneider)
Packit 0ba690
Packit 0ba690
Note that, although the programs are designed to be functional, their
Packit 0ba690
primary purpose is to illustrate how to use libpng to add PNG support to
Packit 0ba690
other programs.  As such, their user interfaces are crude and definitely
Packit 0ba690
are not intended for everyday use.
Packit 0ba690
Packit 0ba690
Please see http://www.libpng.org/pub/png/pngbook.html for further infor-
Packit 0ba690
mation and links to the latest version of the source code, and Chapters
Packit 0ba690
13-15 of the book for detailed discussion of the three programs.
Packit 0ba690
Packit 0ba690
Greg Roelofs
Packit 0ba690
http://pobox.com/~newt/greg_contact.html
Packit 0ba690
16 March 2008
Packit 0ba690
Packit 0ba690
Packit 0ba690
BUILD INSTRUCTIONS
Packit 0ba690
Packit 0ba690
 - Prerequisites (in order of compilation):
Packit 0ba690
Packit 0ba690
      - zlib		http://zlib.net/
Packit 0ba690
      - libpng		http://www.libpng.org/pub/png/libpng.html
Packit 0ba690
      - pngbook		http://www.libpng.org/pub/png/book/sources.html
Packit 0ba690
Packit 0ba690
     The pngbook demo programs are explicitly designed to demonstrate proper
Packit 0ba690
     coding techniques for using the libpng reference library.  As a result,
Packit 0ba690
     you need to download and build both zlib (on which libpng depends) and
Packit 0ba690
     libpng.  A common build setup is to place the zlib, libpng and pngbook
Packit 0ba690
     subdirectory trees ("folders") in the same parent directory.  Then the
Packit 0ba690
     libpng build can refer to files in ../zlib (or ..\zlib or [-.zlib]),
Packit 0ba690
     and similarly for the pngbook build.
Packit 0ba690
Packit 0ba690
     Note that all three packages are designed to be built from a command
Packit 0ba690
     line by default; those who wish to use a graphical or other integrated
Packit 0ba690
     development environments are on their own.
Packit 0ba690
Packit 0ba690
Packit 0ba690
 - Unix:
Packit 0ba690
Packit 0ba690
     Unpack the latest pngbook sources (which should correspond to this
Packit 0ba690
     README file) into a directory and change into that directory.
Packit 0ba690
Packit 0ba690
     Copy Makefile.unx to Makefile and edit the PNG* and Z* variables
Packit 0ba690
     appropriately (possibly also the X* variables if necessary).
Packit 0ba690
Packit 0ba690
     make
Packit 0ba690
Packit 0ba690
     There is no "install" target, so copy the three executables somewhere
Packit 0ba690
     in your path or run them from the current directory.  All three will
Packit 0ba690
     print a basic usage screen when run without any command-line arguments;
Packit 0ba690
     see the book for more details.
Packit 0ba690
Packit 0ba690
Packit 0ba690
 - Windows:
Packit 0ba690
Packit 0ba690
     Unpack the latest pngbook sources (which should correspond to this
Packit 0ba690
     README file) into a folder, open a "DOS shell" or "command prompt"
Packit 0ba690
     or equivalent command-line window, and cd into the folder where you
Packit 0ba690
     unpacked the source code.
Packit 0ba690
Packit 0ba690
     For MSVC, set up the necessary environment variables by invoking
Packit 0ba690
 
Packit 0ba690
        %devstudio%\vc\bin\vcvars32.bat
Packit 0ba690
Packit 0ba690
     where where %devstudio% is the installation directory for MSVC /
Packit 0ba690
     DevStudio.  If you get "environment out of space" errors under 95/98,
Packit 0ba690
     create a desktop shortcut with "c:\windows\command.com /e:4096" as
Packit 0ba690
     the program command line and set the working directory to the pngbook
Packit 0ba690
     directory.  Then double-click to open the new DOS-prompt window with
Packit 0ba690
     a bigger environment and retry the commands above.
Packit 0ba690
Packit 0ba690
     Copy Makefile.w32 to Makefile and edit the PNGPATH and ZPATH variables
Packit 0ba690
     appropriately (possibly also the "INC" and "LIB" variables if needed).
Packit 0ba690
     Note that the names of the dynamic and static libpng and zlib libraries
Packit 0ba690
     used in the makefile may change in later releases of the libraries.
Packit 0ba690
     Also note that, as of libpng version 1.0.5, MSVC DLL builds do not work.
Packit 0ba690
     This makefile therefore builds statically linked executables, but if
Packit 0ba690
     the DLL problems ever get fixed, uncommenting the appropriate PNGLIB
Packit 0ba690
     and ZLIB lines will build dynamically linked executables instead.
Packit 0ba690
Packit 0ba690
     Do the build by typing
Packit 0ba690
Packit 0ba690
        nmake
Packit 0ba690
Packit 0ba690
     The result should be three executables:  rpng-win.exe, rpng2-win.exe,
Packit 0ba690
     and wpng.exe.  Copy them somewhere in your PATH or run them from the
Packit 0ba690
     current folder.  Like the Unix versions, the two windowed programs
Packit 0ba690
     (rpng and rpng2) now display a usage screen in a console window when
Packit 0ba690
     invoked without command-line arguments; this is new behavior as of
Packit 0ba690
     the June 2001 release.  Note that the programs use the Unix-style "-"
Packit 0ba690
     character to specify options, instead of the more common DOS/Windows
Packit 0ba690
     "/" character.  (For example:  "rpng2-win -bgpat 4 foo.png", not
Packit 0ba690
     "rpng2-win /bgpat 4 foo.png")
Packit 0ba690
Packit 0ba690
Packit 0ba690
 - OpenVMS:
Packit 0ba690
Packit 0ba690
     Unpack the pngbook sources into a subdirectory and change into that
Packit 0ba690
     subdirectory.
Packit 0ba690
Packit 0ba690
     Edit makevms.com appropriately, specifically the zpath and pngpath
Packit 0ba690
     variables.
Packit 0ba690
Packit 0ba690
     @makevms
Packit 0ba690
Packit 0ba690
     To run the programs, they probably first need to be set up as "foreign
Packit 0ba690
     symbols," with "disk" and "dir" set appropriately:
Packit 0ba690
Packit 0ba690
     $ rpng  == "$disk:[dir]rpng-x.exe"
Packit 0ba690
     $ rpng2 == "$disk:[dir]rpng2-x.exe"
Packit 0ba690
     $ wpng  == "$disk:[dir]wpng.exe"
Packit 0ba690
Packit 0ba690
     All three will print a basic usage screen when run without any command-
Packit 0ba690
     line arguments; see the book for more details.  Note that the options
Packit 0ba690
     style is Unix-like, i.e., preceded by "-" rather than "/".
Packit 0ba690
Packit 0ba690
Packit 0ba690
RUNNING THE PROGRAMS:  (VERY) BRIEF INTRO
Packit 0ba690
Packit 0ba690
     rpng is a simple PNG viewer that can display transparent PNGs with a
Packit 0ba690
     specified background color; for example,
Packit 0ba690
Packit 0ba690
	rpng -bgcolor #ff0000 toucan.png
Packit 0ba690
Packit 0ba690
     would display the image with a red background.  rpng2 is a progressive
Packit 0ba690
     viewer that simulates a web browser in some respects; it can display
Packit 0ba690
     images against either a background color or a dynamically generated
Packit 0ba690
     background image.  For example:
Packit 0ba690
Packit 0ba690
	rpng2 -bgpat 16 toucan.png
Packit 0ba690
Packit 0ba690
     wpng is a purely command-line image converter from binary PBMPLUS/NetPBM
Packit 0ba690
     format (.pgm or .ppm) to PNG; for example,
Packit 0ba690
Packit 0ba690
	wpng -time < toucan-notrans.ppm > toucan-notrans.png
Packit 0ba690
Packit 0ba690
     would convert the specified PPM file (using redirection) to PNG, auto-
Packit 0ba690
     matically setting the PNG modification-time chunk.
Packit 0ba690
Packit 0ba690
     All options can be abbreviated to the shortest unique value; for example,
Packit 0ba690
     "-bgc" for -bgcolor (versus "-bgp" for -bgpat), or "-g" for -gamma.