Imported from libpng-0.99i.tar
This commit is contained in:
parent
cbe52d8720
commit
08a3343e05
20
CHANGES
20
CHANGES
@ -1,4 +1,4 @@
|
||||
pngchange.txt - changes for libpng
|
||||
CHANGES - changes for libpng
|
||||
|
||||
version 0.2
|
||||
added reader into png.h
|
||||
@ -244,3 +244,21 @@ version 0.99e [February 28, 1998]
|
||||
Replaced pngtest.png with one created with zlib 1.1.1
|
||||
Changed pngtest to report PASS even when file size is different (Jean-loup G.)
|
||||
Corrected some logic errors in png_do_invert_alpha() (Chris Patterson)
|
||||
version 0.99f [March 5, 1998]
|
||||
Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey)
|
||||
Moved makefiles into a "scripts" directory, and added INSTALL instruction file
|
||||
Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok)
|
||||
Added pointers to "note on libpng versions" in makefile.lnx and README
|
||||
Added row callback feature when reading and writing nonprogressive rows
|
||||
and added a test of this feature in pngtest.c
|
||||
Added user transform callbacks, with test of the feature in pngtest.c
|
||||
version 0.99g [March 6, 1998, morning]
|
||||
Minor changes to pngtest.c to suppress compiler warnings.
|
||||
Removed "beta" language from documentation.
|
||||
version 0.99h [March 6, 1998, evening]
|
||||
Minor changes to previous minor changes to pngtest.c
|
||||
Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED
|
||||
and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro
|
||||
version 1.00 [March 7, 1998]
|
||||
Changed several typedefs in pngrutil.c
|
||||
Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik)
|
||||
|
85
INSTALL
Normal file
85
INSTALL
Normal file
@ -0,0 +1,85 @@
|
||||
|
||||
Installing libpng version 1.00 March 7, 1998
|
||||
|
||||
Before installing libpng, you must first install zlib. zlib
|
||||
can usually be found wherever you got libpng. zlib can be
|
||||
placed in another directory, at the same level as libpng.
|
||||
Note that your system might already have a preinstalled
|
||||
zlib, but you will still need to have access to the
|
||||
zlib.h and zconf.h include files that correspond to the
|
||||
version of zlib that's installed.
|
||||
|
||||
You can rename the directories that you downloaded (they
|
||||
might be called "libpng-1.00 or "lpng100" and "zlib-1.1.1"
|
||||
or "zlib111") so that you have directories called "zlib" and "libpng".
|
||||
|
||||
Your directory structure should look like this:
|
||||
|
||||
.. (the parent directory)
|
||||
libpng (this directory)
|
||||
INSTALL (this file)
|
||||
README
|
||||
*.h
|
||||
*.c
|
||||
scripts
|
||||
makefile.*
|
||||
pngtest.png
|
||||
etc.
|
||||
zlib
|
||||
README
|
||||
*.h
|
||||
*.c
|
||||
contrib
|
||||
etc.
|
||||
|
||||
First enter the zlib directory and follow the instructions
|
||||
in zlib/README. Then come back here and choose the
|
||||
appropriate makefile.sys in the scripts directory.
|
||||
The files that are presently available in the scripts directory
|
||||
include
|
||||
|
||||
descrip.mms => VMS makefile for MMS or MMK
|
||||
makefile.std => Generic UNIX makefile
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.sgi => Silicon Graphics IRIX makefile
|
||||
makefile.sun => Sun makefile
|
||||
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.00)
|
||||
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.00)
|
||||
makefile.mip => MIPS makefile
|
||||
makefile.aco => Acorn makefile
|
||||
makefile.ama => Amiga makefile
|
||||
makefile.atr => Atari makefile
|
||||
makefile.bor => Borland makefile
|
||||
build.bat => MS-DOS batch file for Borland compiler
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.msc => Microsoft C makefile
|
||||
makefile.tc3 => Turbo C 3.0 makefile
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
|
||||
pngos2.def => OS/2 module definition file used by makefile.os2
|
||||
makefile.wat => Watcom 10a+ Makefile, 32-bit flat memory model
|
||||
makevms.com => VMS build script
|
||||
|
||||
Copy the file (or files) that you need from the
|
||||
scripts directory into this directory, for example
|
||||
|
||||
MSDOS example: copy scripts\makefile.msd makefile
|
||||
UNIX example: cp scripts/makefile.std makefile
|
||||
|
||||
Read the makefile to see if you need to change any source or
|
||||
target directories to match your preferences.
|
||||
|
||||
Then read pngconf.h to see if you want to make any configuration
|
||||
changes.
|
||||
|
||||
Then just run "make test" which will create the libpng library in
|
||||
this directory and run a quick test that reads the "pngtest.png"
|
||||
file and writes a "pngout.png" file that should be identical to it.
|
||||
|
||||
Most of the makefiles will allow you to run "make install" to
|
||||
put the library in its final resting place (if you want to
|
||||
do that, run "make install" in the zlib directory first if necessary).
|
||||
|
||||
Further information can be found in the README and libpng.txt
|
||||
files, in the individual makefiles, and in png.h, and the manual
|
||||
pages libpng.3 and png.5.
|
46
README
46
README
@ -1,8 +1,7 @@
|
||||
[NOTE: this is still beta version 0.99e; the text below has already
|
||||
been updated in anticipation of the imminent 1.0 release.]
|
||||
README for libpng 1.00 (shared library 2.1)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
|
||||
README for libpng 1.0
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
This is the first official release of libpng. Don't let the fact that
|
||||
it's the first release fool you. The libpng library has been in
|
||||
@ -117,7 +116,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
|
||||
to others, if necessary.
|
||||
|
||||
Please do not send suggestions on how to change PNG. We have
|
||||
been discussing PNG for a couple years now, and it is official and
|
||||
been discussing PNG for three years now, and it is official and
|
||||
finished. If you have suggestions for libpng, however, I'll
|
||||
gladly listen. Even if your suggestion is not used for version
|
||||
1.0, it may be used later.
|
||||
@ -135,21 +134,6 @@ Files in this distribution:
|
||||
libpng.3 => manual page for libpng
|
||||
libpng.txt => Description of libpng and its functions
|
||||
libpngpf.3 => manual page for libpng's private functions
|
||||
makefile.aco => ACORN makefile
|
||||
makefile.ama => Amiga makefile
|
||||
makefile.atr => Atari makefile
|
||||
makefile.bor => Borland makefile
|
||||
makefile.dec => DEC makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.knr => Makefile which calls ansi2knr to convert files
|
||||
makefile.lnx => Unix Linux/ELF makefile
|
||||
makefile.mip => MIPS makefile
|
||||
makefile.msc => Microsoft C makefile
|
||||
makefile.sgi => Silicon Graphics Irix makefile
|
||||
makefile.std => Standard Unix makefile
|
||||
makefile.sun => SUN makefile
|
||||
makefile.tc3 => Turbo C 3.0 makefile
|
||||
makevms.com => VMS make program
|
||||
png.5 => manual page for the PNG format
|
||||
png.c => Basic interface functions common to library
|
||||
png.h => Library function and interface declarations
|
||||
@ -170,6 +154,28 @@ Files in this distribution:
|
||||
pngwrite.c => High-level write functions
|
||||
pngwtran.c => Write data transformations
|
||||
pngwutil.c => Write utility functions
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
descrip.mms => VMS makefile for MMS or MMK
|
||||
makefile.std => Generic UNIX makefile
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.sgi => Silicon Graphics IRIX makefile
|
||||
makefile.sun => Sun makefile
|
||||
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.00)
|
||||
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.00)
|
||||
makefile.mip => MIPS makefile
|
||||
makefile.aco => Acorn makefile
|
||||
makefile.ama => Amiga makefile
|
||||
makefile.atr => Atari makefile
|
||||
makefile.bor => Borland makefile
|
||||
build.bat => MS-DOS batch file for Borland compiler
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.msc => Microsoft C makefile
|
||||
makefile.tc3 => Turbo C 3.0 makefile
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
|
||||
makefile.wat => Watcom 10a+ Makefile, 32-bit flat memory model
|
||||
pngos2.def => OS/2 module definition file used by makefile.os2
|
||||
makevms.com => VMS build script
|
||||
|
||||
Good luck, and happy coding.
|
||||
|
||||
|
2
TODO
2
TODO
@ -1,4 +1,4 @@
|
||||
pngtodo.txt - list of things to do for libpng
|
||||
TODO - list of things to do for libpng
|
||||
|
||||
add "grayscale->palette" transformation and "palette->grayscale" detection
|
||||
improved dithering
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
/* example.c - an example of using libpng */
|
||||
|
||||
/* This is an example of how to use libpng to read and write PNG files.
|
||||
|
132
libpng.3
132
libpng.3
@ -1,4 +1,4 @@
|
||||
.TH LIBPNG 3 "February 28, 1998"
|
||||
.TH LIBPNG 3 "March 7, 1998"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library
|
||||
.SH SYNOPSIS
|
||||
@ -301,6 +301,12 @@ png_colorp palette, int num_palette);
|
||||
void png_set_read_fn (png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn);
|
||||
|
||||
void png_set_read_status_fn (png_structp png_ptr, png_read_status_ptr
|
||||
read_row_fn);
|
||||
|
||||
void png_set_read_user_transform_fn (png_structp png_ptr,
|
||||
png_user_transform_ptr read_user_transform_fn);
|
||||
|
||||
void png_set_rgb_to_gray (png_structp png_ptr);
|
||||
|
||||
void png_set_sBIT (png_structp png_ptr, png_infop info_ptr,
|
||||
@ -337,6 +343,12 @@ png_bytep trans, int num_trans, png_color_16p trans_values);
|
||||
void png_set_write_fn (png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn);
|
||||
|
||||
void png_set_write_status_fn (png_structp png_ptr, png_write_status_ptr
|
||||
write_row_fn);
|
||||
|
||||
void png_set_write_user_transform_fn (png_structp png_ptr,
|
||||
png_user_transform_ptr write_user_transform_fn);
|
||||
|
||||
int png_sig_cmp (png_bytep sig, png_size_t start, png_size_t
|
||||
num_to_check);
|
||||
|
||||
@ -384,23 +396,23 @@ Following is a copy of the libpng.txt file that accompanies libpng.
|
||||
.SH LIBPNG.TXT
|
||||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 0.99e
|
||||
libpng version 1.00 March 7, 1998
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<randeg@alumni.rpi.edu>
|
||||
Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
February 28, 1998
|
||||
For conditions of distribution and use, see copyright
|
||||
notice in png.h.
|
||||
|
||||
based on:
|
||||
|
||||
libpng 1.0 beta 6 version 0.96
|
||||
libpng 1.0 beta 6 version 0.96 May 28, 1997
|
||||
Updated and distributed by Andreas Dilger
|
||||
Copyright (c) 1996, 1997 Andreas Dilger
|
||||
May 28, 1997
|
||||
|
||||
libpng 1.0 beta 2 - version 0.88
|
||||
libpng 1.0 beta 2 - version 0.88 January 26, 1996
|
||||
For conditions of distribution and use, see copyright
|
||||
notice in png.h. Copyright (c) 1995, 1996 Guy Eric
|
||||
Schalnat, Group 42, Inc. January 26, 1996
|
||||
Schalnat, Group 42, Inc.
|
||||
|
||||
Updated/rewritten per request in the libpng FAQ
|
||||
Copyright (c) 1995 Frank J. T. Wojcik
|
||||
@ -414,7 +426,8 @@ file: introduction, structures, reading, writing, and modification and
|
||||
configuration notes for various special platforms. In addition to this
|
||||
file, example.c is a good starting point for using the library, as
|
||||
it is heavily commented and should include everything most people
|
||||
will need.
|
||||
will need. We assume that libpng is already installed; see the
|
||||
INSTALL file for instructions on how to install libpng.
|
||||
|
||||
Libpng was written as a companion to the PNG specification, as a way
|
||||
of reducing the amount of time and effort it takes to support the PNG
|
||||
@ -586,6 +599,22 @@ libpng know that there are some bytes missing from the start of the file.
|
||||
|
||||
png_set_sig_bytes(png_ptr, number);
|
||||
|
||||
At this point, you can set up a callback function that will be
|
||||
called after each row has been read, which you can use to control
|
||||
a progress meter or the like. It's demonstrated in pngtest.c.
|
||||
You must supply a function
|
||||
|
||||
void read_row_callback(png_ptr, png_uint_32 row, int pass);
|
||||
{
|
||||
/* put your code here */
|
||||
}
|
||||
|
||||
(You can give it another name that you like instead of "read_row_callback")
|
||||
|
||||
To inform libpng about your function, use
|
||||
|
||||
png_set_read_status_fn(png_ptr, read_row_callback);
|
||||
|
||||
In PNG files, the alpha channel in an image is the level of opacity.
|
||||
If you need the alpha channel in an image to be the level of transparency
|
||||
instead of opacity, you can invert the alpha channel (or the tRNS chunk
|
||||
@ -599,6 +628,21 @@ because the tRNS chunk data must be modified in the case of paletted images.
|
||||
If your image is not a paletted image, the tRNS data (which in such cases
|
||||
represents a single color to be rendered as transparent) won't be changed.
|
||||
|
||||
Finally, you can write your own transformation function if none of
|
||||
the existing ones meets your needs. This is done by setting a callback
|
||||
with
|
||||
|
||||
png_set_read_user_transform_fn(png_ptr,
|
||||
read_transform_fn);
|
||||
|
||||
You must supply the function
|
||||
|
||||
void read_transform_fn(png_ptr ptr, row_info_ptr
|
||||
row_info, png_bytep data)
|
||||
|
||||
See pngtest.c for a working example. Your function will be called
|
||||
after all of the other transformations have been processed.
|
||||
|
||||
You are now ready to read all the file information up to the actual
|
||||
image data. You do this with a call to png_read_info().
|
||||
|
||||
@ -958,9 +1002,8 @@ the overall gamma correction required to produce pleasing results,
|
||||
which depends on the lighting conditions in the surrounding environment.
|
||||
Screen_gamma is display_gamma/viewing_gamma, where viewing_gamma is
|
||||
the amount of additional gamma correction needed to compensate for
|
||||
a dark (viewing_gamma=1.25) environment.
|
||||
In a dim or brightly lit room, no compensation other than the display_gamma
|
||||
is needed (viewing_gamma=1.0).
|
||||
a (viewing_gamma=1.25) environment. In a dim or brightly lit room, no
|
||||
compensation other than the display_gamma is needed (viewing_gamma=1.0).
|
||||
|
||||
if (/* We have a user-defined screen
|
||||
gamma value */)
|
||||
@ -1299,6 +1342,7 @@ png_infop info_ptr;
|
||||
read.
|
||||
*/
|
||||
void
|
||||
info_callback(png_structp png_ptr, png_infop info)
|
||||
{
|
||||
/* Do any setup here, including setting any of
|
||||
the transformations mentioned in the Reading
|
||||
@ -1368,8 +1412,6 @@ png_infop info_ptr;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
.SH IV. Writing
|
||||
|
||||
Much of this is very similar to reading. However, everything of
|
||||
@ -1390,7 +1432,10 @@ custom writing functions. See the discussion under Customizing libpng.
|
||||
Next, png_struct and png_info need to be allocated and initialized.
|
||||
As these can be both relatively large, you may not want to store these
|
||||
on the stack, unless you have stack space to spare. Of course, you
|
||||
will want to check if they return NULL.
|
||||
will want to check if they return NULL. If you are also reading,
|
||||
you won't want to name your read structure and your write structure
|
||||
both "png_ptr"; you can call them anything you like, such as
|
||||
"read_ptr" and "write_ptr". Look at pngtest.c, for example.
|
||||
|
||||
png_structp png_ptr = png_create_write_struct
|
||||
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
|
||||
@ -1433,6 +1478,22 @@ Libpng section below.
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
At this point, you can set up a callback function that will be
|
||||
called after each row has been written, which you can use to control
|
||||
a progress meter or the like. It's demonstrated in pngtest.c.
|
||||
You must supply a function
|
||||
|
||||
void write_row_callback(png_ptr, png_uint_32 row, int pass);
|
||||
{
|
||||
/* put your code here */
|
||||
}
|
||||
|
||||
(You can give it another name that you like instead of "write_row_callback")
|
||||
|
||||
To inform libpng about your function, use
|
||||
|
||||
png_set_write_status_fn(png_ptr, write_row_callback);
|
||||
|
||||
You now have the option of modifying how the compression library will
|
||||
run. The following functions are mainly for testing, but may be useful
|
||||
in some cases, like if you need to write PNG files extremely fast and
|
||||
@ -1789,6 +1850,21 @@ one. This code would be used if the pixels are supplied with this reversed
|
||||
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
Finally, you can write your own transformation function if none of
|
||||
the existing ones meets your needs. This is done by setting a callback
|
||||
with
|
||||
|
||||
png_set_write_user_transform_fn(png_ptr,
|
||||
write_transform_fn);
|
||||
|
||||
You must supply the function
|
||||
|
||||
void write_transform_fn(png_ptr ptr, row_info_ptr
|
||||
row_info, png_bytep data)
|
||||
|
||||
See pngtest.c for a working example. Your function will be called
|
||||
before any of the other transformations have been processed.
|
||||
|
||||
It is possible to have libpng flush any pending output, either manually,
|
||||
or automatically after a certain number of lines have been written. To
|
||||
flush the output stream a single time call:
|
||||
@ -2143,15 +2219,18 @@ There are a bunch of #define's in pngconf.h that control what parts of
|
||||
libpng are compiled. All the defines end in _SUPPORTED. If you are
|
||||
never going to use an ability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space.
|
||||
You can also turn them off en masse with a compiler directive that
|
||||
defines PNG_READ[or WRITE]_NOT_FULLY_SUPPORTED, or
|
||||
You can also turn a number of them off en masse with a compiler directive
|
||||
that defines PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED, or
|
||||
PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four,
|
||||
along with directives to turn on any of the capabilities that you do
|
||||
want. The NOT_FULLY_SUPPORTED directives disable the extra
|
||||
transformations but still leave the library fully capable of reading
|
||||
want. The PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED directives disable
|
||||
the extra transformations but still leave the library fully capable of reading
|
||||
and writing PNG files with all known public chunks [except for sPLT].
|
||||
Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive
|
||||
produces a library that is incapable of reading or writing ancillary chunks.
|
||||
If you are not using the progressive reading capability, you can
|
||||
turn that off with PNG_PROGRESSIVE_READ_NOT_SUPPORTED (don't confuse
|
||||
this with the INTERLACING capability, which you'll still have).
|
||||
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
linker should only grab the files it needs. However, if you want to
|
||||
@ -2227,9 +2306,7 @@ the first widely used release:
|
||||
0.97c 0.97 2.0.97
|
||||
0.98 0.98 2.0.98
|
||||
0.99 0.99 2.0.99
|
||||
0.99a 0.99 2.0.99
|
||||
0.99b 0.99 2.0.99
|
||||
0.99e 0.99 2.0.99
|
||||
0.99a-g 0.99 2.0.99
|
||||
1.0 1.00 2.1.0
|
||||
|
||||
Henceforth the source version will match the shared-library minor
|
||||
@ -2288,7 +2365,7 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 0.99e (February 28, 1998):
|
||||
Libpng version 1.00 (March 7, 1998):
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Currently maintained by Glenn Randers-Pehrson (randeg@alumni.rpi.edu).
|
||||
|
||||
@ -2296,17 +2373,6 @@ Supported by the PNG development group
|
||||
.br
|
||||
(png-implement@dworkin.wustl.edu).
|
||||
|
||||
.SH BETA NOTICE
|
||||
This is a beta version. It reads and writes valid files on the
|
||||
platforms I have, and has had a wide testing program. You may
|
||||
have to modify the includes in png.h to get it to work on your
|
||||
system, and you may have to supply the correct compiler flags in
|
||||
the makefile if you can't find a makefile suitable for your
|
||||
operating system/compiler combination. Please contact the authors
|
||||
via the mailing list png-implement@dworkin.wustl.edu if you have any
|
||||
problems, or if you want your compiler/platform to be supported in
|
||||
the next official libpng release.
|
||||
|
||||
.SH COPYRIGHT NOTICE:
|
||||
|
||||
The PNG Reference Library (libpng) is supplied "AS IS". The Contributing
|
||||
|
94
libpng.txt
94
libpng.txt
@ -1,22 +1,22 @@
|
||||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 0.99e
|
||||
libpng version 1.00 March 7, 1998
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<randeg@alumni.rpi.edu>
|
||||
Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
February 28, 1998
|
||||
For conditions of distribution and use, see copyright
|
||||
notice in png.h.
|
||||
|
||||
based on:
|
||||
|
||||
libpng 1.0 beta 6 version 0.96
|
||||
libpng 1.0 beta 6 version 0.96 May 28, 1997
|
||||
Updated and distributed by Andreas Dilger
|
||||
Copyright (c) 1996, 1997 Andreas Dilger
|
||||
May 28, 1997
|
||||
|
||||
libpng 1.0 beta 2 - version 0.88
|
||||
libpng 1.0 beta 2 - version 0.88 January 26, 1996
|
||||
For conditions of distribution and use, see copyright
|
||||
notice in png.h. Copyright (c) 1995, 1996 Guy Eric
|
||||
Schalnat, Group 42, Inc. January 26, 1996
|
||||
Schalnat, Group 42, Inc.
|
||||
|
||||
Updated/rewritten per request in the libpng FAQ
|
||||
Copyright (c) 1995 Frank J. T. Wojcik
|
||||
@ -30,7 +30,8 @@ file: introduction, structures, reading, writing, and modification and
|
||||
configuration notes for various special platforms. In addition to this
|
||||
file, example.c is a good starting point for using the library, as
|
||||
it is heavily commented and should include everything most people
|
||||
will need.
|
||||
will need. We assume that libpng is already installed; see the
|
||||
INSTALL file for instructions on how to install libpng.
|
||||
|
||||
Libpng was written as a companion to the PNG specification, as a way
|
||||
of reducing the amount of time and effort it takes to support the PNG
|
||||
@ -202,6 +203,22 @@ libpng know that there are some bytes missing from the start of the file.
|
||||
|
||||
png_set_sig_bytes(png_ptr, number);
|
||||
|
||||
At this point, you can set up a callback function that will be
|
||||
called after each row has been read, which you can use to control
|
||||
a progress meter or the like. It's demonstrated in pngtest.c.
|
||||
You must supply a function
|
||||
|
||||
void read_row_callback(png_ptr, png_uint_32 row, int pass);
|
||||
{
|
||||
/* put your code here */
|
||||
}
|
||||
|
||||
(You can give it another name that you like instead of "read_row_callback")
|
||||
|
||||
To inform libpng about your function, use
|
||||
|
||||
png_set_read_status_fn(png_ptr, read_row_callback);
|
||||
|
||||
In PNG files, the alpha channel in an image is the level of opacity.
|
||||
If you need the alpha channel in an image to be the level of transparency
|
||||
instead of opacity, you can invert the alpha channel (or the tRNS chunk
|
||||
@ -215,6 +232,21 @@ because the tRNS chunk data must be modified in the case of paletted images.
|
||||
If your image is not a paletted image, the tRNS data (which in such cases
|
||||
represents a single color to be rendered as transparent) won't be changed.
|
||||
|
||||
Finally, you can write your own transformation function if none of
|
||||
the existing ones meets your needs. This is done by setting a callback
|
||||
with
|
||||
|
||||
png_set_read_user_transform_fn(png_ptr,
|
||||
read_transform_fn);
|
||||
|
||||
You must supply the function
|
||||
|
||||
void read_transform_fn(png_ptr ptr, row_info_ptr
|
||||
row_info, png_bytep data)
|
||||
|
||||
See pngtest.c for a working example. Your function will be called
|
||||
after all of the other transformations have been processed.
|
||||
|
||||
You are now ready to read all the file information up to the actual
|
||||
image data. You do this with a call to png_read_info().
|
||||
|
||||
@ -914,6 +946,7 @@ png_infop info_ptr;
|
||||
read.
|
||||
*/
|
||||
void
|
||||
info_callback(png_structp png_ptr, png_infop info)
|
||||
{
|
||||
/* Do any setup here, including setting any of
|
||||
the transformations mentioned in the Reading
|
||||
@ -1005,7 +1038,10 @@ custom writing functions. See the discussion under Customizing libpng.
|
||||
Next, png_struct and png_info need to be allocated and initialized.
|
||||
As these can be both relatively large, you may not want to store these
|
||||
on the stack, unless you have stack space to spare. Of course, you
|
||||
will want to check if they return NULL.
|
||||
will want to check if they return NULL. If you are also reading,
|
||||
you won't want to name your read structure and your write structure
|
||||
both "png_ptr"; you can call them anything you like, such as
|
||||
"read_ptr" and "write_ptr". Look at pngtest.c, for example.
|
||||
|
||||
png_structp png_ptr = png_create_write_struct
|
||||
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
|
||||
@ -1048,6 +1084,22 @@ Libpng section below.
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
At this point, you can set up a callback function that will be
|
||||
called after each row has been written, which you can use to control
|
||||
a progress meter or the like. It's demonstrated in pngtest.c.
|
||||
You must supply a function
|
||||
|
||||
void write_row_callback(png_ptr, png_uint_32 row, int pass);
|
||||
{
|
||||
/* put your code here */
|
||||
}
|
||||
|
||||
(You can give it another name that you like instead of "write_row_callback")
|
||||
|
||||
To inform libpng about your function, use
|
||||
|
||||
png_set_write_status_fn(png_ptr, write_row_callback);
|
||||
|
||||
You now have the option of modifying how the compression library will
|
||||
run. The following functions are mainly for testing, but may be useful
|
||||
in some cases, like if you need to write PNG files extremely fast and
|
||||
@ -1404,6 +1456,21 @@ one. This code would be used if the pixels are supplied with this reversed
|
||||
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
Finally, you can write your own transformation function if none of
|
||||
the existing ones meets your needs. This is done by setting a callback
|
||||
with
|
||||
|
||||
png_set_write_user_transform_fn(png_ptr,
|
||||
write_transform_fn);
|
||||
|
||||
You must supply the function
|
||||
|
||||
void write_transform_fn(png_ptr ptr, row_info_ptr
|
||||
row_info, png_bytep data)
|
||||
|
||||
See pngtest.c for a working example. Your function will be called
|
||||
before any of the other transformations have been processed.
|
||||
|
||||
It is possible to have libpng flush any pending output, either manually,
|
||||
or automatically after a certain number of lines have been written. To
|
||||
flush the output stream a single time call:
|
||||
@ -1758,15 +1825,18 @@ There are a bunch of #define's in pngconf.h that control what parts of
|
||||
libpng are compiled. All the defines end in _SUPPORTED. If you are
|
||||
never going to use an ability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space.
|
||||
You can also turn them off en masse with a compiler directive that
|
||||
defines PNG_READ[or WRITE]_NOT_FULLY_SUPPORTED, or
|
||||
You can also turn a number of them off en masse with a compiler directive
|
||||
that defines PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED, or
|
||||
PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four,
|
||||
along with directives to turn on any of the capabilities that you do
|
||||
want. The NOT_FULLY_SUPPORTED directives disable the extra
|
||||
transformations but still leave the library fully capable of reading
|
||||
want. The PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED directives disable
|
||||
the extra transformations but still leave the library fully capable of reading
|
||||
and writing PNG files with all known public chunks [except for sPLT].
|
||||
Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive
|
||||
produces a library that is incapable of reading or writing ancillary chunks.
|
||||
If you are not using the progressive reading capability, you can
|
||||
turn that off with PNG_PROGRESSIVE_READ_NOT_SUPPORTED (don't confuse
|
||||
this with the INTERLACING capability, which you'll still have).
|
||||
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
linker should only grab the files it needs. However, if you want to
|
||||
|
@ -1,4 +1,4 @@
|
||||
.TH LIBPNGPF 3 "February 28, 1998"
|
||||
.TH LIBPNGPF 3 "March 7, 1998"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library
|
||||
(private functions)
|
||||
|
2
png.5
2
png.5
@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "February 28, 1998"
|
||||
.TH PNG 5 "March 7, 1998"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
8
png.c
8
png.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng 0.99e
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -16,7 +16,7 @@
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h.
|
||||
*/
|
||||
char png_libpng_ver[5] = "0.99";
|
||||
char png_libpng_ver[5] = "1.00";
|
||||
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
@ -185,7 +185,7 @@ png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
|
||||
}
|
||||
|
||||
if (need_crc)
|
||||
png_ptr->crc = crc32(png_ptr->crc, ptr, length);
|
||||
png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length);
|
||||
}
|
||||
|
||||
/* Allocate the memory for an info_struct for the application. We don't
|
||||
|
62
png.h
62
png.h
@ -1,12 +1,12 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng 0.99e beta
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see the COPYRIGHT NOTICE below.
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998 Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
*
|
||||
@ -27,27 +27,13 @@
|
||||
* 0.97c 0.97 2.0.97
|
||||
* 0.98 0.98 2.0.98
|
||||
* 0.99 0.99 2.0.99
|
||||
* 0.99a 0.99 2.0.99
|
||||
* 0.99b 0.99 2.0.99
|
||||
* 0.99c 0.99 2.0.99
|
||||
* 0.99e 0.99 2.0.99
|
||||
* 1.0 1.00 2.1.0
|
||||
* 0.99a-i 0.99 2.0.99
|
||||
* 1.00 1.00 2.1.0
|
||||
*
|
||||
* Henceforth the source version will match the shared-library minor
|
||||
* and patch numbers; the shared-library major version number will be
|
||||
* used for changes in backward compatibility, as it is intended.
|
||||
*
|
||||
* BETA NOTICE:
|
||||
* This is a beta version. It reads and writes valid files on the
|
||||
* platforms I have, and has had a wide testing program. You may
|
||||
* have to modify the includes below to get it to work on your
|
||||
* system, and you may have to supply the correct compiler flags in
|
||||
* the makefile if you can't find a makefile suitable for your
|
||||
* operating system/compiler combination. Read libpng.txt for more
|
||||
* information, including how to contact the authors if you have any
|
||||
* problems, or if you want your compiler/platform to be supported in
|
||||
* the next official libpng release.
|
||||
*
|
||||
* See libpng.txt for more information. The PNG specification is available
|
||||
* as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
|
||||
* and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html>
|
||||
@ -126,12 +112,12 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "0.99"
|
||||
#define PNG_LIBPNG_VER_STRING "1.00"
|
||||
|
||||
/* careful here. At one time, I wanted to use 082, but that would be octal.
|
||||
* Version 1.0 will be 100 here, etc.
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 99
|
||||
#define PNG_LIBPNG_VER 100
|
||||
|
||||
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
|
||||
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
|
||||
@ -508,6 +494,8 @@ typedef png_struct FAR * png_structp;
|
||||
typedef void (*png_error_ptr) PNGARG((png_structp, png_const_charp));
|
||||
typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
|
||||
typedef void (*png_flush_ptr) PNGARG((png_structp));
|
||||
typedef void (*png_read_status_ptr) PNGARG((png_structp, png_uint_32, int));
|
||||
typedef void (*png_write_status_ptr) PNGARG((png_structp, png_uint_32, int));
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop));
|
||||
typedef void (*png_progressive_end_ptr) PNGARG((png_structp, png_infop));
|
||||
@ -515,6 +503,12 @@ typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
|
||||
png_uint_32, int));
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
typedef void (*png_user_transform_ptr) PNGARG((png_structp,
|
||||
png_row_infop, png_bytep));
|
||||
#endif /* PNG_READ|WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
|
||||
/* The structure that holds the information to read and write PNG files.
|
||||
* The only people who need to care about what is inside of this are the
|
||||
* people who will be modifying the library for their own special needs.
|
||||
@ -531,9 +525,14 @@ struct png_struct_def
|
||||
png_voidp error_ptr; /* user supplied struct for error functions */
|
||||
png_rw_ptr write_data_fn; /* function for writing output data */
|
||||
png_rw_ptr read_data_fn; /* function for reading input data */
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
png_user_transform_ptr read_user_transform_fn; /* user read transform */
|
||||
png_user_transform_ptr write_user_transform_fn; /* user write transform */
|
||||
#endif
|
||||
png_voidp io_ptr; /* ptr to application struct for I/O functions*/
|
||||
|
||||
png_uint_32 mode; /* tells us whre we are in the PNG file */
|
||||
png_uint_32 mode; /* tells us where we are in the PNG file */
|
||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||
png_uint_32 transformations; /* which transformations to perform */
|
||||
|
||||
@ -620,9 +619,11 @@ struct png_struct_def
|
||||
png_bytep trans; /* transparency values for paletted files */
|
||||
png_color_16 trans_values; /* transparency values for non-paletted files */
|
||||
#endif /* PNG_READ_tRNS_SUPPORTED || PNG_READ_BACKGROUND_SUPPORTED */
|
||||
png_read_status_ptr read_row_fn; /* called after each row is decoded */
|
||||
png_write_status_ptr write_row_fn; /* called after each row is encoded */
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
png_progressive_info_ptr info_fn; /* called after header data fully read */
|
||||
png_progressive_row_ptr row_fn; /* called after each row is decoded */
|
||||
png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */
|
||||
png_progressive_end_ptr end_fn; /* called after image is complete */
|
||||
png_bytep save_buffer_ptr; /* current location in save_buffer */
|
||||
png_bytep save_buffer; /* buffer for previously read data */
|
||||
@ -1096,6 +1097,22 @@ extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
|
||||
/* Return the user pointer associated with the I/O functions */
|
||||
extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
|
||||
|
||||
extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr,
|
||||
png_read_status_ptr read_row_fn));
|
||||
|
||||
extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
|
||||
png_write_status_ptr write_row_fn));
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
|
||||
png_ptr, png_user_transform_ptr read_user_transform_fn));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
|
||||
png_ptr, png_user_transform_ptr write_user_transform_fn));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
/* Sets the function callbacks for the push reader, and a pointer to a
|
||||
* user-defined structure available to the callback functions.
|
||||
@ -1470,6 +1487,7 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
#define PNG_SWAP_ALPHA 0x20000L
|
||||
#define PNG_STRIP_ALPHA 0x40000L
|
||||
#define PNG_INVERT_ALPHA 0x80000L
|
||||
#define PNG_USER_TRANSFORM 0x100000L
|
||||
|
||||
/* flags for png_create_struct */
|
||||
#define PNG_STRUCT_PNG 0x0001
|
||||
|
48
pngconf.h
48
pngconf.h
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng 0.99e
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
@ -236,21 +236,24 @@ __dont__ include it again
|
||||
|
||||
/* Any transformations you will not be using can be undef'ed here */
|
||||
|
||||
/* GR-P, 0.96a: Set "*FULLY_SUPPORTED as default but allow user
|
||||
to turn it off with "*NOT_FULLY_SUPPORTED" on the compile line,
|
||||
/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
|
||||
to turn it off with "*TRANSFORMS_NOT_SUPPORTED" on the compile line,
|
||||
then pick and choose which ones to define without having to edit
|
||||
this file.
|
||||
this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED if you
|
||||
only want to have a png-compliant reader/writer but don't need
|
||||
any of the extra transformations. This saves about 80 kbytes in a
|
||||
typical installation of the library.
|
||||
*/
|
||||
|
||||
#ifndef PNG_READ_NOT_FULLY_SUPPORTED
|
||||
#define PNG_READ_FULLY_SUPPORTED
|
||||
|
||||
#ifndef PNG_READ_TRANSFORMS_NOT_SUPPORTED
|
||||
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_WRITE_NOT_FULLY_SUPPORTED
|
||||
#define PNG_WRITE_FULLY_SUPPORTED
|
||||
#ifndef PNG_WRITE_TRANSFORMS_NOT_SUPPORTED
|
||||
#define PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_FULLY_SUPPORTED
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_SHIFT_SUPPORTED
|
||||
#define PNG_READ_PACK_SUPPORTED
|
||||
@ -267,12 +270,20 @@ __dont__ include it again
|
||||
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel */
|
||||
#endif /* PNG_READ_FULLY_SUPPORTED */
|
||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
/* the following aren't implemented yet
|
||||
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
*/
|
||||
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
|
||||
#ifndef PNG_PROGRESSIVE_READ_NOT_SUPPORTED /* if you don't do progressive */
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
|
||||
#endif /* about interlacing capability! You'll */
|
||||
/* still have interlacing unless you change the following line: */
|
||||
#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel and SGI */
|
||||
|
||||
#ifdef PNG_WRITE_FULLY_SUPPORTED
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||
#define PNG_WRITE_PACK_SUPPORTED
|
||||
#define PNG_WRITE_BGR_SUPPORTED
|
||||
@ -284,10 +295,11 @@ __dont__ include it again
|
||||
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#endif /* PNG_WRITE_FULLY_SUPPORTED */
|
||||
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant */
|
||||
/* encoders, but can cause trouble
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
|
||||
encoders, but can cause trouble
|
||||
if left undefined */
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 0.99e
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file provides a location for all error handling. Users which
|
||||
* need special error handling are expected to write replacement functions
|
||||
|
4
pngget.c
4
pngget.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* libpng 0.99e
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
|
5
pngmem.c
5
pngmem.c
@ -1,11 +1,12 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 0.99e
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file provides a location for all memory allocation. Users which
|
||||
* need special memory handling are expected to modify the code in this file
|
||||
|
11
pngpread.c
11
pngpread.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* libpng 0.99e
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -785,7 +785,10 @@ png_read_push_finish_row(png_structp png_ptr)
|
||||
png_pass_inc[png_ptr->pass] - 1 -
|
||||
png_pass_start[png_ptr->pass]) /
|
||||
png_pass_inc[png_ptr->pass];
|
||||
png_ptr->irowbytes = ((png_ptr->pixel_depth + 7) >> 3) + 1;
|
||||
|
||||
png_ptr->irowbytes = ((png_ptr->iwidth *
|
||||
png_ptr->pixel_depth + 7) >> 3) + 1;
|
||||
|
||||
if (!(png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
png_ptr->num_rows = (png_ptr->height +
|
||||
@ -978,7 +981,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size -
|
||||
(text - key));
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
|
||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||
|
||||
key_size = text - key;
|
||||
text_size = 0;
|
||||
|
13
pngread.c
13
pngread.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 0.99e
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file contains routines that an application calls directly to
|
||||
* read a PNG file or stream.
|
||||
@ -449,6 +449,9 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
png_combine_row(png_ptr, dsp_row, 0xff);
|
||||
}
|
||||
png_read_finish_row(png_ptr);
|
||||
|
||||
if (png_ptr->read_row_fn != NULL)
|
||||
(*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
|
||||
}
|
||||
|
||||
/* Read one or more rows of image data. If the image is interlaced,
|
||||
@ -778,3 +781,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
}
|
||||
|
||||
void
|
||||
png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
||||
{
|
||||
png_ptr->read_row_fn = read_row_fn;
|
||||
}
|
||||
|
4
pngrio.c
4
pngrio.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 0.99e
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file provides a location for all input. Users which need
|
||||
* special handling are expected to write a function which has the same
|
||||
|
33
pngrtran.c
33
pngrtran.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* libpng 0.99e
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file contains functions optionally called by an application
|
||||
* in order to tell libpng how to handle data when reading a PNG.
|
||||
@ -600,6 +600,17 @@ png_set_rgb_to_gray(png_structp png_ptr, int gray_bits)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
void
|
||||
png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
||||
read_user_transform_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_read_user_transform_fn\n");
|
||||
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||
png_ptr->read_user_transform_fn = read_user_transform_fn;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize everything needed for the read. This includes modifying
|
||||
* the palette.
|
||||
*/
|
||||
@ -1078,7 +1089,7 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
png_ptr->gamma_shift);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_RGB_TO_GRAY_SUPPORTED)
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
png_do_rgb_to_gray(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
@ -1149,6 +1160,22 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if(png_ptr->read_user_transform_fn != NULL)
|
||||
(*(png_ptr->read_user_transform_fn)) /* user read transform function */
|
||||
(png_ptr, /* png_ptr */
|
||||
&(png_ptr->row_info), /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_uint_32 rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
/* png_byte bit_depth; bit depth of samples */
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_PACK_SUPPORTED)
|
||||
|
38
pngrutil.c
38
pngrutil.c
@ -6,7 +6,7 @@
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file contains routines which are only called from within
|
||||
* libpng itself during the course of reading an image.
|
||||
@ -1305,7 +1305,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_ptr->zstream.next_in = (png_bytep)text;
|
||||
png_ptr->zstream.avail_in = (uInt)(length - (text - key));
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
|
||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||
|
||||
key_size = (png_size_t)(text - key);
|
||||
text_size = 0;
|
||||
@ -1704,7 +1704,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
case 1:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
int sshift, dshift;
|
||||
png_uint_32 sshift, dshift;
|
||||
int s_start, s_end, s_inc;
|
||||
png_byte v;
|
||||
png_uint_32 i;
|
||||
@ -1715,8 +1715,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (transformations & PNG_PACKSWAP)
|
||||
{
|
||||
sshift = (int)((row_info->width + 7) & 7);
|
||||
dshift = (int)((final_width + 7) & 7);
|
||||
sshift = (png_uint_32)((row_info->width + 7) & 7);
|
||||
dshift = (png_uint_32)((final_width + 7) & 7);
|
||||
s_start = 7;
|
||||
s_end = 0;
|
||||
s_inc = -1;
|
||||
@ -1724,8 +1724,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sshift = 7 - (int)((row_info->width + 7) & 7);
|
||||
dshift = 7 - (int)((final_width + 7) & 7);
|
||||
sshift = 7 - (png_uint_32)((row_info->width + 7) & 7);
|
||||
dshift = 7 - (png_uint_32)((final_width + 7) & 7);
|
||||
s_start = 0;
|
||||
s_end = 7;
|
||||
s_inc = 1;
|
||||
@ -1759,17 +1759,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
case 2:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
int sshift, dshift;
|
||||
png_uint_32 sshift, dshift;
|
||||
int s_start, s_end, s_inc;
|
||||
png_uint_32 i;
|
||||
|
||||
sp = row + (png_size_t)((row_info->width - 1) >> 2);
|
||||
dp = row + (png_size_t)((final_width - 1) >> 2);
|
||||
sp = row + (png_uint_32)((row_info->width - 1) >> 2);
|
||||
dp = row + (png_uint_32)((final_width - 1) >> 2);
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (transformations & PNG_PACKSWAP)
|
||||
{
|
||||
sshift = (png_size_t)(((row_info->width + 3) & 3) << 1);
|
||||
dshift = (png_size_t)(((final_width + 3) & 3) << 1);
|
||||
sshift = (png_uint_32)(((row_info->width + 3) & 3) << 1);
|
||||
dshift = (png_uint_32)(((final_width + 3) & 3) << 1);
|
||||
s_start = 6;
|
||||
s_end = 0;
|
||||
s_inc = -2;
|
||||
@ -1777,8 +1777,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1);
|
||||
dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1);
|
||||
sshift = (png_uint_32)((3 - ((row_info->width + 3) & 3)) << 1);
|
||||
dshift = (png_uint_32)((3 - ((final_width + 3) & 3)) << 1);
|
||||
s_start = 0;
|
||||
s_end = 6;
|
||||
s_inc = 2;
|
||||
@ -1815,7 +1815,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
case 4:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
int sshift, dshift;
|
||||
png_uint_32 sshift, dshift;
|
||||
int s_start, s_end, s_inc;
|
||||
png_uint_32 i;
|
||||
|
||||
@ -1824,8 +1824,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (transformations & PNG_PACKSWAP)
|
||||
{
|
||||
sshift = (png_size_t)(((row_info->width + 1) & 1) << 2);
|
||||
dshift = (png_size_t)(((final_width + 1) & 1) << 2);
|
||||
sshift = (png_uint_32)(((row_info->width + 1) & 1) << 2);
|
||||
dshift = (png_uint_32)(((final_width + 1) & 1) << 2);
|
||||
s_start = 4;
|
||||
s_end = 0;
|
||||
s_inc = -4;
|
||||
@ -1833,8 +1833,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2);
|
||||
dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2);
|
||||
sshift = (png_uint_32)((1 - ((row_info->width + 1) & 1)) << 2);
|
||||
dshift = (png_uint_32)((1 - ((final_width + 1) & 1)) << 2);
|
||||
s_start = 0;
|
||||
s_end = 4;
|
||||
s_inc = 4;
|
||||
|
4
pngset.c
4
pngset.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* libpng 0.99e
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*
|
||||
* The functions here are used during reads to store data from the file
|
||||
* into the info struct, and during writes to store application data
|
||||
|
169
pngtest.c
169
pngtest.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* libpng 0.99e
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* February 28, 1998
|
||||
* March 7, 1998
|
||||
*
|
||||
* This program reads in a PNG image, writes it out again, and then
|
||||
* compares the two files. If the files are identical, this shows that
|
||||
@ -32,8 +32,8 @@
|
||||
|
||||
/* Makes pngtest verbose so we can find problems (needs to be before png.h) */
|
||||
#ifndef PNG_DEBUG
|
||||
#define PNG_DEBUG 0
|
||||
#endif
|
||||
#define PNG_DEBUG 0
|
||||
|
||||
#include "png.h"
|
||||
|
||||
@ -47,6 +47,126 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname);
|
||||
/* #define STDERR stderr */
|
||||
#define STDERR stdout /* for DOS */
|
||||
|
||||
/* example of using row callbacks to make a simple progress meter */
|
||||
static int status_pass=1;
|
||||
static int status_dots_requested=0;
|
||||
static int status_dots=1;
|
||||
void read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
|
||||
void read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
{
|
||||
if(png_ptr == NULL || row_number > 0x3fffffff) return;
|
||||
if(status_pass != pass)
|
||||
{
|
||||
fprintf(stdout,"\n Pass %d: ",pass);
|
||||
status_pass = pass;
|
||||