Imported from libpng-0.99i.tar

This commit is contained in:
Glenn Randers-Pehrson 1998-03-07 06:06:55 -06:00
parent cbe52d8720
commit 08a3343e05
48 changed files with 1232 additions and 174 deletions

20
CHANGES
View File

@ -1,4 +1,4 @@
pngchange.txt - changes for libpng CHANGES - changes for libpng
version 0.2 version 0.2
added reader into png.h 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 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.) 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) 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
View 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
View File

@ -1,8 +1,7 @@
[NOTE: this is still beta version 0.99e; the text below has already README for libpng 1.00 (shared library 2.1)
been updated in anticipation of the imminent 1.0 release.] See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
README for libpng 1.0
This is the first official release of libpng. Don't let the fact that 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 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. to others, if necessary.
Please do not send suggestions on how to change PNG. We have 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 finished. If you have suggestions for libpng, however, I'll
gladly listen. Even if your suggestion is not used for version gladly listen. Even if your suggestion is not used for version
1.0, it may be used later. 1.0, it may be used later.
@ -135,21 +134,6 @@ Files in this distribution:
libpng.3 => manual page for libpng libpng.3 => manual page for libpng
libpng.txt => Description of libpng and its functions libpng.txt => Description of libpng and its functions
libpngpf.3 => manual page for libpng's private 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.5 => manual page for the PNG format
png.c => Basic interface functions common to library png.c => Basic interface functions common to library
png.h => Library function and interface declarations png.h => Library function and interface declarations
@ -170,6 +154,28 @@ Files in this distribution:
pngwrite.c => High-level write functions pngwrite.c => High-level write functions
pngwtran.c => Write data transformations pngwtran.c => Write data transformations
pngwutil.c => Write utility functions 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. Good luck, and happy coding.

2
TODO
View File

@ -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 add "grayscale->palette" transformation and "palette->grayscale" detection
improved dithering improved dithering

View File

@ -1,3 +1,4 @@
/* example.c - an example of using libpng */ /* example.c - an example of using libpng */
/* This is an example of how to use libpng to read and write PNG files. /* This is an example of how to use libpng to read and write PNG files.

132
libpng.3
View File

@ -1,4 +1,4 @@
.TH LIBPNG 3 "February 28, 1998" .TH LIBPNG 3 "March 7, 1998"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library libpng \- Portable Network Graphics (PNG) Reference Library
.SH SYNOPSIS .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, void png_set_read_fn (png_structp png_ptr, png_voidp io_ptr,
png_rw_ptr read_data_fn); 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_rgb_to_gray (png_structp png_ptr);
void png_set_sBIT (png_structp png_ptr, png_infop info_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, 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); 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 int png_sig_cmp (png_bytep sig, png_size_t start, png_size_t
num_to_check); num_to_check);
@ -384,23 +396,23 @@ Following is a copy of the libpng.txt file that accompanies libpng.
.SH LIBPNG.TXT .SH LIBPNG.TXT
libpng.txt - A description on how to use and modify libpng 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 Updated and distributed by Glenn Randers-Pehrson
<randeg@alumni.rpi.edu> <randeg@alumni.rpi.edu>
Copyright (c) 1998, Glenn Randers-Pehrson Copyright (c) 1998, Glenn Randers-Pehrson
February 28, 1998 For conditions of distribution and use, see copyright
notice in png.h.
based on: 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 Updated and distributed by Andreas Dilger
Copyright (c) 1996, 1997 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 For conditions of distribution and use, see copyright
notice in png.h. Copyright (c) 1995, 1996 Guy Eric 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 Updated/rewritten per request in the libpng FAQ
Copyright (c) 1995 Frank J. T. Wojcik 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 configuration notes for various special platforms. In addition to this
file, example.c is a good starting point for using the library, as file, example.c is a good starting point for using the library, as
it is heavily commented and should include everything most people 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 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 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); 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. 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 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 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 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. 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 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(). 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. which depends on the lighting conditions in the surrounding environment.
Screen_gamma is display_gamma/viewing_gamma, where viewing_gamma is Screen_gamma is display_gamma/viewing_gamma, where viewing_gamma is
the amount of additional gamma correction needed to compensate for the amount of additional gamma correction needed to compensate for
a dark (viewing_gamma=1.25) environment. a (viewing_gamma=1.25) environment. In a dim or brightly lit room, no
In a dim or brightly lit room, no compensation other than the display_gamma compensation other than the display_gamma is needed (viewing_gamma=1.0).
is needed (viewing_gamma=1.0).
if (/* We have a user-defined screen if (/* We have a user-defined screen
gamma value */) gamma value */)
@ -1299,6 +1342,7 @@ png_infop info_ptr;
read. read.
*/ */
void void
info_callback(png_structp png_ptr, png_infop info)
{ {
/* Do any setup here, including setting any of /* Do any setup here, including setting any of
the transformations mentioned in the Reading the transformations mentioned in the Reading
@ -1368,8 +1412,6 @@ png_infop info_ptr;
*/ */
} }
.SH IV. Writing .SH IV. Writing
Much of this is very similar to reading. However, everything of 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. 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 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 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_structp png_ptr = png_create_write_struct
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr, (PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
@ -1433,6 +1478,22 @@ Libpng section below.
png_init_io(png_ptr, fp); 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 You now have the option of modifying how the compression library will
run. The following functions are mainly for testing, but may be useful 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 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); 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, It is possible to have libpng flush any pending output, either manually,
or automatically after a certain number of lines have been written. To or automatically after a certain number of lines have been written. To
flush the output stream a single time call: 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 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 never going to use an ability, you can change the #define to #undef
before recompiling libpng and save yourself code and data space. before recompiling libpng and save yourself code and data space.
You can also turn them off en masse with a compiler directive that You can also turn a number of them off en masse with a compiler directive
defines PNG_READ[or WRITE]_NOT_FULLY_SUPPORTED, or that defines PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED, or
PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four, PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four,
along with directives to turn on any of the capabilities that you do along with directives to turn on any of the capabilities that you do
want. The NOT_FULLY_SUPPORTED directives disable the extra want. The PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED directives disable
transformations but still leave the library fully capable of reading the extra transformations but still leave the library fully capable of reading
and writing PNG files with all known public chunks [except for sPLT]. and writing PNG files with all known public chunks [except for sPLT].
Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive
produces a library that is incapable of reading or writing ancillary chunks. 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 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 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.97c 0.97 2.0.97
0.98 0.98 2.0.98 0.98 0.98 2.0.98
0.99 0.99 2.0.99 0.99 0.99 2.0.99
0.99a 0.99 2.0.99 0.99a-g 0.99 2.0.99
0.99b 0.99 2.0.99
0.99e 0.99 2.0.99
1.0 1.00 2.1.0 1.0 1.00 2.1.0
Henceforth the source version will match the shared-library minor 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. 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. Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (randeg@alumni.rpi.edu). Currently maintained by Glenn Randers-Pehrson (randeg@alumni.rpi.edu).
@ -2296,17 +2373,6 @@ Supported by the PNG development group
.br .br
(png-implement@dworkin.wustl.edu). (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: .SH COPYRIGHT NOTICE:
The PNG Reference Library (libpng) is supplied "AS IS". The Contributing The PNG Reference Library (libpng) is supplied "AS IS". The Contributing

View File

@ -1,22 +1,22 @@
libpng.txt - A description on how to use and modify libpng 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 Updated and distributed by Glenn Randers-Pehrson
<randeg@alumni.rpi.edu> <randeg@alumni.rpi.edu>
Copyright (c) 1998, Glenn Randers-Pehrson Copyright (c) 1998, Glenn Randers-Pehrson
February 28, 1998 For conditions of distribution and use, see copyright
notice in png.h.
based on: 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 Updated and distributed by Andreas Dilger
Copyright (c) 1996, 1997 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 For conditions of distribution and use, see copyright
notice in png.h. Copyright (c) 1995, 1996 Guy Eric 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 Updated/rewritten per request in the libpng FAQ
Copyright (c) 1995 Frank J. T. Wojcik 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 configuration notes for various special platforms. In addition to this
file, example.c is a good starting point for using the library, as file, example.c is a good starting point for using the library, as
it is heavily commented and should include everything most people 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 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 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); 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. 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 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 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 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. 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 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(). image data. You do this with a call to png_read_info().
@ -914,6 +946,7 @@ png_infop info_ptr;
read. read.
*/ */
void void
info_callback(png_structp png_ptr, png_infop info)
{ {
/* Do any setup here, including setting any of /* Do any setup here, including setting any of
the transformations mentioned in the Reading 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. 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 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 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_structp png_ptr = png_create_write_struct
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr, (PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
@ -1048,6 +1084,22 @@ Libpng section below.
png_init_io(png_ptr, fp); 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 You now have the option of modifying how the compression library will
run. The following functions are mainly for testing, but may be useful 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 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); 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, It is possible to have libpng flush any pending output, either manually,
or automatically after a certain number of lines have been written. To or automatically after a certain number of lines have been written. To
flush the output stream a single time call: 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 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 never going to use an ability, you can change the #define to #undef
before recompiling libpng and save yourself code and data space. before recompiling libpng and save yourself code and data space.
You can also turn them off en masse with a compiler directive that You can also turn a number of them off en masse with a compiler directive
defines PNG_READ[or WRITE]_NOT_FULLY_SUPPORTED, or that defines PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED, or
PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four, PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four,
along with directives to turn on any of the capabilities that you do along with directives to turn on any of the capabilities that you do
want. The NOT_FULLY_SUPPORTED directives disable the extra want. The PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED directives disable
transformations but still leave the library fully capable of reading the extra transformations but still leave the library fully capable of reading
and writing PNG files with all known public chunks [except for sPLT]. and writing PNG files with all known public chunks [except for sPLT].
Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive
produces a library that is incapable of reading or writing ancillary chunks. 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 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 linker should only grab the files it needs. However, if you want to

View File

@ -1,4 +1,4 @@
.TH LIBPNGPF 3 "February 28, 1998" .TH LIBPNGPF 3 "March 7, 1998"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library libpng \- Portable Network Graphics (PNG) Reference Library
(private functions) (private functions)

2
png.5
View File

@ -1,4 +1,4 @@
.TH PNG 5 "February 28, 1998" .TH PNG 5 "March 7, 1998"
.SH NAME .SH NAME
png \- Portable Network Graphics (PNG) format png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION .SH DESCRIPTION

8
png.c
View File

@ -1,12 +1,12 @@
/* png.c - location for general purpose libpng functions /* 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 * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@ -16,7 +16,7 @@
/* Version information for C files. This had better match the version /* Version information for C files. This had better match the version
* string defined in png.h. * 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. */ /* Place to hold the signature string for a PNG file. */
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; 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) 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 /* Allocate the memory for an info_struct for the application. We don't

62
png.h
View File

@ -1,12 +1,12 @@
/* png.h - header file for PNG reference library /* 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. * For conditions of distribution and use, see the COPYRIGHT NOTICE below.
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998 Glenn Randers-Pehrson * Copyright (c) 1998 Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
* *
* Note about libpng version numbers: * Note about libpng version numbers:
* *
@ -27,27 +27,13 @@
* 0.97c 0.97 2.0.97 * 0.97c 0.97 2.0.97
* 0.98 0.98 2.0.98 * 0.98 0.98 2.0.98
* 0.99 0.99 2.0.99 * 0.99 0.99 2.0.99
* 0.99a 0.99 2.0.99 * 0.99a-i 0.99 2.0.99
* 0.99b 0.99 2.0.99 * 1.00 1.00 2.1.0
* 0.99c 0.99 2.0.99
* 0.99e 0.99 2.0.99
* 1.0 1.00 2.1.0
* *
* Henceforth the source version will match the shared-library minor * Henceforth the source version will match the shared-library minor
* and patch numbers; the shared-library major version number will be * and patch numbers; the shared-library major version number will be
* used for changes in backward compatibility, as it is intended. * 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 * See libpng.txt for more information. The PNG specification is available
* as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> * as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
* and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html> * 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 */ /* 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. /* careful here. At one time, I wanted to use 082, but that would be octal.
* Version 1.0 will be 100 here, etc. * 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 */ /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_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_error_ptr) PNGARG((png_structp, png_const_charp));
typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
typedef void (*png_flush_ptr) PNGARG((png_structp)); 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 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop)); typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop));
typedef void (*png_progressive_end_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)); png_uint_32, int));
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ #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 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 * 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. * 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_voidp error_ptr; /* user supplied struct for error functions */
png_rw_ptr write_data_fn; /* function for writing output data */ png_rw_ptr write_data_fn; /* function for writing output data */
png_rw_ptr read_data_fn; /* function for reading input 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_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 flags; /* flags indicating various things to libpng */
png_uint_32 transformations; /* which transformations to perform */ 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_bytep trans; /* transparency values for paletted files */
png_color_16 trans_values; /* transparency values for non-paletted files */ png_color_16 trans_values; /* transparency values for non-paletted files */
#endif /* PNG_READ_tRNS_SUPPORTED || PNG_READ_BACKGROUND_SUPPORTED */ #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 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
png_progressive_info_ptr info_fn; /* called after header data fully read */ 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_progressive_end_ptr end_fn; /* called after image is complete */
png_bytep save_buffer_ptr; /* current location in save_buffer */ png_bytep save_buffer_ptr; /* current location in save_buffer */
png_bytep save_buffer; /* buffer for previously read data */ 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 */ /* 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(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 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
/* Sets the function callbacks for the push reader, and a pointer to a /* Sets the function callbacks for the push reader, and a pointer to a
* user-defined structure available to the callback functions. * 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_SWAP_ALPHA 0x20000L
#define PNG_STRIP_ALPHA 0x40000L #define PNG_STRIP_ALPHA 0x40000L
#define PNG_INVERT_ALPHA 0x80000L #define PNG_INVERT_ALPHA 0x80000L
#define PNG_USER_TRANSFORM 0x100000L
/* flags for png_create_struct */ /* flags for png_create_struct */
#define PNG_STRUCT_PNG 0x0001 #define PNG_STRUCT_PNG 0x0001

View File

@ -1,12 +1,12 @@
/* pngconf.h - machine configurable file for libpng /* 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 * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * 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 /* 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 */ /* Any transformations you will not be using can be undef'ed here */
/* GR-P, 0.96a: Set "*FULLY_SUPPORTED as default but allow user /* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
to turn it off with "*NOT_FULLY_SUPPORTED" on the compile line, to turn it off with "*TRANSFORMS_NOT_SUPPORTED" on the compile line,
then pick and choose which ones to define without having to edit 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 #endif
#ifndef PNG_WRITE_NOT_FULLY_SUPPORTED #ifndef PNG_WRITE_TRANSFORMS_NOT_SUPPORTED
#define PNG_WRITE_FULLY_SUPPORTED #define PNG_WRITE_TRANSFORMS_SUPPORTED
#endif #endif
#ifdef PNG_READ_FULLY_SUPPORTED #ifdef PNG_READ_TRANSFORMS_SUPPORTED
#define PNG_PROGRESSIVE_READ_SUPPORTED
#define PNG_READ_EXPAND_SUPPORTED #define PNG_READ_EXPAND_SUPPORTED
#define PNG_READ_SHIFT_SUPPORTED #define PNG_READ_SHIFT_SUPPORTED
#define PNG_READ_PACK_SUPPORTED #define PNG_READ_PACK_SUPPORTED
@ -267,12 +270,20 @@ __dont__ include it again
#define PNG_READ_SWAP_ALPHA_SUPPORTED #define PNG_READ_SWAP_ALPHA_SUPPORTED
#define PNG_READ_INVERT_ALPHA_SUPPORTED #define PNG_READ_INVERT_ALPHA_SUPPORTED
#define PNG_READ_STRIP_ALPHA_SUPPORTED #define PNG_READ_STRIP_ALPHA_SUPPORTED
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel */ #define PNG_READ_USER_TRANSFORM_SUPPORTED
#endif /* PNG_READ_FULLY_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_SHIFT_SUPPORTED
#define PNG_WRITE_PACK_SUPPORTED #define PNG_WRITE_PACK_SUPPORTED
#define PNG_WRITE_BGR_SUPPORTED #define PNG_WRITE_BGR_SUPPORTED
@ -284,10 +295,11 @@ __dont__ include it again
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED #define PNG_WRITE_SWAP_ALPHA_SUPPORTED
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED #define PNG_WRITE_INVERT_ALPHA_SUPPORTED
#define PNG_WRITE_WEIGHTED_FILTER_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 */ #define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
/* encoders, but can cause trouble encoders, but can cause trouble
if left undefined */ if left undefined */
#if !defined(PNG_NO_STDIO) #if !defined(PNG_NO_STDIO)

View File

@ -1,12 +1,12 @@
/* pngerror.c - stub functions for i/o and memory allocation /* 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 * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
* *
* This file provides a location for all error handling. Users which * This file provides a location for all error handling. Users which
* need special error handling are expected to write replacement functions * need special error handling are expected to write replacement functions

View File

@ -1,12 +1,12 @@
/* pngget.c - retrieval of values from info struct /* 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 * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL

View File

@ -1,11 +1,12 @@
/* pngmem.c - stub functions for memory allocation /* 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 * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
* *
* This file provides a location for all memory allocation. Users which * This file provides a location for all memory allocation. Users which
* need special memory handling are expected to modify the code in this file * need special memory handling are expected to modify the code in this file

View File

@ -1,12 +1,12 @@
/* pngpread.c - read a png file in push mode /* 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 * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
*/ */
#define PNG_INTERNAL #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_inc[png_ptr->pass] - 1 -
png_pass_start[png_ptr->pass]) / png_pass_start[png_ptr->pass]) /
png_pass_inc[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)) if (!(png_ptr->transformations & PNG_INTERLACE))
{ {
png_ptr->num_rows = (png_ptr->height + 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 - png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size -
(text - key)); (text - key));
png_ptr->zstream.next_out = png_ptr->zbuf; 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; key_size = text - key;
text_size = 0; text_size = 0;

View File

@ -1,12 +1,12 @@
/* pngread.c - read a PNG file /* pngread.c - read a PNG file
* *
* libpng 0.99e * libpng 1.00
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
* *
* This file contains routines that an application calls directly to * This file contains routines that an application calls directly to
* read a PNG file or stream. * 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_combine_row(png_ptr, dsp_row, 0xff);
} }
png_read_finish_row(png_ptr); 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, /* 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)); 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;
}

View File

@ -1,12 +1,12 @@
/* pngrio.c - functions for data input /* pngrio.c - functions for data input
* *
* libpng 0.99e * libpng 1.00
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
* *
* This file provides a location for all input. Users which need * This file provides a location for all input. Users which need
* special handling are expected to write a function which has the same * special handling are expected to write a function which has the same

View File

@ -1,12 +1,12 @@
/* pngrtran.c - transforms the data in a row for PNG readers /* 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 * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
* *
* This file contains functions optionally called by an application * This file contains functions optionally called by an application
* in order to tell libpng how to handle data when reading a PNG. * 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 #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 /* Initialize everything needed for the read. This includes modifying
* the palette. * the palette.
*/ */
@ -1078,7 +1089,7 @@ png_do_read_transformations(png_structp png_ptr)
png_ptr->gamma_shift); png_ptr->gamma_shift);
#endif #endif
#if defined(PNG_RGB_TO_GRAY_SUPPORTED) #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & PNG_RGB_TO_GRAY) if (png_ptr->transformations & PNG_RGB_TO_GRAY)
png_do_rgb_to_gray(&(png_ptr->row_info), png_ptr->row_buf + 1); png_do_rgb_to_gray(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif #endif
@ -1149,6 +1160,22 @@ png_do_read_transformations(png_structp png_ptr)
if (png_ptr->transformations & PNG_SWAP_BYTES) if (png_ptr->transformations & PNG_SWAP_BYTES)
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif #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) #if defined(PNG_READ_PACK_SUPPORTED)

View File

@ -6,7 +6,7 @@
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
* *
* This file contains routines which are only called from within * This file contains routines which are only called from within
* libpng itself during the course of reading an image. * 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.next_in = (png_bytep)text;
png_ptr->zstream.avail_in = (uInt)(length - (text - key)); png_ptr->zstream.avail_in = (uInt)(length - (text - key));
png_ptr->zstream.next_out = png_ptr->zbuf; 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); key_size = (png_size_t)(text - key);
text_size = 0; text_size = 0;
@ -1704,7 +1704,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
case 1: case 1:
{ {
png_bytep sp, dp; png_bytep sp, dp;
int sshift, dshift; png_uint_32 sshift, dshift;
int s_start, s_end, s_inc; int s_start, s_end, s_inc;
png_byte v; png_byte v;
png_uint_32 i; 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 defined(PNG_READ_PACKSWAP_SUPPORTED)
if (transformations & PNG_PACKSWAP) if (transformations & PNG_PACKSWAP)
{ {
sshift = (int)((row_info->width + 7) & 7); sshift = (png_uint_32)((row_info->width + 7) & 7);
dshift = (int)((final_width + 7) & 7); dshift = (png_uint_32)((final_width + 7) & 7);
s_start = 7; s_start = 7;
s_end = 0; s_end = 0;
s_inc = -1; s_inc = -1;
@ -1724,8 +1724,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
else else
#endif #endif
{ {
sshift = 7 - (int)((row_info->width + 7) & 7); sshift = 7 - (png_uint_32)((row_info->width + 7) & 7);
dshift = 7 - (int)((final_width + 7) & 7); dshift = 7 - (png_uint_32)((final_width + 7) & 7);
s_start = 0; s_start = 0;
s_end = 7; s_end = 7;
s_inc = 1; s_inc = 1;
@ -1759,17 +1759,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
case 2: case 2:
{ {
png_bytep sp, dp; png_bytep sp, dp;
int sshift, dshift; png_uint_32 sshift, dshift;
int s_start, s_end, s_inc; int s_start, s_end, s_inc;
png_uint_32 i; png_uint_32 i;
sp = row + (png_size_t)((row_info->width - 1) >> 2); sp = row + (png_uint_32)((row_info->width - 1) >> 2);
dp = row + (png_size_t)((final_width - 1) >> 2); dp = row + (png_uint_32)((final_width - 1) >> 2);
#if defined(PNG_READ_PACKSWAP_SUPPORTED) #if defined(PNG_READ_PACKSWAP_SUPPORTED)
if (transformations & PNG_PACKSWAP) if (transformations & PNG_PACKSWAP)
{ {
sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); sshift = (png_uint_32)(((row_info->width + 3) & 3) << 1);
dshift = (png_size_t)(((final_width + 3) & 3) << 1); dshift = (png_uint_32)(((final_width + 3) & 3) << 1);
s_start = 6; s_start = 6;
s_end = 0; s_end = 0;
s_inc = -2; s_inc = -2;
@ -1777,8 +1777,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
else else
#endif #endif
{ {
sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); sshift = (png_uint_32)((3 - ((row_info->width + 3) & 3)) << 1);
dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); dshift = (png_uint_32)((3 - ((final_width + 3) & 3)) << 1);
s_start = 0; s_start = 0;
s_end = 6; s_end = 6;
s_inc = 2; s_inc = 2;
@ -1815,7 +1815,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
case 4: case 4:
{ {
png_bytep sp, dp; png_bytep sp, dp;
int sshift, dshift; png_uint_32 sshift, dshift;
int s_start, s_end, s_inc; int s_start, s_end, s_inc;
png_uint_32 i; 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 defined(PNG_READ_PACKSWAP_SUPPORTED)
if (transformations & PNG_PACKSWAP) if (transformations & PNG_PACKSWAP)
{ {
sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); sshift = (png_uint_32)(((row_info->width + 1) & 1) << 2);
dshift = (png_size_t)(((final_width + 1) & 1) << 2); dshift = (png_uint_32)(((final_width + 1) & 1) << 2);
s_start = 4; s_start = 4;
s_end = 0; s_end = 0;
s_inc = -4; s_inc = -4;
@ -1833,8 +1833,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
else else
#endif #endif
{ {
sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); sshift = (png_uint_32)((1 - ((row_info->width + 1) & 1)) << 2);
dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); dshift = (png_uint_32)((1 - ((final_width + 1) & 1)) << 2);
s_start = 0; s_start = 0;
s_end = 4; s_end = 4;
s_inc = 4; s_inc = 4;

View File

@ -1,12 +1,12 @@
/* pngset.c - storage of image information into info struct /* 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 * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * 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 * The functions here are used during reads to store data from the file
* into the info struct, and during writes to store application data * into the info struct, and during writes to store application data

169
pngtest.c
View File

@ -1,12 +1,12 @@
/* pngtest.c - a simple test program to test libpng /* 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 * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * 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 * 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 * 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) */ /* Makes pngtest verbose so we can find problems (needs to be before png.h) */
#ifndef PNG_DEBUG #ifndef PNG_DEBUG
#define PNG_DEBUG 0
#endif #endif
#define PNG_DEBUG 0
#include "png.h" #include "png.h"
@ -47,6 +47,126 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname);
/* #define STDERR stderr */ /* #define STDERR stderr */
#define STDERR stdout /* for DOS */ #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;
status_dots = 30;
}
status_dots--;
if(status_dots == 0)
{
fprintf(stdout, "\n ");
status_dots=30;
}
fprintf(stdout, "r");
}
void write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
void write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
{
if(png_ptr == NULL || row_number > 0x3fffffff || pass > 7) return;
fprintf(stdout, "w");
}
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
/* example of using user transform callback (we don't transform anything,
but merely count the black pixels) */
static png_uint_32 black_pixels;
void count_black_pixels(png_structp png_ptr, png_row_infop row_info,
png_bytep data);
void count_black_pixels(png_structp png_ptr, png_row_infop row_info,
png_bytep data)
{
png_bytep dp = data;
if(png_ptr == NULL)return;
/* contents of 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)
*/
/* counts the number of black pixels (or zero pixels if color_type is 3 */
if(row_info->color_type == 0 || row_info->color_type == 3)
{
int pos=0;
png_uint_32 n;
for (n=0; n<(int)row_info->width; n++)
{
if(row_info->bit_depth == 1)
if(((*dp << pos++ )& 0x80) == 0) black_pixels++;
if(pos == 8)
{
pos=0;
dp++;
}
if(row_info->bit_depth == 2)
if(((*dp << (pos+=2))& 0xc0) == 0) black_pixels++;
if(pos == 8)
{
pos=0;
dp++;
}
if(row_info->bit_depth == 4)
if(((*dp << (pos+=4))& 0xf0) == 0) black_pixels++;
if(pos == 8)
{
pos=0;
dp++;
}
if(row_info->bit_depth == 8)
if(*dp++ == 0) black_pixels++;
if(row_info->bit_depth == 16)
{
if((*dp | *(dp+1)) == 0) black_pixels++;
dp+=2;
}
}
}
else /* other color types */
{
png_uint_32 n;
int channel;
int color_channels = row_info->channels;
if(row_info->color_type > 3)color_channels--;
for (n=0; n<row_info->width; n++)
{
for (channel = 0; channel < color_channels; channel++)
{
if(row_info->bit_depth == 8)
if(*dp++ == 0) black_pixels++;
if(row_info->bit_depth == 16)
{
if((*dp | *(dp+1)) == 0) black_pixels++;
dp+=2;
}
}
if(row_info->color_type > 3)
{
dp++;
if(row_info->bit_depth == 16)dp++;
}
}
}
}
#endif /* PNG_READ|WRITE_USER_TRANSFORM_SUPPORTED */
static int verbose = 0; static int verbose = 0;
static int wrote_question = 0; static int wrote_question = 0;
@ -439,6 +559,22 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#else #else
NULL); NULL);
#endif #endif
#endif
if(status_dots_requested == 1)
{
png_set_write_status_fn(write_ptr, write_row_callback);
png_set_read_status_fn(read_ptr, read_row_callback);
}
else
{
png_set_write_status_fn(write_ptr, NULL);
png_set_read_status_fn(read_ptr, NULL);
}
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
black_pixels=0;
png_set_write_user_transform_fn(write_ptr, count_black_pixels);
#endif #endif
png_debug(0, "Reading info struct\n"); png_debug(0, "Reading info struct\n");
@ -730,8 +866,8 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
/* input and output filenames */ /* input and output filenames */
#ifdef RISCOS #ifdef RISCOS
PNG_CONST char *inname = "pngtest_png"; PNG_CONST char *inname = "pngtest/png";
PNG_CONST char *outname = "pngout_png"; PNG_CONST char *outname = "pngout/png";
#else #else
static char *inname = "pngtest.png"; static char *inname = "pngtest.png";
static char *outname = "pngout.png"; static char *outname = "pngout.png";
@ -770,20 +906,28 @@ main(int argc, char *argv[])
if (argc > 1) if (argc > 1)
{ {
if (strcmp(argv[1], "-m") == 0) if (strcmp(argv[1], "-m") == 0)
{
multiple = 1; multiple = 1;
status_dots_requested = 0;
}
else if (strcmp(argv[1], "-mv") == 0 || else if (strcmp(argv[1], "-mv") == 0 ||
strcmp(argv[1], "-vm") == 0 ) strcmp(argv[1], "-vm") == 0 )
{ {
multiple = 1; multiple = 1;
verbose = 1; verbose = 1;
status_dots_requested = 1;
} }
else if (strcmp(argv[1], "-v") == 0) else if (strcmp(argv[1], "-v") == 0)
{ {
verbose = 1; verbose = 1;
status_dots_requested = 1;
inname = argv[2]; inname = argv[2];
} }
else else
{
inname = argv[1]; inname = argv[1];
status_dots_requested = 0;
}
} }
if (!multiple && argc == 3+verbose) if (!multiple && argc == 3+verbose)
@ -813,7 +957,12 @@ main(int argc, char *argv[])
fprintf(STDERR, "Testing %s:",argv[i]); fprintf(STDERR, "Testing %s:",argv[i]);
kerror = test_one_file(argv[i], outname); kerror = test_one_file(argv[i], outname);
if (kerror == 0) if (kerror == 0)
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
fprintf(STDERR, " PASS (%lu black pixels)\n",black_pixels);
#else
fprintf(STDERR, " PASS\n"); fprintf(STDERR, " PASS\n");
#endif
else { else {
fprintf(STDERR, " FAIL\n"); fprintf(STDERR, " FAIL\n");
ierror += kerror; ierror += kerror;
@ -847,12 +996,20 @@ main(int argc, char *argv[])
#ifdef PNGTEST_MEMORY_DEBUG #ifdef PNGTEST_MEMORY_DEBUG
int allocation_now = current_allocation; int allocation_now = current_allocation;
#endif #endif
if (i == 1) status_dots_requested = 1;
else if(verbose == 0)status_dots_requested = 0;
if (i == 0 || verbose == 1 || ierror != 0) if (i == 0 || verbose == 1 || ierror != 0)
fprintf(STDERR, "Testing %s:",inname); fprintf(STDERR, "Testing %s:",inname);
kerror = test_one_file(inname, outname); kerror = test_one_file(inname, outname);
if(kerror == 0) if(kerror == 0)
{ {
if(verbose == 1 || i == 2) fprintf(STDERR, " PASS\n"); if(verbose == 1 || i == 2)
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
fprintf(STDERR, " PASS (%lu black pixels)\n",black_pixels);
#else
fprintf(STDERR, " PASS\n");
#endif
} }
else else
{ {

View File

@ -1,12 +1,12 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers) /* pngtrans.c - transforms the data in a row (used by both readers and writers)
* *
* libpng 0.99e * libpng 1.00
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL

View File

@ -1,12 +1,12 @@
/* pngwio.c - functions for data output /* pngwio.c - functions for data output
* *
* libpng 0.99e * libpng 1.00
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
* *
* This file provides a location for all output. Users which need * This file provides a location for all output. Users which need
* special handling are expected to write functions which have the same * special handling are expected to write functions which have the same

View File

@ -1,12 +1,12 @@
/* pngwrite.c - general routines to write a PNG file /* pngwrite.c - general routines to write a PNG file
* *
* libpng 0.99e * libpng 1.00
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
*/ */
/* get internal access to png.h */ /* get internal access to png.h */
@ -527,6 +527,9 @@ png_write_row(png_structp png_ptr, png_bytep row)
/* Find a filter if necessary, filter the row and write it out. */ /* Find a filter if necessary, filter the row and write it out. */
png_write_find_filter(png_ptr, &(png_ptr->row_info)); png_write_find_filter(png_ptr, &(png_ptr->row_info));
if (png_ptr->write_row_fn != NULL)
(*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
} }
#if defined(PNG_WRITE_FLUSH_SUPPORTED) #if defined(PNG_WRITE_FLUSH_SUPPORTED)
@ -947,3 +950,20 @@ png_set_compression_method(png_structp png_ptr, int method)
png_ptr->zlib_method = method; png_ptr->zlib_method = method;
} }
void
png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
{
png_ptr->write_row_fn = write_row_fn;
}
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
void
png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
write_user_transform_fn)
{
png_debug(1, "in png_set_write_user_transform_fn\n");
png_ptr->transformations |= PNG_USER_TRANSFORM;
png_ptr->write_user_transform_fn = write_user_transform_fn;
}
#endif

View File

@ -1,12 +1,12 @@
/* pngwtran.c - transforms the data in a row for PNG writers /* pngwtran.c - transforms the data in a row for PNG writers
* *
* libpng 0.99e * libpng 1.00
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@ -19,6 +19,21 @@ void
png_do_write_transformations(png_structp png_ptr) png_do_write_transformations(png_structp png_ptr)
{ {
png_debug(1, "in png_do_write_transformations\n"); png_debug(1, "in png_do_write_transformations\n");
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
if (png_ptr->transformations & PNG_USER_TRANSFORM)
if(png_ptr->write_user_transform_fn != NULL)
(*(png_ptr->write_user_transform_fn)) /* user write 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_WRITE_FILLER_SUPPORTED) #if defined(PNG_WRITE_FILLER_SUPPORTED)
if (png_ptr->transformations & PNG_FILLER) if (png_ptr->transformations & PNG_FILLER)
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,

View File

@ -1,12 +1,12 @@
/* pngwutil.c - utilities to write a PNG file /* pngwutil.c - utilities to write a PNG file
* *
* libpng 0.99e * libpng 1.00
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 28, 1998 * March 7, 1998
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL

View File

@ -21,8 +21,10 @@ LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
RANLIB=ranlib RANLIB=ranlib
#RANLIB=echo #RANLIB=echo
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2 PNGMAJ = 2
PNGMIN = 0.99 PNGMIN = 1.00
PNGVER = $(PNGMAJ).$(PNGMIN) PNGVER = $(PNGMAJ).$(PNGMIN)
# where make install puts libpng.a, libpng.so*, and png.h # where make install puts libpng.a, libpng.so*, and png.h

69
scripts/makefile.os2 Normal file
View File

@ -0,0 +1,69 @@
# makefile for libpng on OS/2 with gcc
# For conditions of distribution and use, see copyright notice in png.h
# Related files: pngos2.def
CC=gcc -Zomf -s
# Where the zlib library and include files are located
ZLIBLIB=../zlib
ZLIBINC=../zlib
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) -Wall -O6 -funroll-loops -malign-loops=2 \
-malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll
AR=emxomfar
PNGLIB=png.lib
IMPLIB=emximp
SHAREDLIB=png.dll
SHAREDLIBIMP=pngdll.lib
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
.SUFFIXES: .c .o
all: $(PNGLIB) $(SHAREDLIB) $(SHAREDLIBIMP)
$(PNGLIB): $(OBJS)
$(AR) rc $@ $(OBJS)
$(SHAREDLIB): $(OBJS) pngos2.def
$(CC) $(LDFLAGS) -Zdll -o $@ $^
$(SHAREDLIBIMP): pngos2.def
$(IMPLIB) -o $@ $^
pngtest.exe: pngtest.o png.dll pngdll.lib
$(CC) -o $@ $(CFLAGS) $< $(LDFLAGS)
test: pngtest.exe
./pngtest.exe
clean:
rm -f *.o $(PNGLIB) png.dll pngdll.lib pngtest.exe pngout.png
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h
pngerror.o pngerror.pic.o: png.h pngconf.h
pngrio.o pngrio.pic.o: png.h pngconf.h
pngwio.o pngwio.pic.o: png.h pngconf.h
pngmem.o pngmem.pic.o: png.h pngconf.h
pngset.o pngset.pic.o: png.h pngconf.h
pngget.o pngget.pic.o: png.h pngconf.h
pngread.o pngread.pic.o: png.h pngconf.h
pngrtran.o pngrtran.pic.o: png.h pngconf.h
pngrutil.o pngrutil.pic.o: png.h pngconf.h
pngtrans.o pngtrans.pic.o: png.h pngconf.h
pngwrite.o pngwrite.pic.o: png.h pngconf.h
pngwtran.o pngwtran.pic.o: png.h pngconf.h
pngwutil.o pngwutil.pic.o: png.h pngconf.h
pngpread.o pngpread.pic.o: png.h pngconf.h
pngtest.o: png.h pngconf.h

98
scripts/makefile.s2x Normal file
View File

@ -0,0 +1,98 @@
makefile for libpng on Solaris 2.x with gcc
# Contributed by William L. Sebok, based on makefile.lnx
# Copyright (C) 1996, 1997 Andreas Dilger
# Copyright (C) 1998 Greg Roelofs
# For conditions of distribution and use, see copyright notice in png.h
CC=gcc
# Where the zlib library and include files are located
ZLIBLIB=/usr/local/lib
ZLIBINC=/usr/local/include
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) -Wall -O3 \
#$(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng -lz -lm
#RANLIB=ranlib
RANLIB=echo
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.00
PNGVER = $(PNGMAJ).$(PNGMIN)
# where make install puts libpng.a, libpng.so*, and png.h
prefix=/local
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.pic.o:
$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
all: libpng.a libpng.so pngtest
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
libpng.so: libpng.so.$(PNGMAJ)
ln -sf libpng.so.$(PNGMAJ) libpng.so
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
libpng.so.$(PNGVER): $(OBJSDLL)
$(LD) -G -L$(LIBPATH) -R$(LIBPATH) -h libpng.so.$(PNGMAJ) \
-o libpng.so.$(PNGVER) $(OBJSDLL) -lz
pngtest: pngtest.o libpng.so
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
test: pngtest
./pngtest
install: libpng.a libpng.so.$(PNGVER)
-@mkdir $(INCPATH) $(LIBPATH)
cp png.h pngconf.h $(INCPATH)
chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
(cd $(LIBPATH); ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
ln -sf libpng.so.$(PNGMAJ) libpng.so)
clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h
pngerror.o pngerror.pic.o: png.h pngconf.h
pngrio.o pngrio.pic.o: png.h pngconf.h
pngwio.o pngwio.pic.o: png.h pngconf.h
pngmem.o pngmem.pic.o: png.h pngconf.h
pngset.o pngset.pic.o: png.h pngconf.h
pngget.o pngget.pic.o: png.h pngconf.h
pngread.o pngread.pic.o: png.h pngconf.h
pngrtran.o pngrtran.pic.o: png.h pngconf.h
pngrutil.o pngrutil.pic.o: png.h pngconf.h
pngtrans.o pngtrans.pic.o: png.h pngconf.h
pngwrite.o pngwrite.pic.o: png.h pngconf.h
pngwtran.o pngwtran.pic.o: png.h pngconf.h
pngwutil.o pngwutil.pic.o: png.h pngconf.h
pngpread.o pngpread.pic.o: png.h pngconf.h
pngtest.o: png.h pngconf.h

View File

@ -9,18 +9,22 @@ CFLAGS=-O2 -Z $(MODEL) -I..\zlib
CC=tcc CC=tcc
LD=tcc LD=tcc
LIB=tlib LIB=tlib
LDFLAGS=$(MODEL) LDFLAGS=$(MODEL) -L..\zlib
O=.obj O=.obj
E=.exe
# variables # variables
OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O)
pngwutil$(O)
OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O)
OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O)
OBJSL1 = +png$(O) +pngset$(O) +pngget$(O) +pngrutil$(O) +pngtrans$(O) OBJSL1 = +png$(O) +pngset$(O) +pngget$(O) +pngrutil$(O) +pngtrans$(O)
OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O) OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O)
OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O) +pngerror$(O)
OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O)
+pngwio$(O)
all: libpng.lib all: libpng.lib pngtest.exe
png$(O): png.h pngconf.h png$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c
@ -75,4 +79,7 @@ libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
$(LIB) libpng +$(OBJSL2) $(LIB) libpng +$(OBJSL2)
$(LIB) libpng +$(OBJSL3) $(LIB) libpng +$(OBJSL3)
# End of makefile for libpng pngtest$(E): pngtest$(O) libpng.lib
$(CC) $(LDFLAGS) pngtest.obj libpng.lib zlib.lib
# End of makefile for libpng

88
scripts/makefile.wat Normal file
View File

@ -0,0 +1,88 @@
# Makefile for libpng
# Watcom 10a+ 32-bit protected mode flat memory model
# Adapted by Pawel Mrochen, based on makefile.msc
# For conditions of distribution and use, see copyright notice in png.h
# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
# To use, do "wmake -f makefile.wat"
# ------------- Watcom 10a+ -------------
MODEL=-mf
CFLAGS= $(MODEL) -fpi87 -fp5 -5r -oaeilmnrt -s -i=..\zlib
CC=wcc386
LD=wcl386
LIB=wlib -b -c
LDFLAGS=
O=.obj
#uncomment next to put error messages in a file
#ERRFILE= >> pngerrs
# variables
OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O)
OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O)
all: test
png$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngset$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngget$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngread$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngpread$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngrtran$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngrutil$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngerror$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngmem$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngrio$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngwio$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngtest$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngtrans$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngwrite$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngwtran$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
pngwutil$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
$(LIB) -n libpng.lib +$(OBJS1)
$(LIB) libpng.lib +$(OBJS2)
$(LIB) libpng.lib +$(OBJS3)
pngtest.exe: pngtest.obj libpng.lib
$(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib
test: pngtest.exe
pngtest
# End of makefile for libpng

286
scripts/pngos2.def Normal file
View File

@ -0,0 +1,286 @@
;----------------------------------------
; PNGLIB module definition file for OS/2
;----------------------------------------
LIBRARY PNG
DESCRIPTION "PNG image compression library for OS/2"
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
EXPORTS
png_set_sig_bytes
png_sig_cmp
png_check_sig
png_create_read_struct
png_create_write_struct
png_write_chunk
png_write_chunk_start
png_write_chunk_data
png_write_chunk_end
png_create_info_struct
png_info_init
png_write_info
png_read_info
png_convert_to_rfc1123
png_convert_from_struct_tm
png_convert_from_time_t
png_set_expand
png_set_bgr
png_set_gray_to_rgb
; png_set_rgb_to_gray
png_build_grayscale_palette
png_set_strip_alpha
png_set_swap_alpha
png_set_invert_alpha
png_set_filler
png_set_swap
png_set_packing
png_set_packswap
png_set_shift
png_set_interlace_handling
png_set_invert_mono
png_set_background
png_set_strip_16
png_set_dither
png_set_gamma
png_set_flush
png_write_flush
png_start_read_image
png_read_update_info
png_read_rows
png_read_row
png_read_image
png_write_row
png_write_rows
png_write_image
png_write_end
png_read_end
png_destroy_info_struct
png_destroy_read_struct
png_read_destroy
png_destroy_write_struct
; png_write_destroy_info
png_write_destroy
png_set_crc_action
png_set_filter
png_set_filter_heuristics
png_set_compression_level
png_set_compression_mem_level
png_set_compression_strategy
png_set_compression_window_bits
png_set_compression_method
png_init_io
png_set_error_fn
png_get_error_ptr
png_set_write_fn
png_set_read_fn
png_set_write_status_fn
png_set_read_status_fn
png_get_io_ptr
png_set_progressive_read_fn
png_set_read_status_fn
png_set_read_user_transform_fn
png_set_write_status_fn
png_set_write_user_transform_fn
png_get_progressive_ptr
png_process_data
png_progressive_combine_row
png_malloc
png_free
png_memcpy_check
png_memset_check
; png_debug_malloc
; png_debug_free
; png_far_to_near
png_error
png_chunk_error
png_warning
png_chunk_warning
png_get_valid
png_get_rowbytes
png_get_channels
png_get_image_width
png_get_image_height
png_get_bit_depth
png_get_color_type
png_get_filter_type
png_get_interlace_type
png_get_compression_type
png_get_pixels_per_meter
png_get_pixel_aspect_ratio
png_get_x_offset_pixels
png_get_y_offset_pixels
png_get_x_offset_microns
png_get_y_offset_microns
png_get_signature
png_get_bKGD
png_set_bKGD
png_get_cHRM
png_set_cHRM
png_get_gAMA
png_set_gAMA
png_get_hIST
png_set_hIST
png_get_IHDR
png_set_IHDR
png_get_oFFs
png_set_oFFs
png_get_pCAL
png_set_pCAL
png_get_pHYs
png_set_pHYs
png_get_PLTE
png_set_PLTE
png_get_sBIT
png_set_sBIT
png_get_sRGB
png_set_sRGB
png_set_sRGB_gAMA_and_cHRM
png_get_text
png_set_text
png_get_tIME
png_set_tIME
png_get_tRNS
png_set_tRNS
png_create_struct
png_destroy_struct
png_info_destroy
png_zalloc
png_zfree
png_reset_crc
png_write_data
png_read_data
png_crc_read
png_crc_finish
png_crc_error
png_calculate_crc
png_flush
png_save_uint_32
png_save_int_32
png_save_uint_16
png_write_sig
png_write_IHDR
png_write_PLTE
png_write_IDAT
png_write_IEND
png_write_gAMA
png_write_sBIT
png_write_cHRM
png_write_sRGB
png_write_tRNS
png_write_bKGD
png_write_hIST
png_check_keyword
png_write_tEXt
png_write_zTXt
png_write_oFFs
png_write_pCAL
png_write_pHYs
png_write_tIME
png_write_finish_row
png_write_start_row
png_build_gamma_table
png_combine_row
png_do_read_interlace
png_do_write_interlace
png_read_filter_row
png_write_find_filter
png_write_filtered_row
png_read_finish_row
png_read_start_row
png_read_transform_info
png_do_read_filler
png_do_read_swap_alpha
png_do_write_swap_alpha
png_do_read_invert_alpha
png_do_write_invert_alpha
png_do_strip_filler
png_do_swap
png_do_packswap
; png_do_rgb_to_gray
png_do_gray_to_rgb
png_do_unpack
png_do_unshift
png_do_invert
png_do_chop
png_do_dither
; png_correct_palette
png_do_bgr
png_do_pack
png_do_shift
png_do_background
png_do_gamma
png_do_expand_palette
png_do_expand
png_handle_IHDR
png_handle_PLTE
png_handle_IEND
png_handle_gAMA
png_handle_sBIT
png_handle_cHRM
png_handle_sRGB
png_handle_tRNS
png_handle_bKGD
png_handle_hIST
png_handle_oFFs
png_handle_pCAL
png_handle_pHYs
png_handle_tIME
png_handle_tEXt
png_handle_zTXt
png_handle_unknown
png_check_chunk_name
png_do_read_transformations
png_do_write_transformations
png_init_read_transformations
png_push_read_chunk
png_push_read_sig
; png_push_check_crc
png_push_crc_skip
png_push_crc_finish
png_push_fill_buffer
png_push_save_buffer
png_push_restore_buffer
png_push_read_IDAT
png_process_IDAT_data
png_push_process_row
png_push_handle_unknown
png_push_have_info
png_push_have_end
png_push_have_row
; png_push_read_end
png_process_some_data
png_read_push_finish_row
png_push_handle_tEXt
png_push_read_tEXt
png_push_handle_zTXt
png_push_read_zTXt
png_libpng_ver
png_pass_start
png_pass_inc
png_pass_ystart
png_pass_yinc
png_pass_mask
png_pass_dsp_mask
; png_pass_width
; png_pass_height
png_IHDR
png_IDAT
png_IEND
png_PLTE
png_bKGD
png_cHRM
png_gAMA
png_hIST
png_oFFs
png_pCAL
png_pHYs
png_sBIT
png_sRGB
png_tEXt
png_tIME
png_tRNS
png_zTXt