• Home
  • History
  • Annotate
  • only in /external/libpng/contrib/gregbook/
NameDateSize

..12-Mar-20154 KiB

COPYING12-Mar-201517.7 KiB

LICENSE12-Mar-20152.3 KiB

Makefile.mingw3212-Mar-20153.8 KiB

Makefile.sgi12-Mar-20152.9 KiB

Makefile.unx12-Mar-20153.9 KiB

Makefile.w3212-Mar-20153.3 KiB

makevms.com12-Mar-20153.5 KiB

README12-Mar-20157.7 KiB

readpng.c12-Mar-20159.8 KiB

readpng.h12-Mar-20153.2 KiB

readpng2.c12-Mar-201517.4 KiB

readpng2.h12-Mar-20153.7 KiB

readppm.c12-Mar-20155.3 KiB

rpng-win.c12-Mar-201523.2 KiB

rpng-x.c12-Mar-201530.1 KiB

rpng2-win.c12-Mar-201544.3 KiB

rpng2-x.c12-Mar-201579.4 KiB

toucan.png12-Mar-201512.6 KiB

wpng.c12-Mar-201530.3 KiB

writepng.c12-Mar-201513 KiB

writepng.h12-Mar-20154.1 KiB

README

1                     ===========================
2                      PNG: The Definitive Guide
3                     ===========================
4
5                             Source Code
6
7Chapters 13, 14 and 15 of "PNG: The Definitive Guide" discuss three free,
8cross-platform demo programs that show how to use the libpng reference
9library:  rpng, rpng2 and wpng.  rpng and rpng2 are viewers; the first is
10a very simple example that that shows how a standard file-viewer might use
11libpng, while the second is designed to process streaming data and shows
12how a web browser might be written.  wpng is a simple command-line program
13that reads binary PGM and PPM files (the ``raw'' grayscale and RGB subsets
14of PBMPLUS/NetPBM) and converts them to PNG.
15
16The source code for all three demo programs currently compiles under
17Unix, OpenVMS, and 32-bit Windows.  (Special thanks to Martin Zinser,
18zinser@decus.de, for making the necessary changes for OpenVMS and for
19providing an appropriate build script.)  Build instructions can be found
20below.
21
22Files:
23
24   README             this file
25   LICENSE            terms of distribution and reuse (BSD-like or GNU GPL)
26   COPYING            GNU General Public License (GPL)
27
28   Makefile.unx       Unix makefile
29   Makefile.w32       Windows (MSVC) makefile
30   makevms.com        OpenVMS build script
31
32   rpng-win.c         Windows front end for the basic viewer
33   rpng-x.c           X Window System (Unix, OpenVMS) front end
34   readpng.c          generic back end for the basic viewer
35   readpng.h          header file for the basic viewer
36
37   rpng2-win.c        Windows front end for the progressive viewer
38   rpng2-x.c          X front end for the progressive viewer
39   readpng2.c         generic back end for the progressive viewer
40   readpng2.h         header file for the progressive viewer
41
42   wpng.c             generic (text) front end for the converter
43   writepng.c         generic back end for the converter
44   writepng.h         header file for the converter
45
46   toucan.png         transparent PNG for testing (by Stefan Schneider)
47
48Note that, although the programs are designed to be functional, their
49primary purpose is to illustrate how to use libpng to add PNG support to
50other programs.  As such, their user interfaces are crude and definitely
51are not intended for everyday use.
52
53Please see http://www.libpng.org/pub/png/pngbook.html for further infor-
54mation and links to the latest version of the source code, and Chapters
5513-15 of the book for detailed discussion of the three programs.
56
57Greg Roelofs
58http://pobox.com/~newt/greg_contact.html
5916 March 2008
60
61
62BUILD INSTRUCTIONS
63
64 - Prerequisites (in order of compilation):
65
66      - zlib            http://zlib.net/
67      - libpng          http://www.libpng.org/pub/png/libpng.html
68      - pngbook         http://www.libpng.org/pub/png/book/sources.html
69
70     The pngbook demo programs are explicitly designed to demonstrate proper
71     coding techniques for using the libpng reference library.  As a result,
72     you need to download and build both zlib (on which libpng depends) and
73     libpng.  A common build setup is to place the zlib, libpng and pngbook
74     subdirectory trees ("folders") in the same parent directory.  Then the
75     libpng build can refer to files in ../zlib (or ..\zlib or [-.zlib]),
76     and similarly for the pngbook build.
77
78     Note that all three packages are designed to be built from a command
79     line by default; those who wish to use a graphical or other integrated
80     development environments are on their own.
81
82
83 - Unix:
84
85     Unpack the latest pngbook sources (which should correspond to this
86     README file) into a directory and change into that directory.
87
88     Copy Makefile.unx to Makefile and edit the PNG* and Z* variables
89     appropriately (possibly also the X* variables if necessary).
90
91     make
92
93     There is no "install" target, so copy the three executables somewhere
94     in your path or run them from the current directory.  All three will
95     print a basic usage screen when run without any command-line arguments;
96     see the book for more details.
97
98
99 - Windows:
100
101     Unpack the latest pngbook sources (which should correspond to this
102     README file) into a folder, open a "DOS shell" or "command prompt"
103     or equivalent command-line window, and cd into the folder where you
104     unpacked the source code.
105
106     For MSVC, set up the necessary environment variables by invoking
107
108        %devstudio%\vc\bin\vcvars32.bat
109
110     where where %devstudio% is the installation directory for MSVC /
111     DevStudio.  If you get "environment out of space" errors under 95/98,
112     create a desktop shortcut with "c:\windows\command.com /e:4096" as
113     the program command line and set the working directory to the pngbook
114     directory.  Then double-click to open the new DOS-prompt window with
115     a bigger environment and retry the commands above.
116
117     Copy Makefile.w32 to Makefile and edit the PNGPATH and ZPATH variables
118     appropriately (possibly also the "INC" and "LIB" variables if needed).
119     Note that the names of the dynamic and static libpng and zlib libraries
120     used in the makefile may change in later releases of the libraries.
121     Also note that, as of libpng version 1.0.5, MSVC DLL builds do not work.
122     This makefile therefore builds statically linked executables, but if
123     the DLL problems ever get fixed, uncommenting the appropriate PNGLIB
124     and ZLIB lines will build dynamically linked executables instead.
125
126     Do the build by typing
127
128        nmake
129
130     The result should be three executables:  rpng-win.exe, rpng2-win.exe,
131     and wpng.exe.  Copy them somewhere in your PATH or run them from the
132     current folder.  Like the Unix versions, the two windowed programs
133     (rpng and rpng2) now display a usage screen in a console window when
134     invoked without command-line arguments; this is new behavior as of
135     the June 2001 release.  Note that the programs use the Unix-style "-"
136     character to specify options, instead of the more common DOS/Windows
137     "/" character.  (For example:  "rpng2-win -bgpat 4 foo.png", not
138     "rpng2-win /bgpat 4 foo.png")
139
140
141 - OpenVMS:
142
143     Unpack the pngbook sources into a subdirectory and change into that
144     subdirectory.
145
146     Edit makevms.com appropriately, specifically the zpath and pngpath
147     variables.
148
149     @makevms
150
151     To run the programs, they probably first need to be set up as "foreign
152     symbols," with "disk" and "dir" set appropriately:
153
154     $ rpng  == "$disk:[dir]rpng-x.exe"
155     $ rpng2 == "$disk:[dir]rpng2-x.exe"
156     $ wpng  == "$disk:[dir]wpng.exe"
157
158     All three will print a basic usage screen when run without any command-
159     line arguments; see the book for more details.  Note that the options
160     style is Unix-like, i.e., preceded by "-" rather than "/".
161
162
163RUNNING THE PROGRAMS:  (VERY) BRIEF INTRO
164
165     rpng is a simple PNG viewer that can display transparent PNGs with a
166     specified background color; for example,
167
168        rpng -bgcolor \#ff0000 toucan.png
169
170     would display the image with a red background.  rpng2 is a progressive
171     viewer that simulates a web browser in some respects; it can display
172     images against either a background color or a dynamically generated
173     background image.  For example:
174
175        rpng2 -bgpat 16 toucan.png
176
177     wpng is a purely command-line image converter from binary PBMPLUS/NetPBM
178     format (.pgm or .ppm) to PNG; for example,
179
180        wpng -time < toucan-notrans.ppm > toucan-notrans.png
181
182     would convert the specified PPM file (using redirection) to PNG, auto-
183     matically setting the PNG modification-time chunk.
184
185     All options can be abbreviated to the shortest unique value; for example,
186     "-bgc" for -bgcolor (versus "-bgp" for -bgpat), or "-g" for -gamma.
187