提交 4393a9ad 编写于 作者: G Glenn Randers-Pehrson

Imported from libpng-1.0.4-pre1.tar

上级 87544ac6
Libpng 1.0.3 - January 14, 1999
Libpng 1.0.4 - September 17, 1999
This is a public release of libpng, intended for use in production codes.
Changes since the previous public release (1.0.2):
libpng-1.0.3:
Replaced and extended code that was removed from png_set_filler() in 1.0.1a.
Fixed a bug in png_do_filler() that made it fail to write filler bytes in
the left-most pixel of each row (Kevin Bracey).
Changed "static pngcharp tIME_string" to "static char tIME_string[30]"
in pngtest.c (Duncan Simpson).
Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk
even when no tIME chunk was present in the source file.
Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit.
Fixed a problem in png_read_push_finish_row(), which would not skip some
passes that it should skip, for images that are less than 3 pixels high.
Interchanged the order of calls to png_do_swap() and png_do_shift()
in pngwtran.c (John Cromer).
Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h .
Changed "bad adaptive filter type" from error to warning in pngrutil.c .
Fixed a documentation error about default filtering with 8-bit indexed-color.
Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO
(L. Peter Deutsch).
Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions.
Added png_get_copyright() and png_get_header_version() functions.
Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c
Added information about debugging in libpng.txt and libpng.3 .
Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco.
Removed lines after Dynamic Dependencies" in makefile.aco .
Revised makefile.dec to make a shared library (Jeremie Petit).
Removed trailing blanks from all files.
Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h
Added "if" tests to silence complaints about unused png_ptr in png.h and png.c
Changed "check_if_png" function in example.c to return true (nonzero) if PNG.
Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig()
which is obsolete.
Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice)
Added a statement of Y2K compliance in png.h, libpng.1, and Y2KINFO.
Changes since the last public release (1.0.3):
Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning
if an attempt is made to read an interlaced image when it's not supported.
Added check if png_ptr->trans is defined before free'ing it in pngread.c
Modified the Y2K statement to include versions back to version 0.71
Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c
Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments)
Replaced leading blanks with tab characters in makefile.hux
Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents.
Changed (float)red and (float)green to (double)red, (double)green
in png_set_rgb_to_gray() to avoid "promotion" problems in AIX.
Fixed a bug in pngconf.h that omitted <stdio.h> when PNG_DEBUG==0 (K Bracey).
Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt).
Updated documentation to refer to the PNG-1.2 specification.
Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c
in makefile.knr, INSTALL, and README (L. Peter Deutsch)
Fixed bugs in calculation of the length of rowbytes when adding alpha
channels to 16-bit images, in pngrtran.c (Chris Nokleberg)
Added function png_set_user_transform_info() to store user_transform_ptr,
user_depth, and user_channels into the png_struct, and a function
png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg)
Added function png_set_empty_plte_permitted() to make libpng useable
in MNG applications.
Corrected the typedef for png_free_ptr in png.h (Jesse Jones).
Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be
consistent with PNG-1.2, and allow variance of 500 before complaining.
Added assembler code contributed by Intel in file pngvcrd.c and modified
makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant)
Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code.
Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy.
Added makefile.beo for BEOS on X86, contributed by Sander Stok.
Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h
Changed leading blanks to tabs in all makefiles.
Made alternate versions of png_set_expand() in pngrtran.c, namely
png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha
(Greg Roelofs, in "PNG: The Definitive Guide").
Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h
Revised calculation of num_blocks in pngmem.c to avoid a potentially
negative shift distance, whose results are undefined in the C language.
Added a check in pngset.c to prevent writing multiple tIME chunks.
Added a check in pngwrite.c to detect invalid small window_bits sizes.
Added a demo read_user_transform_fn that examines the row filters in pngtest.c
Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined
Made several minor corrections to pngtest.c
Changed "hptr += 16L" to "hptr = hptr + 16L" in pngmem.c for Turbo 3.0
Send comments/corrections/commendations to
png-implement@dworkin.wustl.edu or to randeg@alumni.rpi.edu
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
Glenn R-P
Send comments/corrections/commendations to
png-implement@dworkin.wustl.edu or to randeg@alumni.rpi.edu
Glenn Randers-Pehrson
libpng maintainer
PNG Development Group
......@@ -386,4 +386,57 @@ version 1.0.2a [January 6, 1999]
which is obsolete.
version 1.0.3 [January 14, 1999]
Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice)
Added a statement of Y2K compliance in png.h, libpng.1, and Y2KINFO.
Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO.
version 1.0.3a [August 12, 1999]
Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning
if an attempt is made to read an interlaced image when it's not supported.
Added check if png_ptr->trans is defined before free'ing it in pngread.c
Modified the Y2K statement to include versions back to version 0.71
Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c
Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments)
Replaced leading blanks with tab characters in makefile.hux
Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents.
Changed (float)red and (float)green to (double)red, (double)green
in png_set_rgb_to_gray() to avoid "promotion" problems in AIX.
Fixed a bug in pngconf.h that omitted <stdio.h> when PNG_DEBUG==0 (K Bracey).
Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt).
Updated documentation to refer to the PNG-1.2 specification.
Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c
in makefile.knr, INSTALL, and README (L. Peter Deutsch)
Fixed bugs in calculation of the length of rowbytes when adding alpha
channels to 16-bit images, in pngrtran.c (Chris Nokleberg)
Added function png_set_user_transform_info() to store user_transform_ptr,
user_depth, and user_channels into the png_struct, and a function
png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg)
Added function png_set_empty_plte_permitted() to make libpng useable
in MNG applications.
Corrected the typedef for png_free_ptr in png.h (Jesse Jones).
Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be
consistent with PNG-1.2, and allow variance of 500 before complaining.
Added assembler code contributed by Intel in file pngvcrd.c and modified
makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant)
Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy.
Added some aliases for png_set_expand() in pngrtran.c, namely
png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS()
(Greg Roelofs, in "PNG: The Definitive Guide").
Added makefile.beo for BEOS on X86, contributed by Sander Stok.
version 1.0.3b [August 26, 1999]
Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h
Changed leading blanks to tabs in all makefiles.
Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code.
Made alternate versions of png_set_expand() in pngrtran.c, namely
png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha
(Greg Roelofs, in "PNG: The Definitive Guide"). Deleted the 1.0.3a aliases.
Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h
Revised calculation of num_blocks in pngmem.c to avoid a potentially
negative shift distance, whose results are undefined in the C language.
Added a check in pngset.c to prevent writing multiple tIME chunks.
Added a check in pngwrite.c to detect invalid small window_bits sizes.
version 1.0.3d [September 4, 1999]
Fixed type casting of igamma in pngrutil.c
Added new png_expand functions to scripts/pngdef.pas and pngos2.def
Added a demo read_user_transform_fn that examines the row filters in pngtest.c
version 1.0.4 [September 17, 1999]
Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined
Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h
Made several minor corrections to pngtest.c
Installing libpng version 1.0.3 - January 14, 1999
Installing libpng version 1.0.4 - September 17, 1999
Before installing libpng, you must first install zlib. zlib
can usually be found wherever you got libpng. zlib can be
......@@ -10,7 +10,7 @@ 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.0.3" or "lpng103" and "zlib-1.1.3"
might be called "libpng-1.0.4" or "lpng103" and "zlib-1.1.3"
or "zlib113") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this:
......@@ -41,18 +41,21 @@ include
descrip.mms => VMS makefile for MMS or MMK
makefile.std => Generic UNIX makefile
makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr
(Requires ansi2knr.c from ftp://ftp.cs.wisc.edu/ghost)
makefile.dec => DEC Alpha UNIX makefile
makefile.hux => HPUX (10.20 and 11.00) makefile
makefile.sgi => Silicon Graphics IRIX makefile
makefile.sun => Sun makefile
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0)
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0)
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.4)
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.4)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mip => MIPS makefile
makefile.aco => Acorn makefile
makefile.ama => Amiga makefile
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
makefile.atr => Atari makefile
makefile.beo => BEOS makefile for X86
makefile.bor => Borland makefile
build.bat => MS-DOS batch file for Borland compiler
makefile.dj2 => DJGPP 2 makefile
......@@ -65,6 +68,7 @@ include
makevms.com => VMS build script
pngdll.mak => To make a png32bd.dll with Borland C++ 4.5
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
SCOPTIONS.ppc => Used with smakefile.ppc
Copy the file (or files) that you need from the
scripts directory into this directory, for example
......
Known bugs and suggested enhancements in libpng-1.0.3
Known bugs and suggested enhancements in libpng-1.0.4
1. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
......@@ -14,12 +14,12 @@ Known bugs and suggested enhancements in libpng-1.0.3
Question whether i-- or --i is better.
STATUS: Under investigation, postponed until after
libpng-1.0.3. About 160 loops will be turned around
libpng-1.0.4. About 160 loops will be turned around
in libpng-1.0.Nn, for testing.
2. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
libpng-1.0.2 and earlier transform colors to gamma=1.0 space for
libpng-1.0.4 and earlier transform colors to gamma=1.0 space for
merging with background, and then back to the image's gamma. The
bit_depth of the intermediate (gamma=1.0) representation is probably
not sufficient. In the typical gamma=1/2.2 situation, the linear
......@@ -29,4 +29,12 @@ Known bugs and suggested enhancements in libpng-1.0.3
STATUS: under development.
3. September 1999 -- ENHANCEMENT --
It should be possible to use libpng without floating-point aritmetic.
STATUS: Under investigation, implementation postponed until after
libpng-1.0.4. The application interface will change because replacements
for the png_set_gAMA(), png_set_cHRM(), and corresponding png_get_()
functions will be needed.
README for libpng 1.0.3 - January 14, 1999 (shared library 2.1)
README for libpng 1.0.4 - September 17, 1999 (shared library 2.1)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
......@@ -49,7 +49,7 @@ to set different actions based on whether the CRC error occurred in a
critical or an ancillary chunk.
The changes made to the library, and bugs fixed are based on discussions
on the PNG implementation mailing list <png-implement@dworking.wustl.edu>
on the PNG implementation mailing list <png-implement@ccrc.wustl.edu>
and not on material submitted to Guy.
For a detailed description on using libpng, read libpng.txt. For
......@@ -98,8 +98,8 @@ fix. Please mention "libpng" somewhere in the subject line. Thanks.
This release was created and will be supported by myself (of course
based in a large way on Guy's and Andreas' earlier work), and the PNG group.
randeg@alumni.rpi.edu
png-implement@dworkin.wustl.edu
randeg@alum.rpi.edu
png-implement@ccrc.wustl.edu
You can't reach Guy, the original libpng author, at the addresses
given in previous versions of this document. He and Andreas will read mail
......@@ -108,7 +108,7 @@ addressed to the png-implement list, however.
Please do not send general questions about PNG. Send them to
the address in the specification (png-group@w3.org). At the same
time, please do not send libpng questions to that address, send them to me
or to png-implement@dworkin.wustl.edu. I'll
or to png-implement@ccrc.wustl.edu. I'll
get them in the end anyway. If you have a question about something
in the PNG specification that is related to using libpng, send it
to me. Send me any questions that start with "I was using libpng,
......@@ -126,8 +126,6 @@ Files in this distribution:
CHANGES => Description of changes between libpng versions
README => This file
TODO => Things not implemented in the current library
ansi2knr.1 => Manual page for ansi2knr
ansi2knr.c => Converts files to K&R style function declarations
build.bat => MS-DOS batch file for Borland compiler
descrip.mms => VMS project file
example.c => Example code for using libpng functions
......@@ -155,38 +153,42 @@ Files in this distribution:
pngwtran.c => Write data transformations
pngwutil.c => Write utility functions
scripts => Directory containing scripts for building libpng:
descrip.mms => VMS makefile for MMS or MMK
makefile.std => Generic UNIX makefile
makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr
makefile.dec => DEC Alpha UNIX makefile
makefile.hux => HPUX (10.20 and 11.00) makefile
makefile.sgi => Silicon Graphics IRIX makefile
makefile.sun => Sun makefile
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0)
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0)
makefile.mip => MIPS makefile
makefile.aco => Acorn makefile
makefile.ama => Amiga makefile
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
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.w32 => makefile for Microsoft Visual C++ 4.0 and later
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
pngdll.mak => To make a png32bd.dll with Borland C++ 4.5
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
descrip.mms => VMS makefile for MMS or MMK
makefile.std => Generic UNIX makefile
makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr
(Requires ansi2knr.c from ftp://ftp.cs.wisc.edu/ghost)
makefile.dec => DEC Alpha UNIX makefile
makefile.hux => HPUX (10.20 and 11.00) makefile
makefile.sgi => Silicon Graphics IRIX makefile
makefile.sun => Sun makefile
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0)
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mip => MIPS makefile
makefile.aco => Acorn makefile
makefile.ama => Amiga makefile
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
makefile.atr => Atari makefile
makefile.beo => BEOS makefile for X86
makefile.bor => Borland makefile
build.bat => MS-DOS batch file for Borland compiler
makefile.dj2 => DJGPP 2 makefile
makefile.msc => Microsoft C makefile
makefile.w32 => makefile for Microsoft Visual C++ 4.0 and later
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
pngdll.mak => To make a png32bd.dll with Borland C++ 4.5
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
SCOPTIONS.ppc => Used with smakefile.ppc
Good luck, and happy coding.
-Glenn Randers-Pehrson
Internet: randeg@alumni.rpi.edu
Internet: randeg@alum.rpi.edu
Web: http://www.rpi.edu/~randeg/index.html
-Andreas Eric Dilger
......
......@@ -10,7 +10,6 @@ Support for application-defined chunk handlers.
Improve setjmp/longjmp usage or remove it in favor of returning error codes.
High-level API for reading images.
Add "grayscale->palette" transformation and "palette->grayscale" detection.
Color to gray transformation.
Improved dithering.
Multi-lingual error and warning message support.
Complete sRGB transformation (presently it simply uses gamma=0.45455).
......@@ -22,3 +21,4 @@ Optional palette (sPLT) creation.
Histogram creation.
Text conversion between different code pages (Latin-1 -> Mac and DOS).
Improve API by hiding the info_ptr.
Make a no-floating-point version.
......@@ -6,9 +6,9 @@
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.81 and
upward are Y2K compliant. It is my belief that earlier versions were
also Y2K compliant.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.4 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer
that will hold years up to 65535. The other two hold the date in text
......@@ -37,14 +37,17 @@
clock time, which returns (year - 1900), which we properly convert to
the full 4-digit year. There is a possibility that applications using
libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
function, or incorrectly passing only a 2-digit year instead of
"year - 1900" into the png_convert_from_struct_tm() function, but this
is not under our control. The libpng documentation has always stated
that it works with 4-digit years, and the APIs have been documented as
such.
function, or that they are incorrectly passing only a 2-digit year
instead of "year - 1900" into the png_convert_from_struct_tm() function,
but this is not under our control. The libpng documentation has always
stated that it works with 4-digit years, and the APIs have been
documented as such.
The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
integer to hold the year, and can hold years as large as 65535.
zlib, upon which libpng depends, is also Y2K compliant. It contains
no date-related code.
Glenn Randers-Pehrson
......
.TH ANSI2KNR 1 "19 Jan 1996"
.SH NAME
ansi2knr \- convert ANSI C to Kernighan & Ritchie C
.SH SYNOPSIS
.I ansi2knr
[--varargs] input_file [output_file]
.SH DESCRIPTION
If no output_file is supplied, output goes to stdout.
.br
There are no error messages.
.sp
.I ansi2knr
recognizes function definitions by seeing a non-keyword identifier at the left
margin, followed by a left parenthesis, with a right parenthesis as the last
character on the line, and with a left brace as the first token on the
following line (ignoring possible intervening comments). It will recognize a
multi-line header provided that no intervening line ends with a left or right
brace or a semicolon. These algorithms ignore whitespace and comments, except
that the function name must be the first thing on the line.
.sp
The following constructs will confuse it:
.br
- Any other construct that starts at the left margin and follows the
above syntax (such as a macro or function call).
.br
- Some macros that tinker with the syntax of the function header.
.sp
The --varargs switch is obsolete, and is recognized only for
backwards compatibility. The present version of
.I ansi2knr
will always attempt to convert a ... argument to va_alist and va_dcl.
.SH AUTHOR
L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and
continues to maintain the current version; most of the code in the current
version is his work. ansi2knr also includes contributions by Francois
Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>.
此差异已折叠。
......@@ -151,7 +151,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
png_set_strip_16(png_ptr);
/* Strip alpha bytes from the input data without combining with th
/* Strip alpha bytes from the input data without combining with the
* background (not recommended).
*/
png_set_strip_alpha(png_ptr);
......
此差异已折叠。
libpng.txt - A description on how to use and modify libpng
libpng version 1.0.3 - January 14, 1999
libpng version 1.0.4 - September 17, 1999
Updated and distributed by Glenn Randers-Pehrson
<randeg@alumni.rpi.edu>
<randeg@alum.rpi.edu>
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
For conditions of distribution and use, see copyright
notice in png.h.
......@@ -22,6 +22,7 @@ libpng.txt - A description on how to use and modify libpng
Copyright (c) 1995 Frank J. T. Wojcik
December 18, 1995 && January 20, 1996
*
I. Introduction
This file describes how to use and modify the PNG reference library
......@@ -35,11 +36,17 @@ INSTALL file for instructions on how to install libpng.
Libpng was written as a companion to the PNG specification, as a way
of reducing the amount of time and effort it takes to support the PNG
file format in application programs. The PNG specification is available
file format in application programs.
The PNG-1.2 specification is available at <http://www.cdrom.com/png>.
The PNG-1.0 specification is available
as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> and as a
W3C Recommendation <http://www.w3.org/TR/REC.png.html>. Some
additional chunks are described in the special-purpose public chunks
documents at <ftp://ftp.uu.net/graphics/png/documents/>. Other information
documents at <ftp://ftp.uu.net/graphics/png/documents/>.
Other information
about PNG, and the latest version of libpng, can be found at the PNG home
page, <http://www.cdrom.com/pub/png/>.
......@@ -261,6 +268,21 @@ You must supply the function
See pngtest.c for a working example. Your function will be called
after all of the other transformations have been processed.
You can also set up a pointer to a user structure for use by your
callback function, and you can inform libpng that your transform
function will change the number of channels or bit depth with the
function
png_set_user_transform_info(png_ptr, user_ptr,
user_depth, user_channels);
You can retrieve the pointer via the function
png_get_user_transform_ptr(). For example:
voidp read_user_transform_ptr =
png_get_user_transform_ptr(png_ptr);
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().
......@@ -506,13 +528,18 @@ grayscale images with bit depths of 2 or 4 or if there is a multiple-image
viewing application that wishes to treat all images in the same way.
if (color_type == PNG_COLOR_TYPE_PALETTE &&
bit_depth <= 8) png_set_expand(png_ptr);
bit_depth <= 8) png_set_palette_to_rgb(png_ptr);
if (color_type == PNG_COLOR_TYPE_GRAY &&
bit_depth < 8) png_set_expand(png_ptr);
bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
if (png_get_valid(png_ptr, info_ptr,
PNG_INFO_tRNS)) png_set_expand(png_ptr);
PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
These three functions are actually aliases for png_set_expand(), added
in libpng version 1.0.4, with the function names expanded to improve code
readability. In some future version they may actually do different
things.
PNG can have files with 16 bits per channel. If you only can handle
8 bits per channel, this will strip the pixels down to 8 bit.
......@@ -599,7 +626,7 @@ and blue channels, leaving the green channel in the gray position.
if (color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)
png_set_rgb_to_gray(png_ptr, error_action,
float red_weight, float green_weight);
double red_weight, double green_weight);
error_action = 1: silently do the conversion
error_action = 2: issue a warning if the original
......@@ -648,7 +675,8 @@ which can be expressed with integers as
The calculation is done in a linear colorspace, if the image gamma
is known.
If you have a grayscale and you are using png_set_expand() to change to
If you have a grayscale and you are using png_set_expand_depth() or
png_set_expand() to change to
a higher bit-depth, you must either supply the background color as a gray
value at the original file bit-depth (need_expand = 1) or else supply the
background color as an RGB triplet at the final, expanded bit depth
......@@ -681,6 +709,8 @@ the amount of additional gamma correction needed to compensate for
a (viewing_gamma=1.25) environment. In a dim or brightly lit room, no
compensation other than the display_gamma is needed (viewing_gamma=1.0).
double gamma, screen_gamma;
if (/* We have a user-defined screen
gamma value */)
{
......@@ -691,7 +721,7 @@ compensation other than the display_gamma is needed (viewing_gamma=1.0).
else if ((gamma_str = getenv("SCREEN_GAMMA"))
!= NULL)
{
screen_gamma = atof(gamma_str);
screen_gamma = (double)atof(gamma_str);
}
/* If we don't have another value */
else
......@@ -831,7 +861,7 @@ row_pointers:
png_read_row(png_ptr, &row_pointers, NULL);
If the file is interlaced (info_ptr->interlace_type != 0), things get
somewhat harder. The only current (PNG Specification version 1.0)
somewhat harder. The only current (PNG Specification version 1.2)
interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7)
is a somewhat complicated 2D interlace scheme, known as Adam7, that
breaks down an image into seven smaller images of varying size, based
......@@ -1194,7 +1224,7 @@ have no special needs in this area, let the library do what it wants by
not calling this function at all, as it has been tuned to deliver a good
speed/compression ratio. The second parameter to png_set_filter() is
the filter method, for which the only valid value is '0' (as of the
October 1996 PNG specification, version 1.0). The third parameter is a
July 1999 PNG specification, version 1.2). The third parameter is a
flag that indicates which filter type(s) are to be tested for each
scanline. See the Compression Library for details on the specific filter
types.
......@@ -1226,7 +1256,7 @@ data. See the Compression Library for details on the compression levels.
You now need to fill in the png_info structure with all the data you
wish to write before the actual image. Note that the only thing you
are allowed to write after the image is the text chunks and the time
chunk (as of PNG Specification 1.0, anyway). See png_write_end() and
chunk (as of PNG Specification 1.2, anyway). See png_write_end() and
the latest PNG specification for more information on that. If you
wish to write them before the image, fill them in now, and flag that
data as being valid. If you want to wait until after the data, don't
......@@ -1555,7 +1585,21 @@ You must supply the function
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.
before any of the other transformations are processed.
You can also set up a pointer to a user structure for use by your
callback function.
png_set_user_transform_info(png_ptr, user_ptr, 0, 0);
The user_channels and user_depth parameters of this function are ignored
when writing; you can set them to zero as shown.
You can retrieve the pointer via the function
png_get_user_transform_ptr(). For example:
voidp write_user_transform_ptr =
png_get_user_transform_ptr(png_ptr);
It is possible to have libpng flush any pending output, either manually,
or automatically after a certain number of lines have been written. To
......@@ -1612,8 +1656,8 @@ row_pointers:
png_write_row(png_ptr, &row_pointer);
When the file is interlaced, things can get a good deal more
complicated. The only currently (as of February 1998 -- PNG Specification
version 1.0, dated October 1996) defined interlacing scheme for PNG files
complicated. The only currently (as of August 1999 -- PNG Specification
version 1.2, dated July 1999) defined interlacing scheme for PNG files
is the "Adam7" interlace scheme, that breaks down an
image into seven smaller images of varying size. libpng will build
these images for you, or you can do them yourself. If you want to
......@@ -1658,7 +1702,6 @@ palette, or histogram, before the call to png_destroy_write_struct();
For a more compact example of writing a PNG image, see the file example.c.
V. Modifying/Customizing libpng:
There are two issues here. The first is changing how libpng does
......@@ -1685,7 +1728,8 @@ which currently just call fread() and fwrite(). The FILE * is stored in
png_struct and is initialized via png_init_io(). If you wish to change
the method of I/O, the library supplies callbacks that you can set
through the function png_set_read_fn() and png_set_write_fn() at run
time, instead of calling the png_init_io() function. These functions
time, instead of calling the png_init_io() function.
These functions
also provide a void pointer that can be retrieved via the function
png_get_io_ptr(). For example:
......@@ -1852,7 +1896,7 @@ images (with and without alpha), but not for paletted images nor
for any images with bit depths less than 8 bits/pixel.
The 'method' parameter sets the main filtering method, which is
currently only '0' in the PNG 1.0 specification. The 'filters'
currently only '0' in the PNG 1.2 specification. The 'filters'
parameter sets which filter(s), if any, should be used for each
scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
to turn filtering on and off, respectively.
......@@ -2021,9 +2065,9 @@ January 13, 1999
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.81 and
upward are Y2K compliant. It is my belief that earlier versions were
also Y2K compliant.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.4 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that
will hold years up to 65535. The other two hold the date in text
......@@ -2052,15 +2096,18 @@ png_convert_from_time_t() function calls gmtime() to convert from system
clock time, which returns (year - 1900), which we properly convert to
the full 4-digit year. There is a possibility that applications using
libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
function, or incorrectly passing only a 2-digit year instead of
"year - 1900" into the png_convert_from_struct_tm() function, but this
is not under our control. The libpng documentation has always stated
that it works with 4-digit years, and the APIs have been documented as
such.
function, or that they are incorrectly passing only a 2-digit year
instead of "year - 1900" into the png_convert_from_struct_tm() function,
but this is not under our control. The libpng documentation has always
stated that it works with 4-digit years, and the APIs have been
documented as such.
The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
integer to hold the year, and can hold years as large as 65535.
zlib, upon which libpng depends, is also Y2K compliant. It contains
no date-related code.
Glenn Randers-Pehrson
libpng maintainer
......
此差异已折叠。
.TH PNG 5 "January 14, 1999"
.TH PNG 5 "September 17, 1999"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
......@@ -20,7 +20,14 @@ platforms.
.SH "SEE ALSO"
.IR libpng(3), zlib(3), deflate(5), and zlib(5)
.LP
PNG specification:
PNG 1.1 specification, January 1999:
.IP
.br
http://www.cdrom.com/pub/png
.LP
PNG 1.0 specification, October 1996:
.IP
.br
RFC 2083
.IP
.br
......@@ -32,12 +39,19 @@ http://www.w3.org/TR/REC-png.html
.SH AUTHORS
This man page: Glenn Randers-Pehrson
.LP
Portable Network Graphics (PNG) Specification Version 1.2 (July 8, 1999):
Glenn Randers-Pehrson and others (png-list@ccrc.wustl.edu).
.LP
Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
Thomas Boutell and others (png-list@dworkin.wustl.edu).
Thomas Boutell and others (png-list@ccrc.wustl.edu).
.LP
.SH COPYRIGHT NOTICE
The PNG specification is copyright (c) 1996 Massachussets Institute of
The PNG-1.2 specification is copyright (c) 1999 Glenn Randers-Pehrson.
See the specification for conditions of use and distribution.
.LP
The PNG-1.0 specification is copyright (c) 1996 Massachussets Institute of
Technology. See the specification for conditions of use and distribution.
.LP
.\" end of man page
......
/* png.c - location for general purpose libpng functions
*
* libpng version 1.0.3 - January 14, 1999
* libpng version 1.0.4 - September 17, 1999
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
......@@ -16,7 +16,7 @@
* string defined in png.h.
*/
char png_libpng_ver[12] = "1.0.3";
char png_libpng_ver[12] = "1.0.4";
/* Place to hold the signature string for a PNG file. */
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
......@@ -352,8 +352,8 @@ png_get_copyright(png_structp png_ptr)
{
if(png_ptr == NULL)
/* silence compiler warning about unused png_ptr */ ;
return("\n libpng version 1.0.3 - January 14, 1999\n\
return("\n libpng version 1.0.4 - September 17, 1999\n\
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
Copyright (c) 1996, 1997 Andreas Dilger\n\
Copyright (c) 1998, 1999, Glenn Randers-Pehrson\n");
Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
}
/* png.h - header file for PNG reference library
*
* libpng version 1.0.3 - January 14, 1999
* libpng version 1.0.4 - September 17, 1999
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
* libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.0.4 - September 17, 1999: Glenn R-P
* See also "Contributing Authors", below.
*
* Y2K compliance in libpng:
* =========================
*
......@@ -14,9 +20,9 @@
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.81 and
* upward are Y2K compliant. It is my belief that earlier versions were
* also Y2K compliant.
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.0.4 are Y2K compliant. It is my belief that earlier
* versions were also Y2K compliant.
*
* Libpng only has three year fields. One is a 2-byte unsigned integer
* that will hold years up to 65535. The other two hold the date in text
......@@ -44,15 +50,17 @@
* clock time, which returns (year - 1900), which we properly convert to
* the full 4-digit year. There is a possibility that applications using
* libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
* function, or incorrectly passing only a 2-digit year instead of
* "year - 1900" into the png_convert_from_struct_tm() function, but this
* is not under our control. The libpng documentation has always stated
* that it works with 4-digit years, and the APIs have been documented as
* such.
* function, or that they are incorrectly passing only a 2-digit year
* instead of "year - 1900" into the png_convert_from_struct_tm() function,
* but this is not under our control. The libpng documentation has always
* stated that it works with 4-digit years, and the APIs have been
* documented as such.
*
* The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
* integer to hold the year, and can hold years as large as 65535.
*
* zlib, upon which libpng depends, is also Y2K compliant. It contains
* no date-related code.
*
* Glenn Randers-Pehrson
* libpng maintainer
......@@ -66,32 +74,35 @@
* The following table summarizes matters since version 0.89c, which was
* the first widely used release:
*
* source png.h png.h shared-lib
* version string int version
* ------- ------ ----- ----------
* 0.89c ("1.0 beta 3") 0.89 89 1.0.89
* 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90]
* 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95]
* 0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96]
* 0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97]
* 0.97c 0.97 97 2.0.97
* 0.98 0.98 98 2.0.98
* 0.99 0.99 98 2.0.99
* 0.99a-m 0.99 99 2.0.99
* 1.00 1.00 100 2.1.0 [int should be 10000]
* 1.0.0 1.0.0 100 2.1.0 [int should be 10000]
* 1.0.1 1.0.1 10001 2.1.0
* 1.0.1a-e 1.0.1a-e 10002 2.1.0.1a-e
* 1.0.2 1.0.2 10002 2.1.0.2
* 1.0.2a-c 1.0.2a 10003 2.1.0.2a-c
* 1.0.3 1.0.3 10003 2.1.0.3
* source png.h png.h shared-lib
* version string int version
* ------- ------ ----- ----------
* 0.89c ("1.0 beta 3") 0.89 89 1.0.89
* 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90]
* 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95]
* 0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96]
* 0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97]
* 0.97c 0.97 97 2.0.97
* 0.98 0.98 98 2.0.98
* 0.99 0.99 98 2.0.99
* 0.99a-m 0.99 99 2.0.99
* 1.00 1.00 100 2.1.0 [int should be 10000]
* 1.0.0 1.0.0 100 2.1.0 [int should be 10000]
* 1.0.1 1.0.1 10001 2.1.0
* 1.0.1a-e 1.0.1a-e 10002 2.1.0.1a-e
* 1.0.2 1.0.2 10002 2.1.0.2
* 1.0.2a-b 1.0.2a-b 10003 2.1.0.2a-b
* 1.0.3 1.0.3 10003 2.1.0.3
* 1.0.3a-d 1.0.3a-d 10004 2.1.0.3a-d
* 1.0.4 1.0.4 10004 2.1.0.4
*
* Henceforth the source version will match the shared-library minor
* and patch numbers; the shared-library major version number will be
* used for changes in backward compatibility, as it is intended. The
* PNG_PNGLIB_VER macro, which is not used within libpng but is available
* for applications, is an unsigned integer of the form xyyzz corresponding
* to the source version x.y.z (leading zeros in y and z).
* to the source version x.y.z (leading zeros in y and z). Internal
* png-group versions (x.y.z[a-z]) will be given the next higher number.
*
* See libpng.txt or libpng.3 for more information. The PNG specification
* is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
......@@ -121,6 +132,13 @@
*
* COPYRIGHT NOTICE:
*
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* (libpng versions 0.5, May 1995, through 0.89c, May 1996)
* Copyright (c) 1996, 1997 Andreas Dilger
* (libpng versions 0.90, December 1996, through 0.96, May 1997)
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* (libpng versions 0.97, January 1998, through 1.0.4 - September 17, 1999)
*
* The PNG Reference Library is supplied "AS IS". The Contributing Authors
* and Group 42, Inc. disclaim all warranties, expressed or implied,
* including, without limitation, the warranties of merchantability and of
......@@ -149,10 +167,6 @@
#ifndef _PNG_H
#define _PNG_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* This is not the place to learn how to use libpng. The file libpng.txt
* describes how to use libpng, and the file example.c summarizes it
* with some code on which to build. This file is useful for looking
......@@ -165,6 +179,11 @@ extern "C" {
/* include all user configurable info */
#include "pngconf.h"
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* This file is arranged in several sections. The first section contains
* structure and type definitions. The second section contains the external
* library functions, while the third has the internal library functions,
......@@ -172,14 +191,14 @@ extern "C" {
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.0.3"
#define PNG_LIBPNG_VER_STRING "1.0.4"
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=bugfix */
#define PNG_LIBPNG_VER 10003 /* 1.0.3 */
#define PNG_LIBPNG_VER 10004 /* 1.0.4 */
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
......@@ -460,6 +479,9 @@ typedef struct png_info_struct
typedef png_info FAR * png_infop;
typedef png_info FAR * FAR * png_infopp;
/* Maximum positive integer used in PNG is (2^31)-1 */
#define PNG_MAX_UINT ((png_uint_32)0x7fffffffL)
/* These describe the color_type field in png_info. */
/* color type masks */
#define PNG_COLOR_MASK_PALETTE 1
......@@ -473,11 +495,11 @@ typedef png_info FAR * FAR * png_infopp;
#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
/* This is for compression type. PNG 1.0 only defines the single type. */
/* This is for compression type. PNG 1.0-1.2 only define the single type. */
#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
/* This is for filter type. PNG 1.0 only defines the single type. */
/* This is for filter type. PNG 1.0-1.2 only define the single type. */
#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
......@@ -575,7 +597,7 @@ typedef void (*png_user_transform_ptr) PNGARG((png_structp,
#endif /* PNG_READ|WRITE_USER_TRANSFORM_SUPPORTED */
typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
typedef void (*png_free_ptr) PNGARG((png_structp, png_structp));
typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
/* 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
......@@ -593,12 +615,19 @@ struct png_struct_def
png_voidp error_ptr; /* user supplied struct for error functions */
png_rw_ptr write_data_fn; /* function for writing output data */
png_rw_ptr read_data_fn; /* function for reading input data */
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
png_voidp io_ptr; /* ptr to application struct for I/O functions*/
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
png_user_transform_ptr read_user_transform_fn; /* user read transform */
#endif
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
png_user_transform_ptr write_user_transform_fn; /* user write transform */
#endif
png_voidp io_ptr; /* ptr to application struct for I/O functions*/
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
png_voidp user_transform_ptr; /* user supplied struct for user transform */
int user_transform_depth; /* bit depth of user transformed pixels */
int user_transform_channels; /* channels in user transformed pixels */
#endif
png_uint_32 mode; /* tells us where we are in the PNG file */
png_uint_32 flags; /* flags indicating various things to libpng */
......@@ -670,10 +699,10 @@ struct png_struct_def
float screen_gamma; /* screen gamma value (display_gamma/viewing_gamma */
#endif /* PNG_READ_GAMMA_SUPPORTED */
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep gamma_table; /* gamma table for 8 bit depth files */
png_bytep gamma_table; /* gamma table for 8-bit depth files */
png_bytep gamma_from_1; /* converts from 1.0 to screen */
png_bytep gamma_to_1; /* converts from file to 1.0 */
png_uint_16pp gamma_16_table; /* gamma table for 16 bit depth files */
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
#endif /* PNG_READ_GAMMA_SUPPORTED || PNG_WRITE_GAMMA_SUPPORTED */
......@@ -751,6 +780,10 @@ struct png_struct_def
png_byte rgb_to_gray_green_coeff;
png_byte rgb_to_gray_blue_coeff;
#endif
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
png_byte empty_plte_permitted;
#endif
};
typedef png_struct FAR * FAR * png_structpp;
......@@ -847,8 +880,11 @@ extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
#endif /* PNG_WRITE_tIME_SUPPORTED */
#if defined(PNG_READ_EXPAND_SUPPORTED)
/* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha if available. */
/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_EXPAND_SUPPORTED */
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
......@@ -857,14 +893,14 @@ extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_BGR_SUPPORTED || PNG_WRITE_BGR_SUPPORTED */
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
/* Expand the grayscale to 24 bit RGB if necessary. */
/* Expand the grayscale to 24-bit RGB if necessary. */
extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
/* Reduce RGB to grayscale. */
extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
int error_action, float red, float green ));
int error_action, double red, double green ));
extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
png_ptr));
#endif /* PNG_READ_RGB_TO_GRAY_SUPPORTED */
......@@ -897,19 +933,19 @@ extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
/* Swap bytes in 16 bit depth files. */
/* Swap bytes in 16-bit depth files. */
extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_SWAP_SUPPORTED || PNG_WRITE_SWAP_SUPPORTED */
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
/* Use 1 byte per pixel in 1, 2, or 4 bit depth files. */
/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_PACK_SUPPORTED || PNG_WRITE_PACK_SUPPORTED */
#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
/* Swap packing order of pixels in bytes. */
extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_PACKSWAP_SUPPORTED || PNG_WRITE_PACKSWAP_SUPPOR */
#endif /* PNG_READ_PACKSWAP_SUPPORTED || PNG_WRITE_PACKSWAP_SUPPORTED */
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
/* Converts files to legal bit depths. */
......@@ -940,7 +976,7 @@ extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
#if defined(PNG_READ_16_TO_8_SUPPORTED)
/* strip the second byte of information from a 16 bit depth file. */
/* strip the second byte of information from a 16-bit depth file. */
extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_16_TO_8_SUPPORTED */
......@@ -957,6 +993,13 @@ extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
double screen_gamma, double default_file_gamma));
#endif /* PNG_READ_GAMMA_SUPPORTED */
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */
extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr,
int empty_plte_permitted));
#endif /* PNG_READ_EMPTY_PLTE_SUPPORTED */
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
/* Set how many lines between output flushes - 0 for no flushing */
extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
......@@ -1217,6 +1260,16 @@ extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
png_ptr, png_user_transform_ptr write_user_transform_fn));
#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp
png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
int user_transform_channels));
/* Return the user pointer associated with the user transform functions */
extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr)
PNGARG((png_structp png_ptr));
#endif
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
/* Sets the function callbacks for the push reader, and a pointer to a
* user-defined structure available to the callback functions.
......@@ -1552,7 +1605,7 @@ png_get_header_version(png_structp png_ptr)
{
if(png_ptr == NULL)
/* silence compiler warning about unused png_ptr */ ;
return("\n libpng version 1.0.3 - January 14, 1999 (header)\n");
return("\n libpng version 1.0.4 - September 17, 1999 (header)\n");
}
#endif
......@@ -1823,7 +1876,7 @@ PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
#endif
/* Place a 16 bit number into a buffer in PNG byte order.
/* Place a 16-bit number into a buffer in PNG byte order.
* The parameter is declared unsigned int, not png_uint_16,
* just to avoid potential problems on pre-ANSI C compilers.
*/
......
/* pngasmrd.h - assembler version of utilities to read a PNG file
*
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1999 Glenn Randers-Pehrson
*
*/
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
/* Set this in the makefile for VC++ on Pentium, not in pngconf.h */
#ifdef PNG_USE_PNGVCRD
/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c .
* MMX will be detected at run time and used if present.
*/
#define PNG_HAVE_ASSEMBLER_COMBINE_ROW
#define PNG_HAVE_ASSEMBLER_READ_INTERLACE
#define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
#endif
/* Set this in the makefile for gcc on Pentium, not in pngconf.h */
#ifdef PNG_USE_PNGGCCRD
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c
* (not available in libpng-1.0.3a).
* MMX will be detected at run time and used if present.
*/
#define PNG_HAVE_ASSEMBLER_COMBINE_ROW
#define PNG_HAVE_ASSEMBLER_READ_INTERLACE
#define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
#endif
#endif
/* pngconf.h - machine configurable file for libpng
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -54,25 +54,24 @@
* prevent these from being compiled and used. #defining PNG_NO_STDIO
* will also prevent these, plus will prevent the entire set of stdio
* macros and functions (FILE *, printf, etc.) from being compiled and used,
* unless PNG_DEBUG has been #defined.
* unless (PNG_DEBUG > 0) has been #defined.
*
* #define PNG_NO_CONSOLE_IO
* #define PNG_NO_STDIO
*/
#ifdef PNG_DEBUG
# if (PNG_DEBUG > 0)
# include <stdio.h>
# endif
#else
# ifdef PNG_NO_STDIO
# ifndef PNG_NO_CONSOLE_IO
# define PNG_NO_CONSOLE_IO
# endif
# ifdef PNG_DEBUG
# if (PNG_DEBUG > 0)
# include <stdio.h>
# endif
# endif
# else
# include <stdio.h>
# endif
#endif
/* This macro protects us against machines that don't have function
* prototypes (ie K&R style headers). If your compiler does not handle
......@@ -173,7 +172,7 @@ __dont__ include it again
#endif
/* Codewarrior on NT has linking problems without this. */
#if defined(__MWERKS__) && defined(WIN32)
#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__)
#define PNG_ALWAYS_EXTERN
#endif
......@@ -339,6 +338,10 @@ __dont__ include it again
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel and SGI */
#endif
#ifndef PNG_NO_READ_EMPTY_PLTE
#define PNG_READ_EMPTY_PLTE_SUPPORTED /* useful for MNG applications */
#endif
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
#ifndef PNG_NO_WRITE_SHIFT
#define PNG_WRITE_SHIFT_SUPPORTED
......@@ -384,6 +387,10 @@ __dont__ include it again
#define PNG_WRITE_FLUSH_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_EMPTY_PLTE
#define PNG_WRITE_EMPTY_PLTE_SUPPORTED /* useful for MNG applications */
#endif
#ifndef PNG_NO_STDIO
#define PNG_TIME_RFC1123_SUPPORTED
#endif
......@@ -408,6 +415,10 @@ __dont__ include it again
#define PNG_EASY_ACCESS_SUPPORTED
#endif
#ifndef PNG_NO_ASSEMBLER_CODE
#define PNG_ASSEMBLER_CODE_SUPPORTED
#endif
/* These are currently experimental features, define them if you want */
/* very little testing */
......
/* pngerror.c - stub functions for i/o and memory allocation
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......
/* pngget.c - retrieval of values from info struct
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -454,7 +454,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
channels++;
pixel_depth = *bit_depth * channels;
rowbytes_per_pixel = (pixel_depth + 7) >> 3;
if ((*width > (png_uint_32)2147483647L/rowbytes_per_pixel))
if ((*width > PNG_MAX_UINT/rowbytes_per_pixel))
{
png_warning(png_ptr,
"Width too large for libpng to process image data.");
......
/* pngmem.c - stub functions for memory allocation
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -157,8 +157,9 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
ret = NULL;
}
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
if (num_blocks < 1)
if(png_ptr->zlib_window_bits > 14)
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
else
num_blocks = 1;
if (png_ptr->zlib_mem_level >= 7)
num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
......@@ -192,12 +193,12 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
if ((png_size_t)hptr & 0xf)
{
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
hptr += 16L;
hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */
}
for (i = 0; i < num_blocks; i++)
{
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
hptr += (png_uint_32)65536L;
hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */
}
png_ptr->offset_table_number = num_blocks;
......
/* pngpread.c - read a png file in push mode
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......
/* pngread.c - read a PNG file
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -188,7 +188,8 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
png_reset_crc(png_ptr);
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name);
png_debug2(0, "Reading %s chunk, length=%d.\n", png_ptr->chunk_name,
length);
/* This should be a binary subdivision search or a hash for
* matching the chunk name rather than a linear search.
......@@ -530,7 +531,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
* not called png_set_interlace_handling(), the display_row buffer will
* be ignored, so pass NULL to it.
*
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.3.
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.4.
*/
void
......@@ -579,7 +580,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
* only call this function once. If you desire to have an image for
* each pass of a interlaced image, use png_read_rows() instead.
*
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.3.
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.4.
*/
void
png_read_image(png_structp png_ptr, png_bytepp image)
......@@ -590,7 +591,16 @@ png_read_image(png_structp png_ptr, png_bytepp image)
png_debug(1, "in png_read_image\n");
/* save jump buffer and error functions */
#ifdef PNG_READ_INTERLACING_SUPPORTED
pass = png_set_interlace_handling(png_ptr);
#else
if (png_ptr->interlaced)
png_error(png_ptr,
"Cannot read interlaced image -- interlace handler disabled.");
pass = 1;
#endif
image_height=png_ptr->height;
png_ptr->num_rows = image_height; /* Make sure this is set correctly */
......@@ -805,8 +815,11 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
#endif
if (png_ptr->flags & PNG_FLAG_FREE_PALETTE)
png_zfree(png_ptr, png_ptr->palette);
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED) || \
defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
if (png_ptr->flags & PNG_FLAG_FREE_TRANS)
png_free(png_ptr, png_ptr->trans);
#endif
#if defined(PNG_READ_hIST_SUPPORTED)
if (png_ptr->flags & PNG_FLAG_FREE_HIST)
png_free(png_ptr, png_ptr->hist);
......
/* pngrio.c - functions for data input
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......
/* pngrtran.c - transforms the data in a row for PNG readers
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -523,7 +523,7 @@ png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
#if defined(PNG_READ_EXPAND_SUPPORTED)
/* Expand paletted images to rgb, expand grayscale images of
* less than 8 bit depth to 8 bit depth, and expand tRNS chunks
* less than 8-bit depth to 8-bit depth, and expand tRNS chunks
* to alpha channels.
*/
void
......@@ -532,7 +532,45 @@ png_set_expand(png_structp png_ptr)
png_debug(1, "in png_set_expand\n");
png_ptr->transformations |= PNG_EXPAND;
}
#endif
/* GRR 19990627: the following three functions currently are identical
* to png_set_expand(). However, it is entirely reasonable that someone
* might wish to expand an indexed image to RGB but *not* expand a single,
* fully transparent palette entry to a full alpha channel--perhaps instead
* convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace
* the transparent color with a particular RGB value, or drop tRNS entirely.
* IOW, a future version of the library may make the transformations flag
* a bit more fine-grained, with separate bits for each of these three
* functions.
*
* More to the point, these functions make it obvious what libpng will be
* doing, whereas "expand" can (and does) mean any number of things.
*/
/* Expand paletted images to RGB. */
void
png_set_palette_to_rgb(png_structp png_ptr)
{
png_debug(1, "in png_set_expand\n");
png_ptr->transformations |= PNG_EXPAND;
}
/* Expand grayscale images of less than 8-bit depth to 8 bits. */
void
png_set_gray_1_2_4_to_8(png_structp png_ptr)
{
png_debug(1, "in png_set_expand\n");
png_ptr->transformations |= PNG_EXPAND;
}
/* Expand tRNS chunks to alpha channels. */
void
png_set_tRNS_to_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_expand\n");
png_ptr->transformations |= PNG_EXPAND;
}
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
void
......@@ -548,8 +586,8 @@ png_set_gray_to_rgb(png_structp png_ptr)
* for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image.
*/
void
png_set_rgb_to_gray(png_structp png_ptr, int error_action, float red,
float green)
png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
double green)
{
png_debug(1, "in png_set_rgb_to_gray\n");
switch(error_action)
......@@ -570,8 +608,8 @@ png_set_rgb_to_gray(png_structp png_ptr, int error_action, float red,
}
#endif
{
png_byte red_byte = (png_byte)(red*255.0 + 0.5);
png_byte green_byte = (png_byte)(green*255.0 + 0.5);
png_byte red_byte = (png_byte)((float)red*255.0 + 0.5);
png_byte green_byte = (png_byte)((float)green*255.0 + 0.5);
if(red < 0.0 || green < 0.0)
{
red_byte = 54;
......@@ -1018,6 +1056,16 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
++info_ptr->channels;
#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
if(png_ptr->transformations & PNG_USER_TRANSFORM)
{
if(info_ptr->bit_depth < png_ptr->user_transform_depth)
info_ptr->bit_depth = png_ptr->user_transform_depth;
if(info_ptr->channels < png_ptr->user_transform_channels)
info_ptr->channels = png_ptr->user_transform_channels;
}
#endif
info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
info_ptr->bit_depth);
info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
......@@ -1223,6 +1271,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
#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 */
......@@ -1234,6 +1283,15 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
/* 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 */
if(png_ptr->user_transform_depth)
png_ptr->row_info.bit_depth = png_ptr->user_transform_depth;
if(png_ptr->user_transform_channels)
png_ptr->row_info.channels = png_ptr->user_transform_channels;
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
png_ptr->row_info.channels);
png_ptr->row_info.rowbytes = (png_ptr->row_info.width *
png_ptr->row_info.pixel_depth+7)>>3;
}
#endif
}
......@@ -1737,7 +1795,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
*(--dp) = lo_filler;
row_info->channels = 2;
row_info->pixel_depth = 32;
row_info->rowbytes = row_width * 2;
row_info->rowbytes = row_width * 4;
}
/* This changes the data from GG to XXGG */
else
......@@ -1752,8 +1810,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
*(--dp) = lo_filler;
}
row_info->channels = 2;
row_info->pixel_depth = 16;
row_info->rowbytes = row_width * 2;
row_info->pixel_depth = 32;
row_info->rowbytes = row_width * 4;
}
}
} /* COLOR_TYPE == GRAY */
......@@ -1817,7 +1875,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
*(--dp) = lo_filler;
row_info->channels = 4;
row_info->pixel_depth = 64;
row_info->rowbytes = row_width * 4;
row_info->rowbytes = row_width * 8;
}
/* This changes the data from RRGGBB to XXRRGGBB */
else
......@@ -1837,7 +1895,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
}
row_info->channels = 4;
row_info->pixel_depth = 64;
row_info->rowbytes = row_width * 4;
row_info->rowbytes = row_width * 8;
}
}
} /* COLOR_TYPE == RGB */
......@@ -1869,8 +1927,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
{
*(dp--) = *sp;
*(dp--) = *sp;
*(dp--) = *sp;
sp--;
*(dp--) = *(sp--);
}
}
else
......@@ -1883,10 +1940,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
*(dp--) = *(sp - 1);
*(dp--) = *sp;
*(dp--) = *(sp - 1);
*(dp--) = *sp;
*(dp--) = *(sp - 1);
sp--;
sp--;
*(dp--) = *(sp--);
*(dp--) = *(sp--);
}
}
}
......@@ -1901,8 +1956,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
*(dp--) = *(sp--);
*(dp--) = *sp;
*(dp--) = *sp;
*(dp--) = *sp;
sp--;
*(dp--) = *(sp--);
}
}
else
......@@ -1917,10 +1971,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
*(dp--) = *(sp - 1);
*(dp--) = *sp;
*(dp--) = *(sp - 1);
*(dp--) = *sp;
*(dp--) = *(sp - 1);
sp--;
sp--;
*(dp--) = *(sp--);
*(dp--) = *(sp--);
}
}
}
......
/* pngrutil.c - utilities to read a PNG file
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.3b - August 26, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -14,6 +14,10 @@
#define PNG_INTERNAL
#include "png.h"
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
#include "pngasmrd.h"
#endif
#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
png_uint_32
......@@ -165,8 +169,8 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
interlace_type = buf[12];
/* check for width and height valid values */
if (width == 0 || width > (png_uint_32)2147483647L || height == 0 ||
height > (png_uint_32)2147483647L)
if (width == 0 || width > PNG_MAX_UINT || height == 0 ||
height > PNG_MAX_UINT)
png_error(png_ptr, "Invalid image size in IHDR");
/* check other values */
......@@ -178,7 +182,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
color_type == 5 || color_type > 6)
png_error(png_ptr, "Invalid color type in IHDR");
if ((color_type == PNG_COLOR_TYPE_PALETTE && bit_depth) > 8 ||
if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||
((color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))
......@@ -420,7 +424,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#if defined(PNG_READ_sRGB_SUPPORTED)
if (info_ptr->valid & PNG_INFO_sRGB)
if(igamma != (png_uint_32)45000L)
if(fabs((float)igamma - 45455.)>500.)
{
png_warning(png_ptr,
"Ignoring incorrect gAMA value when sRGB is also present");
......@@ -692,7 +696,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
if ((info_ptr->valid & PNG_INFO_gAMA))
if((png_uint_32)(png_ptr->gamma*(float)100000.+.5) != (png_uint_32)45000L)
if(fabs((png_ptr->gamma*(float)100000.+.5)-45455.) > 500.)
{
png_warning(png_ptr,
"Ignoring incorrect gAMA value when sRGB is also present");
......@@ -871,9 +875,21 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
png_ptr->background.index = buf[0];
png_ptr->background.red = (png_uint_16)png_ptr->palette[buf[0]].red;
png_ptr->background.green = (png_uint_16)png_ptr->palette[buf[0]].green;
png_ptr->background.blue = (png_uint_16)png_ptr->palette[buf[0]].blue;
if(info_ptr->num_palette)
{
if(buf[0] > info_ptr->num_palette)
{
png_warning(png_ptr, "Incorrect bKGD chunk index value");
png_crc_finish(png_ptr, length);
return;
}
png_ptr->background.red =
(png_uint_16)png_ptr->palette[buf[0]].red;
png_ptr->background.green =
(png_uint_16)png_ptr->palette[buf[0]].green;
png_ptr->background.blue =
(png_uint_16)png_ptr->palette[buf[0]].blue;
}
}
else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */
{
......@@ -1480,8 +1496,12 @@ png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
to any alpha or transparency value associated with the pixel. If
you want all pixels to be combined, pass 0xff (255) in mask. */
void
png_combine_row(png_structp png_ptr, png_bytep row,
int mask)
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
png_combine_row_c
#else
png_combine_row
#endif /* PNG_HAVE_ASSEMBLER_COMBINE_ROW */
(png_structp png_ptr, png_bytep row, int mask)
{
png_debug(1,"in png_combine_row\n");
if (mask == 0xff)
......@@ -1684,7 +1704,12 @@ png_combine_row(png_structp png_ptr, png_bytep row,
#if defined(PNG_READ_INTERLACING_SUPPORTED)
void
png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
png_do_read_interlace_c
#else
png_do_read_interlace
#endif /* PNG_HAVE_ASSEMBLER_READ_INTERLACE */
(png_row_infop row_info, png_bytep row, int pass,
png_uint_32 transformations)
{
png_debug(1,"in png_do_read_interlace\n");
......@@ -1894,13 +1919,16 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
#endif
void
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
png_read_filter_row_c
#else
png_read_filter_row
#endif /* PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */
(png_structp png_ptr, png_row_infop row_info, png_bytep row,
png_bytep prev_row, int filter)
{
png_debug(1, "in png_read_filter_row\n");
png_debug2(2,"row = %d, filter = %d\n", png_ptr->row_number, filter);
switch (filter)
{
case PNG_FILTER_VALUE_NONE:
......
/* pngset.c - storage of image information into info struct
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -107,7 +107,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
/* check for overflow */
rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3;
if (( width > (png_uint_32)2147483647L/rowbytes_per_pixel))
if (( width > PNG_MAX_UINT/rowbytes_per_pixel))
{
png_warning(png_ptr,
"Width too large to process image data; rowbytes will overflow.");
......@@ -344,7 +344,8 @@ void
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
{
png_debug1(1, "in %s storage function\n", "tIME");
if (png_ptr == NULL || info_ptr == NULL)
if (png_ptr == NULL || info_ptr == NULL ||
(png_ptr->flags & PNG_FLAG_WROTE_tIME))
return;
png_memcpy(&(info_ptr->mod_time), mod_time, sizeof (png_time));
......@@ -378,3 +379,13 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
}
#endif
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED)
void
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
{
png_debug1(1, "in png_permit_empty_plte\n", "");
if (png_ptr == NULL)
return;
png_ptr->empty_plte_permitted=(png_byte)empty_plte_permitted;
}
#endif
/* pngtest.c - a simple test program to test libpng
*
* libpng 1.0.3 -January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -42,6 +42,8 @@ static int tIME_chunk_present=0;
static char tIME_string[30] = "no tIME chunk present in file";
#endif /* PNG_TIME_RFC1123_SUPPORTED */
static int verbose = 0;
int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname));
#ifdef __TURBOC__
......@@ -60,12 +62,12 @@ static int status_dots=1;
void
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
{
if(png_ptr == NULL || row_number > 0x3fffffffL) return;
if(png_ptr == NULL || row_number > PNG_MAX_UINT) return;
if(status_pass != pass)
{
fprintf(stdout,"\n Pass %d: ",pass);
status_pass = pass;
status_dots = 30;
status_dots = 31;
}
status_dots--;
if(status_dots == 0)
......@@ -79,11 +81,24 @@ read_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 > 0x3fffffffL || pass > 7) return;
if(png_ptr == NULL || row_number > PNG_MAX_UINT || pass > 7) return;
fprintf(stdout, "w");
}
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
/* Example of using user transform callback (we don't transform anything,
but merely examine the row filters. We set this to 256 rather than
5 in case illegal filter values are present.) */
static png_uint_32 filters_used[256];
void
count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
{
if(png_ptr != NULL && row_info != NULL)
++filters_used[*(data-1)];
}
#endif
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
/* example of using user transform callback (we don't transform anything,
but merely count the zero samples) */
......@@ -105,6 +120,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
* png_byte pixel_depth bits per pixel (depth*channels)
*/
/* counts the number of zero samples (or zero pixels if color_type is 3 */
if(row_info->color_type == 0 || row_info->color_type == 3)
......@@ -178,7 +194,6 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
}
#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */
static int verbose = 0;
static int wrote_question = 0;
#if defined(PNG_NO_STDIO)
......@@ -584,10 +599,18 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_set_read_status_fn(read_ptr, NULL);
}
# if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
zero_samples=0;
png_set_write_user_transform_fn(write_ptr, count_zero_samples);
# endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
{
int i;
for(i=0; i<256; i++)
filters_used[i]=0;
png_set_read_user_transform_fn(read_ptr, count_filters);
}
#endif
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
zero_samples=0;
png_set_write_user_transform_fn(write_ptr, count_zero_samples);
#endif
png_debug(0, "Reading info struct\n");
png_read_info(read_ptr, read_info_ptr);
......@@ -859,7 +882,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (png_memcmp(inbuf, outbuf, num_in))
{
fprintf(STDERR, "Files %s and %s are different\n", inname, outname);
fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname);
if(wrote_question == 0)
{
fprintf(STDERR,
......@@ -885,8 +908,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
/* input and output filenames */
#ifdef RISCOS
PNG_CONST char *inname = "pngtest/png";
PNG_CONST char *outname = "pngout/png";
static PNG_CONST char *inname = "pngtest/png";
static PNG_CONST char *outname = "pngout/png";
#else
static PNG_CONST char *inname = "pngtest.png";
static PNG_CONST char *outname = "pngout.png";
......@@ -973,7 +996,7 @@ main(int argc, char *argv[])
#endif
for (i=2; i<argc; ++i)
{
int kerror;
int k, kerror;
fprintf(STDERR, "Testing %s:",argv[i]);
kerror = test_one_file(argv[i], outname);
if (kerror == 0)
......@@ -983,6 +1006,12 @@ main(int argc, char *argv[])
#else
fprintf(STDERR, " PASS\n");
#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
for (k=0; k<256; k++)
if(filters_used[k])
fprintf(STDERR, " Filter %d was used %lu times\n",
k,filters_used[k]);
#endif
#if defined(PNG_TIME_RFC1123_SUPPORTED)
if(tIME_chunk_present != 0)
fprintf(STDERR, " tIME = %s\n",tIME_string);
......@@ -1032,14 +1061,21 @@ main(int argc, char *argv[])
{
if(verbose == 1 || i == 2)
{
int k;
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
fprintf(STDERR, " PASS (%lu zero samples)\n",zero_samples);
#else
fprintf(STDERR, " PASS\n");
#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
for (k=0; k<256; k++)
if(filters_used[k])
fprintf(STDERR, " Filter %d was used %lu times\n",
k,filters_used[k]);
#endif
#if defined(PNG_TIME_RFC1123_SUPPORTED)
if(tIME_chunk_present != 0)
fprintf(STDERR, " tIME = %s\n",tIME_string);
if(tIME_chunk_present != 0)
fprintf(STDERR, " tIME = %s\n",tIME_string);
#endif /* PNG_TIME_RFC1123_SUPPORTED */
}
}
......
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -570,3 +570,26 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
}
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
void
png_set_user_transform_info(png_structp png_ptr, png_voidp
user_transform_ptr, int user_transform_depth, int user_transform_channels)
{
png_debug(1, "in png_set_user_transform_info\n");
png_ptr->user_transform_ptr = user_transform_ptr;
png_ptr->user_transform_depth = user_transform_depth;
png_ptr->user_transform_channels = user_transform_channels;
}
/* This function returns a pointer to the user_transform_ptr associated with
* the user transform functions. The application should free any memory
* associated with this pointer before png_write_destroy and png_read_destroy
* are called.
*/
png_voidp
png_get_user_transform_ptr(png_structp png_ptr)
{
return ((png_voidp)png_ptr->user_transform_ptr);
}
#endif
此差异已折叠。
/* pngwio.c - functions for data output
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......
/* pngwrite.c - general routines to write a PNG file
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -971,6 +971,8 @@ png_set_compression_window_bits(png_structp png_ptr, int window_bits)
{
if (window_bits > 15)
png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
else if (window_bits < 8)
png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS;
png_ptr->zlib_window_bits = window_bits;
}
......@@ -1001,4 +1003,3 @@ png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
png_ptr->write_user_transform_fn = write_user_transform_fn;
}
#endif
/* pngwtran.c - transforms the data in a row for PNG writers
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......
/* pngwutil.c - utilities to write a PNG file
*
* libpng 1.0.3 - January 14, 1999
* libpng 1.0.4 - September 17, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -284,17 +284,21 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
png_byte buf[3];
png_debug(1, "in png_write_PLTE\n");
if (num_pal == 0 || num_pal > 256)
{
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
png_error(png_ptr, "Invalid number of colors in palette");
}
else
{
png_warning(png_ptr, "Invalid number of colors in palette");
return;
}
if ((
#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED
!png_ptr->empty_plte_permitted &&
#endif
num_pal == 0) || num_pal > 256)
{
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
png_error(png_ptr, "Invalid number of colors in palette");
}
else
{
png_warning(png_ptr, "Invalid number of colors in palette");
return;
}
}
png_ptr->num_palette = (png_uint_16)num_pal;
......@@ -524,7 +528,12 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
png_debug(1, "in png_write_bKGD\n");
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
if (back->index > png_ptr->num_palette)
if (
#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED
(!png_ptr->empty_plte_permitted ||
(png_ptr->empty_plte_permitted && png_ptr->num_palette)) &&
#endif
back->index > png_ptr->num_palette)
{
png_warning(png_ptr, "Invalid background palette index");
return;
......@@ -713,6 +722,11 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
/* make sure we include the 0 after the key */
png_write_chunk_start(png_ptr, png_tEXt, (png_uint_32)key_len+text_len+1);
/*
* We leave it to the application to meet PNG-1.0 requirements on the
* contents of the text. PNG-1.0 through PNG-1.2 discourage the use of
* any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them.
*/
png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
if (text_len)
png_write_chunk_data(png_ptr, (png_bytep)text, text_len);
......
......@@ -13,36 +13,36 @@ Squeezeflags = -o $@
# Final targets:
@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \
@.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \
@.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
@.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \
@.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
@.mm-libpng-lib: @.mm.png @.mm.pngerror @.mm.pngrio @.mm.pngwio @.mm.pngmem \
@.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \
@.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil
LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \
@.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \
@.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \
@.mm.pngwtran @.mm.pngwutil
@.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \
@.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil
LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \
@.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \
@.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \
@.mm.pngwtran @.mm.pngwutil
# User-editable dependencies:
# (C) Copyright 1997 Tom Tanner
Test: @.pngtest
<Prefix$Dir>.pngtest
@remove <Prefix$Dir>.pngtest
<Prefix$Dir>.pngtest
@remove <Prefix$Dir>.pngtest
#It would be nice if you could stop "make" listing from here on!
@.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
.SUFFIXES: .o .mm .c
.c.mm:
MemCheck.CC cc $(ccflags) -o $@ LibPng:$<
MemCheck.CC cc $(ccflags) -o $@ LibPng:$<
.c.o:
cc $(ccflags) -o $@ $<
cc $(ccflags) -o $@ $<
# Static dependencies:
......
......@@ -8,7 +8,7 @@ CC=sc
# WARNING: a bug in V6.51 causes bad code with OPTGO
# So use V6.55 or set NOOPTGO!!!!!!!!!
CFLAGS= NOSTKCHK PARMS=REG OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL\
OPTLOOP OPTRDEP=4 OPTDEP=4 OPTCOMP=4 DEFINE=PNG_INTERNAL
OPTLOOP OPTRDEP=4 OPTDEP=4 OPTCOMP=4 DEFINE=PNG_INTERNAL
#linker flags
LDFLAGS= SD ND BATCH
#link libs
......
# makefile for libpng on BeOS x86 ELF with gcc
# modified from makefile.lnx by Sander Stoks
# Copyright (C) 1996, 1997 Andreas Dilger
# Copyright (C) 1999 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
ALIGN=
# For I-386:
# ALIGN=-malign-loops=2 -malign-functions=2
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
# On BeOS, -O1 is actually better than -O3. This is a known bug but it's
# still here in R4.5
CFLAGS=-I$(ZLIBINC) -Wall -O1 -funroll-loops \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
# LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
LDFLAGS=-L. -Wl,-soname=libpng.so.$(PNGMAJ) -L$(ZLIBLIB) -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.0.3
PNGVER = $(PNGMAJ).$(PNGMIN)
# where make install puts libpng.a, libpng.so*, and png.h
prefix=/usr/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)
.SUFFIXES: .c .o
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
cp libpng.so* /boot/home/config/lib
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
libpng.so.$(PNGVER): $(OBJSDLL)
$(CC) -L$(ZLIBLIB) -lz -nostart -Wl,-soname,libpng.so.$(PNGMAJ) -o
libpng.so.$(PNGVER) \
$(OBJSDLL)
pngtest: pngtest.o libpng.so
$(CC) -L$(ZLIBLIB) -lz -lpng -o pngtest pngtest.o
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
......@@ -70,38 +70,38 @@ O=obj
## variables
OBJS = \
png.$(O) \
pngerror.$(O) \
pngmem.$(O) \
pngpread.$(O) \
pngset.$(O) \
pngget.$(O) \
pngread.$(O) \
pngrio.$(O) \
pngrtran.$(O) \
pngrutil.$(O) \
pngtrans.$(O) \
pngwrite.$(O) \
pngwtran.$(O) \
pngwio.$(O) \
pngwutil.$(O)
png.$(O) \
pngerror.$(O) \
pngmem.$(O) \
pngpread.$(O) \
pngset.$(O) \
pngget.$(O) \
pngread.$(O) \
pngrio.$(O) \
pngrtran.$(O) \
pngrutil.$(O) \
pngtrans.$(O) \
pngwrite.$(O) \
pngwtran.$(O) \
pngwio.$(O) \
pngwutil.$(O)
LIBOBJS = \
+png.$(O) \
+pngerror.$(O) \
+pngmem.$(O) \
+pngpread.$(O) \
+pngread.$(O) \
+pngset.$(O) \
+pngget.$(O) \
+pngrio.$(O) \
+pngrtran.$(O) \
+pngrutil.$(O) \
+pngtrans.$(O) \
+pngwrite.$(O) \
+pngwtran.$(O) \
+pngwio.$(O) \
+pngwutil.$(O)
+png.$(O) \
+pngerror.$(O) \
+pngmem.$(O) \
+pngpread.$(O) \
+pngread.$(O) \
+pngset.$(O) \
+pngget.$(O) \
+pngrio.$(O) \
+pngrtran.$(O) \
+pngrutil.$(O) \
+pngtrans.$(O) \
+pngwrite.$(O) \
+pngwtran.$(O) \
+pngwio.$(O) \
+pngwutil.$(O)
LIBNAME=libpng$(MODEL).lib
......@@ -146,7 +146,7 @@ pngwutil.obj: pngwutil.c
$(LIBNAME): $(OBJS)
-del $(LIBNAME)
$(LIB) $(LIBNAME) @&&|
$(LIB) $(LIBNAME) @&&|
$(LIBOBJS), libpng$(MODEL)
|
......
......@@ -14,7 +14,7 @@ ZLIBINC=../zlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.3
PNGMIN = 1.0.4
PNGVER = $(PNGMAJ).$(PNGMIN)
CC=cc
......@@ -36,10 +36,10 @@ libpng.a: $(OBJS)
$(RANLIB) $@
libpng.so: libpng.so.$(PNGMAJ)
ln -s -f libpng.so.$(PNGMAJ) libpng.so
ln -f -s libpng.so.$(PNGMAJ) libpng.so
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
ln -s -f libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
libpng.so.$(PNGVER): $(OBJS)
$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) -lz -lm
......@@ -62,8 +62,8 @@ install: libpng.a libpng.so.$(PNGVER)
chmod 644 $(prefix)/lib/libpng.a
chmod 644 $(prefix)/lib/libpng.so.$(PNGVER)
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
(cd $(LIBPATH); ln -s -f libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
ln -s -f libpng.so.$(PNGMAJ) libpng.so)
(cd $(LIBPATH); ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
ln -f -s libpng.so.$(PNGMAJ) libpng.so)
clean:
rm -f *.o libpng.a pngtest pngout.png libpng.so*
......
===========================================================================
# makefile for libpng, HPUX (10.20 and 11.00)
# Copyright (C) 1995 Guy Eric Schalnat, Group 42
# Copyright (C) 1999 Glenn Randers-Pehrson
......@@ -17,36 +16,36 @@ LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
RANLIB=ranlib
# where make install puts libpng.a and png.h
prefix=/opt/libpng/
prefix=/opt/libpng
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
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
ar rc $@ $(OBJS)
$(RANLIB) $@
pngtest: pngtest.o libpng.a
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
test: pngtest
./pngtest
./pngtest
install: libpng.a
-@mkdir $(prefix)/include
-@mkdir $(prefix)/lib
cp png.h $(prefix)/include
cp pngconf.h $(prefix)/include
chmod 644 $(prefix)/include/png.h
chmod 644 $(prefix)/include/pngconf.h
cp libpng.a $(prefix)/lib
chmod 644 $(prefix)/lib/libpng.a
-@mkdir $(prefix)/include
-@mkdir $(prefix)/lib
cp png.h $(prefix)/include
cp pngconf.h $(prefix)/include
chmod 644 $(prefix)/include/png.h
chmod 644 $(prefix)/include/pngconf.h
cp libpng.a $(prefix)/lib
chmod 644 $(prefix)/lib/libpng.a
clean:
rm -f *.o libpng.a pngtest pngout.png
rm -f *.o libpng.a pngtest pngout.png
# DO NOT DELETE THIS LINE -- make depend depends on it.
......
......@@ -2,6 +2,11 @@
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
# This makefile requires file file ansi2knr.c, which you can get
# from the Ghostscript ftp site at ftp://ftp.cs.wisc.edu/ghost/
# If you have libjpeg, you probably already have ansi2knr.c in the jpeg
# source distribution.
# where make install puts libpng.a and png.h
prefix=/usr/local
......
......@@ -19,11 +19,11 @@ ALIGN=
#ALIGN=-malign-loops=2 -malign-functions=2
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
RANLIB=ranlib
......@@ -32,15 +32,15 @@ RANLIB=ranlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.3
PNGMIN = 1.0.4
PNGVER = $(PNGMAJ).$(PNGMIN)
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
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
OBJSDLL = $(OBJS:.o=.pic.o)
......@@ -56,10 +56,10 @@ libpng.a: $(OBJS)
$(RANLIB) $@
libpng.so: libpng.so.$(PNGMAJ)
ln -s -f libpng.so.$(PNGMAJ) libpng.so
ln -f -s libpng.so.$(PNGMAJ) libpng.so
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
ln -s -f libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
libpng.so.$(PNGVER): $(OBJSDLL)
$(CC) -shared -Wl,-soname,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \
......@@ -78,8 +78,8 @@ install: libpng.a libpng.so.$(PNGVER)
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 -s -f libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
ln -s -f libpng.so.$(PNGMAJ) libpng.so)
(cd $(LIBPATH); ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
ln -f -s libpng.so.$(PNGMAJ) libpng.so)
clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
......
......@@ -26,52 +26,52 @@ png$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngset$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngget$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngread$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngpread$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngrtran$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngrutil$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngerror$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngmem$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngrio$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwio$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngtest$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngtrans$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwrite$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwtran$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwutil$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
del libpng.lib
del libpng.lib
lib libpng $(OBJS1);
lib libpng $(OBJS2);
lib libpng $(OBJS3);
......
......@@ -10,10 +10,10 @@ ZLIBLIB=../zlib
ZLIBINC=../zlib
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
-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
-malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll
AR=emxomfar
......@@ -23,8 +23,8 @@ 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
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
.SUFFIXES: .c .o
......
此差异已折叠。
此差异已折叠。
......@@ -14,6 +14,7 @@ ZLIBINC=../zlib
CC=cc
WARNMORE=-fullwarn
# You can add the -n32 option; then zlib must also be compiled with -n32
CFLAGS=-I$(ZLIBINC) -O $(WARNMORE) # -g -DPNG_DEBUG=5
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
......
......@@ -13,8 +13,8 @@ ZLIBINC=../zlib
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow -Wconversion \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes
CC=gcc
CFLAGS=-I$(ZLIBINC) -O # $(WARNMORE) -DPNG_DEBUG=5
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册