Imported from libpng-0.88.tar

This commit is contained in:
Guy Schalnat 1996-01-26 01:38:47 -06:00 committed by Glenn Randers-Pehrson
parent 4ee97b0891
commit b2e01bd505
36 changed files with 3932 additions and 2578 deletions

488
ansi2knr.c Normal file
View File

@ -0,0 +1,488 @@
/* Copyright (C) 1989, 1991, 1993 Aladdin Enterprises. All rights reserved. */
/* ansi2knr.c */
/* Convert ANSI function declarations to K&R syntax */
/*
ansi2knr is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing. Refer
to the GNU General Public License for full details.
Everyone is granted permission to copy, modify and redistribute
ansi2knr, but only under the conditions described in the GNU
General Public License. A copy of this license is supposed to have been
given to you along with ansi2knr so you can know your rights and
responsibilities. It should be in a file named COPYING. Among other
things, the copyright notice and this notice must be preserved on all
copies.
*/
/*
---------- Here is the GNU GPL file COPYING, referred to above ----------
----- These terms do NOT apply to the JPEG software itself; see README ------
GHOSTSCRIPT GENERAL PUBLIC LICENSE
(Clarified 11 Feb 1988)
Copyright (C) 1988 Richard M. Stallman
Everyone is permitted to copy and distribute verbatim copies of this
license, but changing it is not allowed. You can also use this wording
to make the terms for other programs.
The license agreements of most software companies keep you at the
mercy of those companies. By contrast, our general public license is
intended to give everyone the right to share Ghostscript. To make sure
that you get the rights we want you to have, we need to make
restrictions that forbid anyone to deny you these rights or to ask you
to surrender the rights. Hence this license agreement.
Specifically, we want to make sure that you have the right to give
away copies of Ghostscript, that you receive source code or else can get
it if you want it, that you can change Ghostscript or use pieces of it
in new free programs, and that you know you can do these things.
To make sure that everyone has such rights, we have to forbid you to
deprive anyone else of these rights. For example, if you distribute
copies of Ghostscript, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
Also, for our own protection, we must make certain that everyone finds
out that there is no warranty for Ghostscript. If Ghostscript is
modified by someone else and passed on, we want its recipients to know
that what they have is not what we distributed, so that any problems
introduced by others will not reflect on our reputation.
Therefore we (Richard M. Stallman and the Free Software Foundation,
Inc.) make the following terms which say what you must do to be allowed
to distribute or change Ghostscript.
COPYING POLICIES
1. You may copy and distribute verbatim copies of Ghostscript source
code as you receive it, in any medium, provided that you conspicuously
and appropriately publish on each copy a valid copyright and license
notice "Copyright (C) 1989 Aladdin Enterprises. All rights reserved.
Distributed by Free Software Foundation, Inc." (or with whatever year is
appropriate); keep intact the notices on all files that refer to this
License Agreement and to the absence of any warranty; and give any other
recipients of the Ghostscript program a copy of this License Agreement
along with the program. You may charge a distribution fee for the
physical act of transferring a copy.
2. You may modify your copy or copies of Ghostscript or any portion of
it, and copy and distribute such modifications under the terms of
Paragraph 1 above, provided that you also do the following:
a) cause the modified files to carry prominent notices stating
that you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish,
that in whole or in part contains or is a derivative of Ghostscript
or any part thereof, to be licensed at no charge to all third
parties on terms identical to those contained in this License
Agreement (except that you may choose to grant more extensive
warranty protection to some or all third parties, at your option).
c) You may charge a distribution fee for the physical act of
transferring a copy, and you may at your option offer warranty
protection in exchange for a fee.
Mere aggregation of another unrelated program with this program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other program under the scope of these terms.
3. You may copy and distribute Ghostscript (or a portion or derivative
of it, under Paragraph 2) in object code or executable form under the
terms of Paragraphs 1 and 2 above provided that you also do one of the
following:
a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal
shipping charge) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
For an executable file, complete source code means all the source code for
all modules it contains; but, as a special exception, it need not include
source code for modules which are standard libraries that accompany the
operating system on which the executable file runs.
4. You may not copy, sublicense, distribute or transfer Ghostscript
except as expressly provided under this License Agreement. Any attempt
otherwise to copy, sublicense, distribute or transfer Ghostscript is
void and your rights to use the program under this License agreement
shall be automatically terminated. However, parties who have received
computer software programs from you with this License Agreement will not
have their licenses terminated so long as such parties remain in full
compliance.
5. If you wish to incorporate parts of Ghostscript into other free
programs whose distribution conditions are different, write to the Free
Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not
yet worked out a simple rule that can be stated here, but we will often
permit this. We will be guided by the two goals of preserving the free
status of all derivatives of our free software and of promoting the
sharing and reuse of software.
Your comments and suggestions about our licensing policies and our
software are welcome! Please contact the Free Software Foundation,
Inc., 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296.
NO WARRANTY
BECAUSE GHOSTSCRIPT IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD
M. STALLMAN, ALADDIN ENTERPRISES, L. PETER DEUTSCH, AND/OR OTHER PARTIES
PROVIDE GHOSTSCRIPT "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF GHOSTSCRIPT IS WITH
YOU. SHOULD GHOSTSCRIPT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., L. PETER DEUTSCH, ALADDIN
ENTERPRISES, AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE
GHOSTSCRIPT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING
ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GHOSTSCRIPT, EVEN IF YOU
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM
BY ANY OTHER PARTY.
-------------------- End of file COPYING ------------------------------
*/
#include <stdio.h>
#include <ctype.h>
#ifdef BSD
#include <strings.h>
#else
#ifdef VMS
extern int strlen(), strncmp();
#else
#include <string.h>
#endif
#endif
/* malloc and free should be declared in stdlib.h, */
/* but if you've got a K&R compiler, they probably aren't. */
#ifdef MSDOS
#include <malloc.h>
#else
#ifdef VMS
extern char *malloc();
extern void free();
#else
extern char *malloc();
extern int free();
#endif
#endif
/* Usage:
ansi2knr input_file [output_file]
* If no output_file is supplied, output goes to stdout.
* There are no error messages.
*
* ansi2knr recognizes functions 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.
* It will recognize a multi-line header provided that the last character
* of the last line of the header is a right parenthesis,
* and no intervening line ends with a left brace or a semicolon.
* These algorithms ignore whitespace and comments, except that
* the function name must be the first thing on the line.
* The following constructs will confuse it:
* - Any other construct that starts at the left margin and
* follows the above syntax (such as a macro or function call).
* - Macros that tinker with the syntax of the function header.
*/
/* Scanning macros */
#define isidchar(ch) (isalnum(ch) || (ch) == '_')
#define isidfirstchar(ch) (isalpha(ch) || (ch) == '_')
/* Forward references */
char *skipspace();
int writeblanks();
int test1();
int convert1();
/* The main program */
main(argc, argv)
int argc;
char *argv[];
{ FILE *in, *out;
#define bufsize 5000 /* arbitrary size */
char *buf;
char *line;
switch ( argc )
{
default:
printf("Usage: ansi2knr input_file [output_file]\n");
exit(0);
case 2:
out = stdout; break;
case 3:
out = fopen(argv[2], "w");
if ( out == NULL )
{ fprintf(stderr, "Cannot open %s\n", argv[2]);
exit(1);
}
}
in = fopen(argv[1], "r");
if ( in == NULL )
{ fprintf(stderr, "Cannot open %s\n", argv[1]);
exit(1);
}
fprintf(out, "#line 1 \"%s\"\n", argv[1]);
buf = malloc(bufsize);
line = buf;
while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
{ switch ( test1(buf) )
{
case 1: /* a function */
convert1(buf, out);
break;
case -1: /* maybe the start of a function */
line = buf + strlen(buf);
if ( line != buf + (bufsize - 1) ) /* overflow check */
continue;
/* falls through */
default: /* not a function */
fputs(buf, out);
break;
}
line = buf;
}
if ( line != buf ) fputs(buf, out);
free(buf);
fclose(out);
fclose(in);
return 0;
}
/* Skip over space and comments, in either direction. */
char *
skipspace(p, dir)
register char *p;
register int dir; /* 1 for forward, -1 for backward */
{ for ( ; ; )
{ while ( isspace(*p) ) p += dir;
if ( !(*p == '/' && p[dir] == '*') ) break;
p += dir; p += dir;
while ( !(*p == '*' && p[dir] == '/') )
{ if ( *p == 0 ) return p; /* multi-line comment?? */
p += dir;
}
p += dir; p += dir;
}
return p;
}
/*
* Write blanks over part of a string.
*/
int
writeblanks(start, end)
char *start;
char *end;
{ char *p;
for ( p = start; p < end; p++ ) *p = ' ';
return 0;
}
/*
* Test whether the string in buf is a function definition.
* The string may contain and/or end with a newline.
* Return as follows:
* 0 - definitely not a function definition;
* 1 - definitely a function definition;
* -1 - may be the beginning of a function definition,
* append another line and look again.
*/
int
test1(buf)
char *buf;
{ register char *p = buf;
char *bend;
char *endfn;
int contin;
if ( !isidfirstchar(*p) )
return 0; /* no name at left margin */
bend = skipspace(buf + strlen(buf) - 1, -1);
switch ( *bend )
{
case ')': contin = 1; break;
case '{':
case ';': return 0; /* not a function */
default: contin = -1;
}
while ( isidchar(*p) ) p++;
endfn = p;
p = skipspace(p, 1);
if ( *p++ != '(' )
return 0; /* not a function */
p = skipspace(p, 1);
if ( *p == ')' )
return 0; /* no parameters */
/* Check that the apparent function name isn't a keyword. */
/* We only need to check for keywords that could be followed */
/* by a left parenthesis (which, unfortunately, is most of them). */
{ static char *words[] =
{ "asm", "auto", "case", "char", "const", "double",
"extern", "float", "for", "if", "int", "long",
"register", "return", "short", "signed", "sizeof",
"static", "switch", "typedef", "unsigned",
"void", "volatile", "while", 0
};
char **key = words;
char *kp;
int len = endfn - buf;
while ( (kp = *key) != 0 )
{ if ( strlen(kp) == len && !strncmp(kp, buf, len) )
return 0; /* name is a keyword */
key++;
}
}
return contin;
}
int
convert1(buf, out)
char *buf;
FILE *out;
{ char *endfn;
register char *p;
char **breaks;
unsigned num_breaks = 2; /* for testing */
char **btop;
char **bp;
char **ap;
/* Pre-ANSI implementations don't agree on whether strchr */
/* is called strchr or index, so we open-code it here. */
for ( endfn = buf; *(endfn++) != '('; ) ;
top: p = endfn;
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
if ( breaks == 0 )
{ /* Couldn't allocate break table, give up */
fprintf(stderr, "Unable to allocate break table!\n");
fputs(buf, out);
return -1;
}
btop = breaks + num_breaks * 2 - 2;
bp = breaks;
/* Parse the argument list */
do
{ int level = 0;
char *end = NULL;
if ( bp >= btop )
{ /* Filled up break table. */
/* Allocate a bigger one and start over. */
free((char *)breaks);
num_breaks <<= 1;
goto top;
}
*bp++ = p;
/* Find the end of the argument */
for ( ; end == NULL; p++ )
{ switch(*p)
{
case ',': if ( !level ) end = p; break;
case '(': level++; break;
case ')': if ( --level < 0 ) end = p; break;
case '/': p = skipspace(p, 1) - 1; break;
default: ;
}
}
p--; /* back up over terminator */
/* Find the name being declared. */
/* This is complicated because of procedure and */
/* array modifiers. */
for ( ; ; )
{ p = skipspace(p - 1, -1);
switch ( *p )
{
case ']': /* skip array dimension(s) */
case ')': /* skip procedure args OR name */
{ int level = 1;
while ( level )
switch ( *--p )
{
case ']': case ')': level++; break;
case '[': case '(': level--; break;
case '/': p = skipspace(p, -1) + 1; break;
default: ;
}
}
if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
{ /* We found the name being declared */
while ( !isidfirstchar(*p) )
p = skipspace(p, 1) + 1;
goto found;
}
break;
default: goto found;
}
}
found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
{ p++;
if ( bp == breaks + 1 ) /* sole argument */
writeblanks(breaks[0], p);
else
writeblanks(bp[-1] - 1, p);
bp--;
}
else
{ while ( isidchar(*p) ) p--;
*bp++ = p+1;
}
p = end;
}
while ( *p++ == ',' );
*bp = p;
/* Make a special check for 'void' arglist */
if ( bp == breaks+2 )
{ p = skipspace(breaks[0], 1);
if ( !strncmp(p, "void", 4) )
{ p = skipspace(p+4, 1);
if ( p == breaks[2] - 1 )
{ bp = breaks; /* yup, pretend arglist is empty */
writeblanks(breaks[0], p + 1);
}
}
}
/* Put out the function name */
p = buf;
while ( p != endfn ) putc(*p, out), p++;
/* Put out the declaration */
for ( ap = breaks+1; ap < bp; ap += 2 )
{ p = *ap;
while ( isidchar(*p) ) putc(*p, out), p++;
if ( ap < bp - 1 ) fputs(", ", out);
}
fputs(") ", out);
/* Put out the argument declarations */
for ( ap = breaks+2; ap <= bp; ap += 2 ) (*ap)[-1] = ';';
fputs(breaks[0], out);
free((char *)breaks);
return 0;
}

2
build.bat Normal file
View File

@ -0,0 +1,2 @@
make -fmakefile.bor -B -DMODEL=m %1 %2 %3 libpng >buildm.out
make -fmakefile.bor -B -DMODEL=l %1 %2 %3 libpng >buildl.out

50
descrip.mms Normal file
View File

@ -0,0 +1,50 @@
cc_defs = /inc=$(ZLIBSRC)
c_deb =
.ifdef __DECC__
pref = /prefix=all
.endif
OBJS = png.obj, pngrcb.obj, pngrutil.obj, pngtrans.obj, pngwutil.obj,\
pngread.obj, pngmem.obj, pngwrite.obj, pngrtran.obj, pngwtran.obj,\
pngio.obj, pngerror.obj, pngpread.obj
CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF)
all : pngtest.exe libpng.olb
@ write sys$output " pngtest available"
libpng.olb : libpng.olb($(OBJS))
@ write sys$output " Libpng available"
pngtest.exe : pngtest.obj libpng.olb
link pngtest,libpng.olb/lib,$(ZLIBSRC)libz.olb/lib
test : pngtest.exe
run pngtest
clean :
delete *.obj;*,*.exe;*
# Other dependencies.
png.obj : png.h, pngconf.h
pngpread.obj : png.h, pngconf.h
pngrcb.obj : png.h, pngconf.h
pngread.obj : png.h, pngconf.h
pngrtran.obj : png.h, pngconf.h
pngrutil.obj : png.h, pngconf.h
pngerror.obj : png.h, pngconf.h
pngmem.obj : png.h, pngconf.h
pngio.obj : png.h, pngconf.h
pngtest.obj : png.h, pngconf.h
pngtrans.obj : png.h, pngconf.h
pngwrite.obj : png.h, pngconf.h
pngwtran.obj : png.h, pngconf.h
pngwutil.obj : png.h, pngconf.h

View File

@ -6,7 +6,7 @@ libpng.txt - a description on how to use and modify libpng
January 15, 1996 January 15, 1996
Updated/rewritten per request in the libpng FAQ Updated/rewritten per request in the libpng FAQ
Copyright (c) 1995 Frank J. T. Wojcik Copyright (c) 1995 Frank J. T. Wojcik
December 18, 1995 December 18, 1995 && January 20, 1996
I. Introduction I. Introduction
@ -18,13 +18,12 @@ file, example.c is a good starting point for using the library, as
it is heavily commented and should include everything most people it is heavily commented and should include everything most people
will need. will need.
Libpng was written as a companion to the PNG specification, as a Libpng was written as a companion to the PNG specification, as a way
way to reduce the amount of time and effort it takes to support to reduce the amount of time and effort it takes to support the PNG
the PNG file format in application programs. Most users will not file format in application programs. Most users will not have to
have to modify the library significantly; advanced users may want modify the library significantly; advanced users may want to modify it
to modify it more. The library was coded for both kinds of users. more. All attempts were made to make it as complete as possible,
All attempts were made to make it as complete as possible, while while keeping the code easy to understand. Currently, this library
keeping the code easy to understand. Currently, this library
only supports C. Support for other languages is being considered. only supports C. Support for other languages is being considered.
Libpng has been designed to handle multiple sessions at one time, Libpng has been designed to handle multiple sessions at one time,
@ -32,7 +31,7 @@ to be easily modifiable, to be portable to the vast majority of
machines (ANSI, K&R, 16 bit, 32 bit) available, and to be easy to machines (ANSI, K&R, 16 bit, 32 bit) available, and to be easy to
use. The ultimate goal of libpng is to promote the acceptance of use. The ultimate goal of libpng is to promote the acceptance of
the PNG file format in whatever way possible. While there is still the PNG file format in whatever way possible. While there is still
work to be done (see the todo.txt file), libpng should cover the work to be done (see the pngtodo.txt file), libpng should cover the
majority of the needs of it's users. majority of the needs of it's users.
Libpng uses zlib for its compression and decompression of PNG files. Libpng uses zlib for its compression and decompression of PNG files.
@ -40,7 +39,7 @@ The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng. useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details. See the documentation delivered with zlib for more details.
Libpng is thread safe provided the threads are using different Libpng is thread safe, provided the threads are using different
instances of the structures. Each thread should have its own instances of the structures. Each thread should have its own
png_struct and png_info instances, and thus its own image. png_struct and png_info instances, and thus its own image.
Libpng does not protect itself against two threads using the Libpng does not protect itself against two threads using the
@ -68,18 +67,6 @@ And while I'm on the topic, make sure you include the png header file:
III. Reading III. Reading
Checking PNG files:
Libpng provides a simple check to see if a file is a PNG file. To
use it, pass in the first 1 to 8 bytes of the file, and it will return
true or false (1 or 0) depending on whether the bytes could be part
of a PNG file. Of course, the more bytes you pass in, the greater
the accuracy of the prediction. If you pass in more then eight bytes,
libpng will only look at the first eight bytes.
fread(header, 1, number, fp);
is_png = png_check_sig(header, number);
Reading PNG files: Reading PNG files:
We'll now walk you through the possible functions to call when reading We'll now walk you through the possible functions to call when reading
@ -88,11 +75,36 @@ See example.c and png.h for more detail. While Progressive reading
is covered in the next section, you will still need some of the is covered in the next section, you will still need some of the
functions discussed in this section to read a PNG file. functions discussed in this section to read a PNG file.
The first thing you need to do while reading a PNG file, aside from You will want to do the I/O initialization(*) before you get into libpng,
the standard I/O initialization, is to allocate and initialize so if it doesn't work, you don't have much to undo. Of course, you
png_struct and png_info. As these are both large, you may not want to will also want to insure that you are, in fact, dealing with a PNG
store these on the stack, unless you have stack space to spare. Of file. Libpng provides a simple check to see if a file is a PNG file.
course, you will want to check if malloc returns NULL. To use it, pass in the first 1 to 8 bytes of the file, and it will
return true or false (1 or 0) depending on whether the bytes could be
part of a PNG file. Of course, the more bytes you pass in, the
greater the accuracy of the prediction. If you pass in more then
eight bytes, libpng will only look at the first eight bytes.
(*): If you are not using the standard I/O functions, you will need
to replace them with custom functions. See the discussion under
Customizing libpng.
FILE *fp = fopen(file_name, "rb");
if (!fp)
{
return;
}
fread(header, 1, number, fp);
is_png = png_check_sig(header, number);
if (!is_png)
{
return;
}
Next, png_struct and png_info need to be allocated and initialized.
As these are both large, you may not want to store these on the stack,
unless you have stack space to spare. Of course, you will want to
check if malloc returns NULL.
png_structp png_ptr = malloc(sizeof (png_struct)); png_structp png_ptr = malloc(sizeof (png_struct));
if (!png_ptr) if (!png_ptr)
@ -104,22 +116,6 @@ course, you will want to check if malloc returns NULL.
return; return;
} }
You may also want to do any i/o initialization here, before
you get into libpng, so if it doesn't work, you don't have
much to undo.
FILE *fp = fopen(file_name, "rb");
if (!fp)
{
free(png_ptr);
free(info_ptr);
return;
}
If you are not using the standard i/o functions, you will need
to replace them with custom functions. See the discussion under
Customizing libpng.
After you have these structures, you will need to set up the After you have these structures, you will need to set up the
error handling. When libpng encounters an error, it expects to error handling. When libpng encounters an error, it expects to
longjmp back to your routine. Therefore, you will need to call longjmp back to your routine. Therefore, you will need to call
@ -147,19 +143,19 @@ Next, you will need to call png_info_init() and png_read_init().
These functions make sure all the fields are initialized to useful These functions make sure all the fields are initialized to useful
values, and, in the case of png_read_init(), and allocate any memory values, and, in the case of png_read_init(), and allocate any memory
needed for internal uses. You must call png_info_init() first, as needed for internal uses. You must call png_info_init() first, as
png_read_init() could do a longjmp, and if the info is not initialized, png_read_init() could do a longjmp, and, if the info is not initialized,
the png_read_destroy() could try to png_free() random addresses, which then png_read_destroy() could try to png_free() random addresses, which
would be bad. would be bad.
png_info_init(info_ptr); png_info_init(info_ptr);
png_read_init(png_ptr); png_read_init(png_ptr);
Now you need to set up the input code. The default for libpng is Now you need to set up the input code. The default for libpng is to
to use the C function fread(). If you use this, you will need to use the C function fread(). If you use this, you will need to pass a
pass a valid FILE * in the function png_init_io(). Be sure that valid FILE * in the function png_init_io(). Be sure that the file is
the file is opened in binary mode. If you wish to handle reading opened in binary mode. Again, if you wish to handle reading data in
data in another way, see the discussion on png i/o handling in the another way, see the discussion on libpng I/O handling in the Customizing
Customizing Libpng section below. Libpng section below.
png_init_io(png_ptr, fp); png_init_io(png_ptr, fp);
@ -177,13 +173,13 @@ to read the file. Some of the more important parts of the png_info are:
color_type - describes the channels and what they mean color_type - describes the channels and what they mean
(see the PNG_COLOR_TYPE_ macros for more information) (see the PNG_COLOR_TYPE_ macros for more information)
channels - number of channels of info for the color type channels - number of channels of info for the color type
pixel_depth - bits per pixel, the result of multiplying the bit_depth pixel_depth - bits per pixel, the result of multiplying the
times the channels bit_depth times the channels
rowbytes - number of bytes needed to hold a row rowbytes - number of bytes needed to hold a row
interlace_type - currently 0 for none, 1 for interlaced interlace_type - currently 0 for none, 1 for interlaced
valid - this details which optional chunks were found in the valid - this details which optional chunks were found in the
file to see if a chunk was present, AND valid with the file to see if a chunk was present, AND valid with
appropriate PNG_INFO_<chunk name> define. the appropriate PNG_INFO_<chunk name> define.
These are also important, but their validity depends on whether a These are also important, but their validity depends on whether a
corresponding chunk exists. Use valid (see above) to ensure that what corresponding chunk exists. Use valid (see above) to ensure that what
@ -193,12 +189,11 @@ you're doing with these values makes sense.
num_palette - number of entries in the palette num_palette - number of entries in the palette
gamma - the gamma the file is written at gamma - the gamma the file is written at
sig_bit - the number of significant bits sig_bit - the number of significant bits
for the gray, red, green, and blue channels, whichever are for the gray, red, green, and blue channels, whichever
appropriate for the given color type. are appropriate for the given color type.
sig_bit_number - number of channels
trans_values - transparent pixel for non-paletted images trans_values - transparent pixel for non-paletted images
trans - array of transparent entries for paletted images trans - array of transparent entries for paletted images
number_trans - number of transparent entries num_trans - number of transparent entries
hist - histogram of palette hist - histogram of palette
text - text comments in the file. text - text comments in the file.
num_text - number of comments num_text - number of comments
@ -210,13 +205,13 @@ needed to hold a row (expand, rgbx, xrgb, graph_to_rgb, etc.).
See png_update_info(), below. See png_update_info(), below.
A quick word about text and num_text. PNG stores comments in A quick word about text and num_text. PNG stores comments in
keyword/text pairs, one pair per chunk. While there are keyword/text pairs, one pair per chunk. While there are suggested
suggested keywords, there is no requirement to restrict the use keywords, there is no requirement to restrict the use to these
to these strings. There is a requirement to have at least one strings. There is a requirement to have at least one character for a
character for a keyword. It is strongly suggested that keywords keyword. It is strongly suggested that keywords be sensible to humans
be sensible to humans (that's the point), so don't use abbreviations. (that's the point), so don't use abbreviations. See the png
See the png specification for more details. There is no requirement specification for more details. There is also no requirement to have
to have text after the keyword. text after the keyword.
Keywords are restricted to 80 characters without leading or trailing Keywords are restricted to 80 characters without leading or trailing
spaces, but spaces are allowed within the keyword It is possible to spaces, but spaces are allowed within the keyword It is possible to
@ -225,7 +220,7 @@ array of png_text structures, each holding pointer to a keyword
and a pointer to a text string. Only the text string may be null. and a pointer to a text string. Only the text string may be null.
The keyword/text pairs are put into the array in the order that The keyword/text pairs are put into the array in the order that
they are received. However, some or all of the text chunks may be they are received. However, some or all of the text chunks may be
after the image, so to make sure you have read all the text chunks, after the image, so, to make sure you have read all the text chunks,
don't mess with these until after you read the stuff after the image. don't mess with these until after you read the stuff after the image.
This will be mentioned again below in the discussion that goes with This will be mentioned again below in the discussion that goes with
png_read_end(). png_read_end().
@ -233,17 +228,17 @@ png_read_end().
After you've read the file information, you can set up the library to After you've read the file information, you can set up the library to
handle any special transformations of the image data. The various handle any special transformations of the image data. The various
ways to transform the data will be described in the order that they ways to transform the data will be described in the order that they
occur. This is important, as some of these change the color type should occur. This is important, as some of these change the color
and bit depth of the data, and some others only work on certain type and/or bit depth of the data, and some others only work on
color types and bit depths. Even though each transformation should certain color types and bit depths. Even though each transformation
check to see if it has data that it can do somthing with, you should checks to see if it has data that it can do somthing with, you should
make sure to only enable a transformation if it will be valid for make sure to only enable a transformation if it will be valid for the
the data. For example, don't swap red and blue on grayscale data. data. For example, don't swap red and blue on grayscale data.
This transforms bit depths of less than 8 to 8 bits, changes paletted The following code transforms bit depths of less than 8 to 8 bits,
images to rgb, and adds an alpha channel if there is transparency changes paletted images to rgb, and adds an alpha channel if there is
information in a tRNS chunk. This is probably most useful on grayscale transparency information in a tRNS chunk. This is probably most
images with bit depths of 2 or 4 and tRNS chunks. useful on grayscale images with bit depths of 2 or 4 and tRNS chunks.
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE && if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
info_ptr->bit_depth < 8) info_ptr->bit_depth < 8)
@ -256,15 +251,15 @@ images with bit depths of 2 or 4 and tRNS chunks.
if (info_ptr->valid & PNG_INFO_tRNS) if (info_ptr->valid & PNG_INFO_tRNS)
png_set_expand(png_ptr); png_set_expand(png_ptr);
This handles alpha and transparency by replacing it with a background The following code handles alpha and transparency by replacing it with
value. If there was a valid one in the file, you can use it if you a background value. If there was a valid one in the file, you can use
want. However, you can replace it with your own if you want also. If it if you want. However, you can replace it with your own if you want
there wasn't one in the file, you must supply a color. If libpng is also. If there wasn't one in the file, you must supply a color. If
doing gamma correction, you will need to tell libpng where the libpng is doing gamma correction, you will need to tell libpng where
background came from so it can do the appropriate gamma correction. the background came from so it can do the appropriate gamma
If you are modifying the color data with png_set_expand(), you must correction. If you are telling libpong to modify the color data with
indicate whether the background needs to be expanded. See the png_set_expand(), you must indicate whether the background needs to be
function definition in png.h for more details. expanded. See the function definition in png.h for more details.
png_color_16 my_background; png_color_16 my_background;
@ -275,12 +270,12 @@ function definition in png.h for more details.
png_set_background(png_ptr, &my_background, png_set_background(png_ptr, &my_background,
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
This handles gamma transformations of the data. Pass both the file The following code handles gamma transformations of the data. Pass
gamma and the desired screen gamma. If the file does not have a both the file gamma and the desired screen gamma. If the file does
gamma value, you can pass one anyway if you wish. Note that file not have a gamma value, you can pass one anyway if you wish. Note
gammas are inverted from screen gammas. See the discussions on that file gammas are inverted from screen gammas. See the discussions
gamma in the PNG specification for more information. It is strongly on gamma in the PNG specification for more information. It is
recommended that viewers support gamma correction. strongly recommended that viewers support gamma correction.
if (info_ptr->valid & PNG_INFO_gAMA) if (info_ptr->valid & PNG_INFO_gAMA)
png_set_gamma(png_ptr, screen_gamma, info_ptr->gamma); png_set_gamma(png_ptr, screen_gamma, info_ptr->gamma);
@ -293,42 +288,46 @@ PNG can have files with 16 bits per channel. If you only can handle
if (info_ptr->bit_depth == 16) if (info_ptr->bit_depth == 16)
png_set_strip_16(png_ptr); png_set_strip_16(png_ptr);
If you need to reduce an rgb file to a paletted file, or if a If you need to reduce an rgb file to a paletted file, or if a paletted
paletted file has more entries then will fit on your screen, file has more entries then will fit on your screen, png_set_dither()
png_set_dither() will do that. Note that this is a simple match will do that. Note that this is a simple match dither that merely
dither, that merely finds the closest color available. This should finds the closest color available. This should work fairly well with
work fairly well with optimized palettes, and fairly badly with linear optimized palettes, and fairly badly with linear color cubes. If you
color cubes. If you pass a palette that is larger then pass a palette that is larger then maximum_colors, the file will
maximum_colors, the file will reduce the number of colors in the reduce the number of colors in the palette so it will fit into
palette so it will fit into maximum_colors. If there is a histogram, maximum_colors. If there is a histogram, it will use it to make
it will use it to make intelligent choices when reducing the palette. intelligent choices when reducing the palette. If there is no
If there is no histogram, it may not do as good a job. histogram, it may not do as good a job.
This function will be rewritten and/or replaced in libpng 0.9, which It should be noted that this function will be rewritten and/or
will have full two pass dithering with optimized palettes. replaced in libpng 0.9, which will have full two pass dithering with
optimized palettes.
if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
{ {
if (info_ptr->valid & PNG_INFO_PLTE) if (info_ptr->valid & PNG_INFO_PLTE)
{
png_set_dither(png_ptr, info_ptr->palette, png_set_dither(png_ptr, info_ptr->palette,
info_ptr->num_palette, max_screen_colors, info_ptr->num_palette, max_screen_colors,
info_ptr->histogram); info_ptr->histogram, 1);
}
else else
{ {
png_color std_color_cube[MAX_SCREEN_COLORS] = png_color std_color_cube[MAX_SCREEN_COLORS] =
{ ... colors ... }; { ... colors ... };
png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS, png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS,
MAX_SCREEN_COLORS, NULL); MAX_SCREEN_COLORS, NULL,0);
} }
} }
PNG files describe monocrome as black is zero and white is one. The PNG files describe monochrome as black being zero and white being one.
following code will reverse this (make black be one and white be zero): The following code will reverse this (make black be one and white be
zero):
if (info_ptr->bit_depth == 1 && if (info_ptr->bit_depth == 1 &&
info_ptr->color_type == PNG_COLOR_GRAY) info_ptr->color_type == PNG_COLOR_GRAY)
png_set_invert(png_ptr); png_set_invert_mono(png_ptr);
PNG files have possible bit depths of 1, 2, 4, 8, and 16. However, PNG files have possible bit depths of 1, 2, 4, 8, and 16. However,
they also provide a way to describe the true bit depth of the image. they also provide a way to describe the true bit depth of the image.
@ -428,43 +427,43 @@ where row_pointers is:
You can point to void or char or whatever you use for pixels. You can point to void or char or whatever you use for pixels.
If you don't want to read the whole image in at once, you can If you don't want to read int the whole image at once, you can
use png_read_rows() instead. If there is no interlacing (check use png_read_rows() instead. If there is no interlacing (check
info_ptr->interlace_type), this is simple: info_ptr->interlace_type), this is simple:
png_read_rows(png_ptr, row_pointers, NULL, number_of_rows); png_read_rows(png_ptr, row_pointers, NULL, number_of_rows);
row_pointers is the same as in the png_read_image() call. where row_pointers is the same as in the png_read_image() call.
If you are just calling one row at a time, you can do this for If you are doing this just one row at a time, you can do this with
row_pointers: row_pointers:
png_bytep row_pointers = row; png_bytep row_pointers = row;
png_read_rows(png_ptr, &row_pointers, NULL, 1); png_read_rows(png_ptr, &row_pointers, NULL, 1);
If the file is interlaced (info_ptr->interlace_type != 0), things get If the file is interlaced (info_ptr->interlace_type != 0), things get
a good deal harder. The only currently (as of 12/95) defined a good deal harder. The only currently (as of 1/96 -- PNG
interlacing scheme for PNG files (info_ptr->interlace_type == 1) is a Specification version 0.92) defined interlacing scheme for PNG files
complicated interlace scheme, known as Adam7, that breaks down an (info_ptr->interlace_type == 1) is a complicated interlace scheme,
image into seven smaller images of varying size. libpng will fill out known as Adam7, that breaks down an image into seven smaller images of
those images or it will give them to you "as is". If you want to fill varying size. libpng will fill out those images or it will give them
them out, there are two ways to do that. The one mentioned in the PNG to you "as is". If you want them filled out, there are two ways to
specification is to expand each pixel to cover those pixels that have do that. The one mentioned in the PNG specification is to expand each
not been read yet. This results in a blocky image for the first pass, pixel to cover those pixels that have not been read yet. This results
which gradually smoothes out as more pixels are read. The other in a blocky image for the first pass, which gradually smoothes out as
method is the "sparkle" method, where pixels are draw only in their more pixels are read. The other method is the "sparkle" method, where
final locations, with the rest of the image remaining whatever colors pixels are draw only in their final locations, with the rest of the
they were initialized to before the start of the read. The first image remaining whatever colors they were initialized to before the
method usually looks better, but tends to be slower, as there are more start of the read. The first method usually looks better, but tends
pixels to put in the rows. to be slower, as there are more pixels to put in the rows.
If you don't want libpng to handle the interlacing details, just If you don't want libpng to handle the interlacing details, just
call png_read_rows() the correct number of times to read in all call png_read_rows() the correct number of times to read in all
seven images. See the PNG specification for more details on the seven images. See the PNG specification for more details on the
interlacing scheme. interlacing scheme.
If you want libpng to expand the images, call this above: If you want libpng to expand the images, call this before calling
png_start_read_image() or png_read_update_info():
if (info_ptr->interlace_type) if (info_ptr->interlace_type)
number_passes = png_set_interlace_handling(png_ptr); number_passes = png_set_interlace_handling(png_ptr);
@ -521,7 +520,7 @@ callbacks when it has the info, a row, or the end of the image. You
set up these callbacks with png_set_progressive_read_fn(). You don't set up these callbacks with png_set_progressive_read_fn(). You don't
have to worry about the input/output functions of libpng, as you are have to worry about the input/output functions of libpng, as you are
giving the library the data directly in png_process_data(). I will giving the library the data directly in png_process_data(). I will
assume that you have read the second on reading PNG files above, assume that you have read the section on reading PNG files above,
so I will only highlight the differences (although I will show so I will only highlight the differences (although I will show
all of the code). all of the code).
@ -553,11 +552,13 @@ initialize_png_reader()
png_info_init(info_ptr); png_info_init(info_ptr);
png_read_init(png_ptr); png_read_init(png_ptr);
/* this one's new. You will need to provide all three /*
This one's new. You will need to provide all three
function callbacks, even if you aren't using them all. function callbacks, even if you aren't using them all.
You can use any void pointer as the user_ptr, and You can use any void pointer as the user_ptr, and
retrieve the pointer from inside the callbacks using retrieve the pointer from inside the callbacks using
the function png_get_progressive_ptr(png_ptr); */ the function png_get_progressive_ptr(png_ptr);
*/
png_set_progressive_read_fn(png_ptr, user_ptr, png_set_progressive_read_fn(png_ptr, user_ptr,
info_callback, row_callback, end_callback); info_callback, row_callback, end_callback);
@ -575,33 +576,39 @@ process_data(png_bytep buffer, png_uint_32 length)
return -1; return -1;
} }
/* this one's new also. Simply give it a chunk of data /*
from the file stream (in order, of course). On Segmented This one's new also. Simply give it a chunk of data
machines, don't give it any more then 64K. The library from the file stream (in order, of course). On machines
seems to run fine with sizes of 4K, although you can give with segmented memory models machines, don't give it any
it much less if necessary (I assume you can give it chunks more than 64K. The library seems to run fine with sizes
of 1 byte, but I haven't tried less then 256 bytes yet). of 4K. Although you can give it much less if necessary
When this function returns, you may want to display any (I assume you can give it chunks of 1 byte, I haven't
rows that were generated in the row callback. */ tried less then 256 bytes yet). When this function returns,
you may want to display any rows that were generated in the
row callback.
*/
png_process_data(png_ptr, info_ptr, buffer, length); png_process_data(png_ptr, info_ptr, buffer, length);
return 0; return 0;
} }
info_callback(png_structp png_ptr, png_infop info) info_callback(png_structp png_ptr, png_infop info)
{ {
do any setup here, including setting any of the transformations /*
Do any setup here, including setting any of the transformations
mentioned in the Reading PNG files section. For now, you _must_ mentioned in the Reading PNG files section. For now, you _must_
call either png_start_read_image() or png_read_update_info() call either png_start_read_image() or png_read_update_info()
after all the transformations are set (even if you don't set after all the transformations are set (even if you don't set
any). You may start getting rows before png_process_data() any). You may start getting rows before png_process_data()
returns, so this is your last chance to prepare for that. returns, so this is your last chance to prepare for that.
*/
} }
row_callback(png_structp png_ptr, png_bytep new_row, row_callback(png_structp png_ptr, png_bytep new_row,
png_uint_32 row_num, int pass) png_uint_32 row_num, int pass)
{ {
this function is called for every row in the image. If the /*
image is interlacing, and you turned on the interlace handler, This function is called for every row in the image. If the
image is interlaced, and you turned on the interlace handler,
this function will be called for every row in every pass. this function will be called for every row in every pass.
Some of these rows will not be changed from the previous pass. Some of these rows will not be changed from the previous pass.
When the row is not changed, the new_row variable will be NULL. When the row is not changed, the new_row variable will be NULL.
@ -619,16 +626,18 @@ row_callback(png_structp png_ptr, png_bytep new_row,
png_progressive_combine_row(png_ptr, old_row, new_row); png_progressive_combine_row(png_ptr, old_row, new_row);
where old_row is what was displayed for previous rows. Note where old_row is what was displayed for previous rows. Note
that the first pass (pass == 0 really) will completely cover that the first pass (pass == 0, really) will completely cover
the old row, so the rows do not have to be initialized. After the old row, so the rows do not have to be initialized. After
the first pass (and only for interlaced images), you will have the first pass (and only for interlaced images), you will have
to pass the current row, and the function will combine the to pass the current row, and the function will combine the
old row and the new row. old row and the new row.
*/
} }
end_callback(png_structp png_ptr, png_infop info) end_callback(png_structp png_ptr, png_infop info)
{ {
this function is called when the whole image has been read, /*
This function is called after the whole image has been read,
including any chunks after the image (up to and including including any chunks after the image (up to and including
the IEND). You will usually have the same info chunk as you the IEND). You will usually have the same info chunk as you
had in the header, although some data may have been added had in the header, although some data may have been added
@ -636,19 +645,32 @@ end_callback(png_structp png_ptr, png_infop info)
Most people won't do much here, perhaps setting a flag that Most people won't do much here, perhaps setting a flag that
marks the image as finished. marks the image as finished.
*/
} }
IV. Writing IV. Writing
Much of this is very similar to reading. However, everything of Much of this is very similar to reading. However, everything of
importance is repeated here, so you don't have to constantly look importance is repeated here, so you won't have to constantly look
back up in the reading section to understand writing. back up in the reading section to understand writing.
The first thing you need to do while writing a PNG file is to allocate You will want to do the I/O initialization before you get into libpng,
and initialize png_struct and png_info. As these are both large, you so if it doesn't work, you don't have much to undo. If you are not
may not want to store these on the stack, unless you have stack space using the standard I/O functions, you will need to replace them with
to spare. custom functions. See the discussion under Customizing libpng.
FILE *fp = fopen(file_name, "wb");
if (!fp)
{
return;
}
Next, png_struct and png_info need to be allocated and initialized.
As these are both large, you may not want to store these on the stack,
unless you have stack space to spare. Of course, you will want to
check if malloc returns NULL.
png_structp png_ptr = malloc(sizeof (png_struct)); png_structp png_ptr = malloc(sizeof (png_struct));
if (!png_ptr) if (!png_ptr)
@ -660,18 +682,6 @@ to spare.
return; return;
} }
You may also want to do any i/o initialization here, before
you get into libpng, so if it doesn't work, you don't have
much to undo.
FILE *fp = fopen(file_name, "wb");
if (!fp)
{
free(png_ptr);
free(info_ptr);
return;
}
After you have these structures, you will need to set up the After you have these structures, you will need to set up the
error handling. When libpng encounters an error, it expects to error handling. When libpng encounters an error, it expects to
longjmp back to your routine. Therefore, you will need to call longjmp back to your routine. Therefore, you will need to call
@ -694,7 +704,7 @@ section below for more information on the libpng error handling.
return; return;
} }
Next, you will need to call png_info_init() and png_write_init(). Then, you will need to call png_info_init() and png_write_init().
These functions make sure all the fields are initialized to useful These functions make sure all the fields are initialized to useful
values, and, in the case of png_write_init(), allocate any memory values, and, in the case of png_write_init(), allocate any memory
needed for internal uses. Do png_info_init() first, so if needed for internal uses. Do png_info_init() first, so if
@ -704,12 +714,12 @@ don't free random memory pointers, which would be bad.
png_info_init(info_ptr); png_info_init(info_ptr);
png_write_init(png_ptr); png_write_init(png_ptr);
Now you need to set up the input code. The default for libpng is Now you need to set up the input code. The default for libpng is to
to use the C function fwrite(). If you use this, you will need to use the C function fwrite(). If you use this, you will need to pass a
pass a valid FILE * in the function png_init_io(). Be sure that valid FILE * in the function png_init_io(). Be sure that the file is
the file is opened in binary mode. If you wish to handle writing opened in binary mode. Again, if you wish to handle writing data in
data in another way, see the discussion on png i/o handling in the another way, see the discussion on libpng I/O handling in the Customizing
Customizing Libpng section below. Libpng section below.
png_init_io(png_ptr, fp); png_init_io(png_ptr, fp);
@ -733,10 +743,11 @@ See the compression library for more details.
png_set_compression_window_bits(png_ptr, 15); png_set_compression_window_bits(png_ptr, 15);
png_set_compression_method(png_ptr, 8); png_set_compression_method(png_ptr, 8);
You now need to fill in the png_info structure with all the data You now need to fill in the png_info structure with all the data you
you wish to write before the actual image. Note that the only thing wish to write before the actual image. Note that the only thing you
you are allowed to write after the image is the text chunks and the are allowed to write after the image is the text chunks and the time
time chunk. See png_write_end() for more information on that. If you chunk (as of PNG Specification 0.92, 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. If you want to wish to write them before the image, fill them in now. If you want to
wait until after the data, don't fill them until png_write_end(). For wait until after the data, don't fill them until png_write_end(). For
all the fields in png_info, see png.h. For explanations of what the all the fields in png_info, see png.h. For explanations of what the
@ -754,18 +765,17 @@ Some of the more important parts of the png_info are:
file. Note that if you are writing a file. Note that if you are writing a
PNG_COLOR_TYPE_PALETTE file, the PLTE chunk is not PNG_COLOR_TYPE_PALETTE file, the PLTE chunk is not
optional, but must still be marked for writing. To optional, but must still be marked for writing. To
mark chunks for writing, OR valid with the appropriate mark chunks for writing, OR valid with the
PNG_INFO_<chunk name> define. appropriate PNG_INFO_<chunk name> define.
palette - the palette for the file palette - the palette for the file
num_palette - number of entries in the palette num_palette - number of entries in the palette
gamma - the gamma the file is written at gamma - the gamma the file is written at
sig_bit - the number of significant bits sig_bit - the number of significant bits for the gray, red,
for the gray, red, green, and blue channels, whichever are green, and blue channels, whichever are appropriate
appropriate for the given color type. for the given color type.
sig_bit_number - number of channels
trans_values - transparent pixel for non-paletted images trans_values - transparent pixel for non-paletted images
trans - array of transparent entries for paletted images trans - array of transparent entries for paletted images
number_trans - number of transparent entries num_trans - number of transparent entries
hist - histogram of palette hist - histogram of palette
text - text comments in the file. text - text comments in the file.
num_text - number of comments num_text - number of comments
@ -836,12 +846,12 @@ image data. You do this with a call to png_write_info().
After you've read the file information, you can set up the library to After you've read the file information, you can set up the library to
handle any special transformations of the image data. The various handle any special transformations of the image data. The various
ways to transform the data will be described in the order that they ways to transform the data will be described in the order that they
occur. This is important, as some of these change the color type should occur. This is important, as some of these change the color
and bit depth of the data, and some others only work on certain type and/or bit depth of the data, and some others only work on
color types and bit depths. Even though each transformation should certain color types and bit depths. Even though each transformation
check to see if it has data that it can do somthing with, you should checks to see if it has data that it can do somthing with, you should
make sure to only enable a transformation if it will be valid for make sure to only enable a transformation if it will be valid for the
the data. For example, don't swap red and blue on grayscale data. data. For example, don't swap red and blue on grayscale data.
PNG files store rgb pixels packed into 3 bytes. This code tells PNG files store rgb pixels packed into 3 bytes. This code tells
the library to use 4 bytes per pixel the library to use 4 bytes per pixel
@ -865,10 +875,10 @@ this will scale the values to appear to be the correct bit depth.
Make sure you write a sBIT chunk when you do this, so others, if Make sure you write a sBIT chunk when you do this, so others, if
they want, can reduce the values down to their true depth. they want, can reduce the values down to their true depth.
/* do this before png_write_info() */ /* Do this before png_write_info() */
info_ptr->valid |= PNG_INFO_sBIT; info_ptr->valid |= PNG_INFO_sBIT;
/* note that you can cheat and set all the values of /* Note that you can cheat and set all the values of
sig_bit to true_bit_depth if you want */ sig_bit to true_bit_depth if you want */
if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
{ {
@ -889,19 +899,19 @@ they want, can reduce the values down to their true depth.
png_set_shift(png_ptr, &(info_ptr->sig_bit)); png_set_shift(png_ptr, &(info_ptr->sig_bit));
PNG files store 16 bit pixels in network byte order (big-endian, PNG files store 16 bit pixels in network byte order (big-endian,
ie. most significant bits first). This code would be used to supply ie. most significant bits first). This code would be used if they are
them the other way (little-endian, ie. least significant bits first, supplied the other way (little-endian, ie. least significant bits
eg. the way PCs store them): first, eg. the way PCs store them):
png_set_swap(png_ptr); png_set_swap(png_ptr);
PNG files store 3 color pixels in red, green, blue order. This code PNG files store 3 color pixels in red, green, blue order. This code
would be used to supply the pixels as blue, green, red: would be used if they are supplied as blue, green, red:
png_set_bgr(png_ptr); png_set_bgr(png_ptr);
PNG files describe monochrome as black being zero and white being PNG files describe monochrome as black being zero and white being
one. This code would be used to supply the pixels with this reversed one. This code would be used if the pixels are supplied with this reversed
(black being one and white being zero): (black being one and white being zero):
png_set_invert(png_ptr); png_set_invert(png_ptr);
@ -930,7 +940,7 @@ this is simple:
row_pointers is the same as in the png_write_image() call. row_pointers is the same as in the png_write_image() call.
If you are just calling one row at a time, you can do this for If you are just writing one row at a time, you can do this with
row_pointers: row_pointers:
png_bytep row_pointers = row; png_bytep row_pointers = row;
@ -938,12 +948,13 @@ row_pointers:
png_write_rows(png_ptr, &row_pointers, 1); png_write_rows(png_ptr, &row_pointers, 1);
When the file is interlaced, things can get a good deal more When the file is interlaced, things can get a good deal more
complicated. The only currently (as of 12/95) defined interlacing complicated. The only currently (as of 1/96 -- PNG Specification
scheme for PNG files is a compilcated interlace scheme, known as version 0.92) defined interlacing scheme for PNG files is a
Adam7, that breaks down an image into seven smaller images of varying compilcated interlace scheme, known as Adam7, that breaks down an
size. libpng will build these images for you, or you can do them image into seven smaller images of varying size. libpng will build
yourself. If you want to build them yourself, see the PNG these images for you, or you can do them yourself. If you want to
specification for details of which pixels to write when. build them yourself, see the PNG specification for details of which
pixels to write when.
If you don't want libpng to handle the interlacing details, just If you don't want libpng to handle the interlacing details, just
call png_write_rows() the correct number of times to write all call png_write_rows() the correct number of times to write all
@ -991,10 +1002,10 @@ standard things like memory allocation, input/output, and error handling.
The second deals with more complicated things like adding new chunks, The second deals with more complicated things like adding new chunks,
adding new transformations, and generally changing how libpng works. adding new transformations, and generally changing how libpng works.
All of the memory allocation, input/output, and error handling in libpng All of the memory allocation, input/output, and error handling in
goes through callbacks which are user setable. The default routines libpng goes through callbacks which are user setable. The default
are in pngerror.c, pngmem.c, and pngio.c. To change these functions, routines are in pngmem.c, pngio.c, and pngerror.c respectively. To
call the approprate _fn function. change these functions, call the approprate _fn function.
Memory allocation is done through the functions png_large_malloc(), Memory allocation is done through the functions png_large_malloc(),
png_malloc(), png_realloc(), png_large_free(), and png_free(). png_malloc(), png_realloc(), png_large_free(), and png_free().
@ -1066,16 +1077,16 @@ If you need to read or write custom chunks, you will need to get deeper
into the libpng code. First, read the PNG specification, and have into the libpng code. First, read the PNG specification, and have
a first level of understanding of how it works. Pay particular a first level of understanding of how it works. Pay particular
attention to the sections that describe chunk names, and look attention to the sections that describe chunk names, and look
at how other chunks were designed, so you can do things similar. at how other chunks were designed, so you can do things similarly.
Second, check out the sections of libpng that read and write chunks. Second, check out the sections of libpng that read and write chunks.
Try to find a chunk that is similar to yours, and copy off of it. Try to find a chunk that is similar to yours and copy off of it.
More details can be found in the comments inside the code. More details can be found in the comments inside the code.
If you wish to write your own transformation for the data, look If you wish to write your own transformation for the data, look
through the part of the code that does the transformations, and check through the part of the code that does the transformations, and check
out some of the more simple ones to get an idea of how they work. Try out some of the simpler ones to get an idea of how they work. Try to
to find a similar transformation to the one you want to add, and copy find a similar transformation to the one you want to add and copy off
off of it. More details can be found in the comments inside the code of it. More details can be found in the comments inside the code
itself. itself.
Configuring for 16 bit platforms: Configuring for 16 bit platforms:

View File

@ -2,15 +2,15 @@
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
CC=gcc CC=cc
CFLAGS=-I../zlib -O2 -Wall CFLAGS=-I../zlib -O
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
RANLIB=ranlib #RANLIB=ranlib
#RANLIB=echo RANLIB=echo
# where make install puts libpng.a and png.h # where make install puts libpng.a and png.h
prefix=/home/munet-d2/sun/local prefix=/usr/local
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \ OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \ pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
@ -31,12 +31,11 @@ test: pngtest
install: libpng.a install: libpng.a
-@mkdir $(prefix)/include -@mkdir $(prefix)/include
-@mkdir $(prefix)/lib -@mkdir $(prefix)/lib
cp png.h pngconf.h $(prefix)/include cp png.h $(prefix)/include
rcp png.h pngconf.h vlsi:bin/include cp pngconf.h $(prefix)/include
chmod 644 $(prefix)/include/png.h chmod 644 $(prefix)/include/png.h
chmod 644 $(prefix)/include/pngconf.h chmod 644 $(prefix)/include/pngconf.h
cp libpng.a $(prefix)/lib cp libpng.a $(prefix)/lib
rcp libpng.a vlsi:bin/lib
chmod 644 $(prefix)/lib/libpng.a chmod 644 $(prefix)/lib/libpng.a
clean: clean:

42
makefile.ama Normal file
View File

@ -0,0 +1,42 @@
# Commodore Amiga Makefile
# makefile for libpng and SAS C V6.55 compiler
# Copyright (C) 1995 Wolf Faust
#compiler
CC=sc
#compiler flags
# 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
#linker flags
LDFLAGS= SD ND BATCH
#link libs
LDLIBS= libpng.lib libgz.lib LIB:scm.lib LIB:sc.lib Lib:amiga.lib
# linker
LN= slink
# file deletion command
RM= delete quiet
# library (.lib) file creation command
AR= oml
# make directory command
MKDIR= makedir
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o pngpread.o \
pngread.o pngerror.o pngwrite.o pngrtran.o pngwtran.o pngio.o pngmem.o
all: libpng.lib pngtest
libpng.lib: $(OBJS)
-$(RM) libpng.lib
$(AR) libpng.lib r $(OBJS)
pngtest: pngtest.o libpng.lib
$(LN) <WITH <
$(LDFLAGS)
TO pngtest
FROM LIB:c.o pngtest.o
LIB $(LDLIBS)
<

31
makefile.atr Normal file
View File

@ -0,0 +1,31 @@
# makefile for libpng
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
# modified for LC56/ATARI assumes libz.lib is in same dir and uses default
# rules for library management
#
CFLAGS=-I..\zlib -O
LBR = png.lib
LDFLAGS=-lpng -lz -lm
# where make install puts libpng.a and png.h
OBJS = $(LBR)(png.o) $(LBR)(pngrcb.o) $(LBR)(pngrutil.o)\
$(LBR)(pngtrans.o) $(LBR)(pngwutil.o)\
$(LBR)(pngread.o) $(LBR)(pngerror.o) $(LBR)(pngwrite.o)\
$(LBR)(pngrtran.o) $(LBR)(pngwtran.o)\
$(LBR)(pngmem.o) $(LBR)(pngio.o) $(LBR)(pngpread.o)
all: $(LBR) pngtest.ttp
$(LBR): $(OBJS)
pngtest.ttp: pngtest.o $(LBR)
$(CC) $(CFLAGS) $(LDFLAGS) -o$@ pngtest.o
install: libpng.a
-@mkdir $(prefix)/include
-@mkdir $(prefix)/lib
cp png.h $(prefix)/include
cp pngconf.h $(prefix)/include
chmod 644 $(prefix)/include/p

165
makefile.bor Normal file
View File

@ -0,0 +1,165 @@
# Makefile for libpng
# Borland C++ 4.5 (Note: All modules are compiled in C mode)
# Will work with C++ 4.02 also
# To build the library, do:
# "make -fmakefile.bor -DMODEL=m"
# or: "make -fmakefile.bor -DMODEL=l"
#
# ------------- Borland C++ 4.5 -------------
### Absolutely necessary for this makefile to work
.AUTODEPEND
## Useful user options
# Usually defined in builtins.mak or the environment
# Currently unused.
!ifndef BCROOT
BCROOT=N:\BC45
!endif
# Where zlib.h and zconf.h and zlib.lib are
ZLIB_PATH=..\zlib
!ifndef MODEL
MODEL=l
!endif
#TARGET_CPU=3
# 2 = 286, 3 = 386, etc.
!ifndef TARGET_CPU
TARGET_CPU=2
!endif
# Use this if you don't want Borland's fancy exception handling.
NOEHLIB=noeh$(MODEL).lib
!ifdef DEBUG
CDEBUG=-v
LDEBUG=-v
!else
CDEBUG=
LDEBUG=
!endif
# STACKOFLOW=1
!ifdef STACKOFLOW
CDEBUG=$(CDEBUG) -N
LDEBUG=$(LDEBUG) -N
!endif
## Compiler, linker, and lib stuff
CC=bcc
LD=bcc
LIB=tlib
MODELARG=-m$(MODEL)
# -X- turns on dependency generation in the object file
# -w sets all warnings on
# -O2 optimize for speed
# -Z global optimization
CFLAGS=-O2 -Z -X- -w -I$(ZLIB_PATH) -$(TARGET_CPU) $(MODELARG) $(CDEBUG)
# -M generate map file
LDFLAGS=-M $(LDEBUG)
O=obj
## variables
OBJS = \
png.$(O) \
pngrcb.$(O) \
pngrutil.$(O) \
pngtrans.$(O) \
pngwutil.$(O) \
pngmem.$(O) \
pngread.$(O) \
pngpread.$(O) \
pngerror.$(O) \
pngwrite.$(O) \
pngrtran.$(O) \
pngwtran.$(O) \
pngzlib.$(O) \
pngio.$(O)
LIBOBJS = \
+png.$(O) \
+pngrcb.$(O) \
+pngrutil.$(O) \
+pngtrans.$(O) \
+pngwutil.$(O) \
+pngmem.$(O) \
+pngpread.$(O) \
+pngread.$(O) \
+pngerror.$(O) \
+pngwrite.$(O) \
+pngrtran.$(O) \
+pngwtran.$(O) \
+pngzlib.$(O) \
+pngio.$(O)
LIBNAME=libpng$(MODEL).lib
## Implicit rules
# Braces let make "batch" calls to the compiler,
# 2 calls instead of 12; space is important.
.c.obj:
$(CC) $(CFLAGS) -c {$*.c }
.c.exe:
$(CC) $(CFLAGS) $(LDFLAGS) $*.c
## Major targets
libpng: $(LIBNAME)
pngtest: pngtest$(MODEL).exe
test:
pngtest$(MODEL)
## Minor Targets
png.obj: png.c
pngrcb.obj: pngrcb.c
pngread.obj: pngread.c
pngpread.obj: pngpread.c
pngrtran.obj: pngrtran.c
pngrutil.obj: pngrutil.c
pngerror.obj: pngerror.c
pngmem.obj: pngmem.c
pngio.obj: pngio.c
pngtrans.obj: pngtrans.c
pngwrite.obj: pngwrite.c
pngwtran.obj: pngwtran.c
pngwutil.obj: pngwutil.c
pngzlib.obj: pngzlib.c
$(LIBNAME): $(OBJS)
-del $(LIBNAME)
$(LIB) $(LIBNAME) @&&|
$(LIBOBJS), libpng$(MODEL)
|
pngtest$(MODEL).obj: pngtest.c
$(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c
pngtest$(MODEL).exe: pngtest$(MODEL).obj
$(CC) $(MODELARG) $(LDFLAGS) -L$(ZLIB_PATH) pngtest$(MODEL).obj $(LIBNAME) zlib$(MODEL).lib $(NOEHLIB)
# Clean up anything else you want
clean:
-del *.obj
-del *.lib
-del *.lst
# End of makefile for libpng

View File

@ -9,7 +9,7 @@ LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
RANLIB=ranlib RANLIB=ranlib
#RANLIB=echo #RANLIB=echo
PNGVER = 0.87 PNGVER = 0.86
# where make install puts libpng.a, libpng.so*, and png.h # where make install puts libpng.a, libpng.so*, and png.h
prefix=/usr/local prefix=/usr/local

50
makefile.gcc Normal file
View File

@ -0,0 +1,50 @@
# gcc/DOS makefile for libpng
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
CC=gcc
CFLAGS=-I../zlib -O
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
RANLIB=ranlib
# where make install puts libpng.a and png.h
#prefix=/usr/local
prefix=.
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
pngtest: pngtest.o libpng.a
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
coff2exe pngtest
test: pngtest
./pngtest
clean:
rm -f *.o libpng.a pngtest pngout.png
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngrcb.o: png.h pngconf.h
pngread.o: png.h pngconf.h
pngpread.o: png.h pngconf.h
pngrtran.o: png.h pngconf.h
pngrutil.o: png.h pngconf.h
pngtest.o: png.h pngconf.h
pngtrans.o: png.h pngconf.h
pngwrite.o: png.h pngconf.h
pngwtran.o: png.h pngconf.h
pngwutil.o: png.h pngconf.h

71
makefile.knr Normal file
View File

@ -0,0 +1,71 @@
# makefile for libpng
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
CC=cc
CFLAGS=-I../zlib -O
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
# flags for ansi2knr
ANSI2KNRFLAGS=
RANLIB=ranlib
#RANLIB=echo
# where make install puts libpng.a and png.h
prefix=/usr/local
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
pngmem.o pngerror.o pngpread.o
all: ansi2knr libpng.a pngtest
# general rule to allow ansi2knr to work
.c.o:
./ansi2knr $*.c T$*.c
$(CC) $(CFLAGS) -c T$*.c
rm -f T$*.c $*.o
mv T$*.o $*.o
ansi2knr: ansi2knr.c
$(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c
libpng.a: ansi2knr $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
pngtest: pngtest.o libpng.a ansi2knr
cc -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
test: 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
clean:
rm -f *.o libpng.a pngtest pngout.png ansi2knr
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngrcb.o: png.h pngconf.h
pngread.o: png.h pngconf.h
pngpread.o: png.h pngconf.h
pngrtran.o: png.h pngconf.h
pngrutil.o: png.h pngconf.h
pngtest.o: png.h pngconf.h
pngtrans.o: png.h pngconf.h
pngwrite.o: png.h pngconf.h
pngwtran.o: png.h pngconf.h
pngwutil.o: png.h pngconf.h

60
makefile.mip Normal file
View File

@ -0,0 +1,60 @@
# makefile for libpng
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
CC=cc
CFLAGS=-I../zlib -O -systype sysv -DSYSV -w -Dmips
#CFLAGS=-O
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
#RANLIB=ranlib
RANLIB=echo
# where make install puts libpng.a and png.h
prefix=/usr/local
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
pngtest: pngtest.o libpng.a
cc -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
test: 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
clean:
rm -f *.o libpng.a pngtest pngout.png
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngrcb.o: png.h pngconf.h
pngread.o: png.h pngconf.h
pngpread.o: png.h pngconf.h
pngrtran.o: png.h pngconf.h
pngrutil.o: png.h pngconf.h
pngtest.o: png.h pngconf.h
pngtrans.o: png.h pngconf.h
pngwrite.o: png.h pngconf.h
pngwtran.o: png.h pngconf.h
pngwutil.o: png.h pngconf.h

78
makefile.msc Normal file
View File

@ -0,0 +1,78 @@
# makefile for libpng
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
# ------------- Microsoft C 5.1 and later -------------
MODEL=-AL
CFLAGS=-Oait -Gs -nologo -W2 $(MODEL) -I..\zlib
#-Ox generates bad code with MSC 5.1
CC=cl
LD=link
LDFLAGS=/e/st:0x1500/noe
O=.obj
#uncomment next to put error messages in a file
ERRFILE= >> pngerrs
# variables
OBJS1 = png$(O) pngrcb$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) pngmem$(O) pngpread$(O)
OBJS2 = pngread$(O) pngerror$(O) pngwrite$(O) pngrtran$(O) pngwtran$(O) pngio$(O)
all: libpng.lib
png$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngrcb$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngread$(O): png.h pngconf.h
$(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)
pngrutil$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngerror$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngmem$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngio$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngtest$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngtrans$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwrite$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwtran$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwutil$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
libpng.lib: $(OBJS1) $(OBJS2)
del libpng.lib
lib libpng $(OBJS1);
lib libpng $(OBJS2);
pngtest.exe: pngtest.obj libpng.lib
$(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ;
test: pngtest.exe
pngtest
# End of makefile for libpng

60
makefile.std Normal file
View File

@ -0,0 +1,60 @@
# makefile for libpng
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
CC=cc
CFLAGS=-I../zlib -O
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
#RANLIB=ranlib
RANLIB=echo
# where make install puts libpng.a and png.h
prefix=/usr/local
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
pngtest: pngtest.o libpng.a
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
test: 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
clean:
rm -f *.o libpng.a pngtest pngout.png
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngrcb.o: png.h pngconf.h
pngread.o: png.h pngconf.h
pngrtran.o: png.h pngconf.h
pngrutil.o: png.h pngconf.h
pngtest.o: png.h pngconf.h
pngtrans.o: png.h pngconf.h
pngwrite.o: png.h pngconf.h
pngwtran.o: png.h pngconf.h
pngwutil.o: png.h pngconf.h
pngpread.o: png.h pngconf.h

69
makefile.tc Normal file
View File

@ -0,0 +1,69 @@
# Makefile for libpng
# TurboC++ 3.0 (Note: All modules are compiled in C mode)
# To use, do "make -fmakefile.tc"
# ------------- Turbo C++ 3.0 -------------
MODEL=-ml
CFLAGS=-O2 -Z $(MODEL) -I..\zlib
CC=tcc
LD=tcc
LIB=tlib
LDFLAGS=$(MODEL)
O=.obj
# variables
OBJS1 = png$(O) pngrcb$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) pngmem$(O) pngpread$(O)
OBJS2 = pngread$(O) pngerror$(O) pngwrite$(O) pngrtran$(O) pngwtran$(O) pngio$(O)
OBJSL1 = +png$(O) +pngrcb$(O) +pngrutil$(O) +pngtrans$(O) +pngwutil$(O) +pngmem$(O) +pngpread$(O)
OBJSL2 = +pngread$(O) +pngerror$(O) +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) pngio$(O)
all: libpng.lib
png$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngrcb$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngread$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngpread$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngrtran$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngrutil$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngerror$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngmem$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngio$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngtest$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngtrans$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngwrite$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngwtran$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngwutil$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
libpng.lib: $(OBJS1) $(OBJS2)
$(LIB) libpng +$(OBJSL1)
$(LIB) libpng +$(OBJSL2)
# End of makefile for libpng

121
makevms.com Normal file
View File

@ -0,0 +1,121 @@
$! make libpng under VMS
$!
$!
$! Look for the compiler used
$!
$ zlibsrc = "[-.zlib]"
$ ccopt="/include=''zlibsrc'"
$ if f$getsyi("HW_MODEL").ge.1024
$ then
$ ccopt = "/prefix=all"+ccopt
$ comp = "__decc__=1"
$ if f$trnlnm("SYS").eqs."" then define sys sys$library:
$ else
$ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs.""
$ then
$ if f$trnlnm("SYS").eqs."" then define sys sys$library:
$ if f$search("SYS$SYSTEM:VAXC.EXE").eqs.""
$ then
$ comp = "__gcc__=1"
$ CC :== GCC
$ else
$ comp = "__vaxc__=1"
$ endif
$ else
$ if f$trnlnm("SYS").eqs."" then define sys decc$library_include:
$ ccopt = "/decc/prefix=all"+ccopt
$ comp = "__decc__=1"
$ endif
$ endif
$!
$! Build the thing plain or with mms
$!
$ write sys$output "Compiling Libpng sources ..."
$ if f$search("SYS$SYSTEM:MMS.EXE").eqs.""
$ then
$ dele pngtest.obj;*
$ CALL MAKE png.OBJ "cc ''CCOPT' png" -
png.c png.h pngconf.h
$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" -
pngpread.c png.h pngconf.h
$ CALL MAKE pngrcb.OBJ "cc ''CCOPT' pngrcb" -
pngrcb.c png.h pngconf.h
$ CALL MAKE pngread.OBJ "cc ''CCOPT' pngread" -
pngread.c png.h pngconf.h
$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" -
pngpread.c png.h pngconf.h
$ CALL MAKE pngrtran.OBJ "cc ''CCOPT' pngrtran" -
pngrtran.c png.h pngconf.h
$ CALL MAKE pngrutil.OBJ "cc ''CCOPT' pngrutil" -
pngrutil.c png.h pngconf.h
$ CALL MAKE pngerror.OBJ "cc ''CCOPT' pngerror" -
pngerror.c png.h pngconf.h
$ CALL MAKE pngmem.OBJ "cc ''CCOPT' pngmem" -
pngmem.c png.h pngconf.h
$ CALL MAKE pngio.OBJ "cc ''CCOPT' pngio" -
pngio.c png.h pngconf.h
$ CALL MAKE pngtrans.OBJ "cc ''CCOPT' pngtrans" -
pngtrans.c png.h pngconf.h
$ CALL MAKE pngwrite.OBJ "cc ''CCOPT' pngwrite" -
pngwrite.c png.h pngconf.h
$ CALL MAKE pngwtran.OBJ "cc ''CCOPT' pngwtran" -
pngwtran.c png.h pngconf.h
$ CALL MAKE pngwutil.OBJ "cc ''CCOPT' pngwutil" -
pngwutil.c png.h pngconf.h
$ write sys$output "Building Libpng ..."
$ CALL MAKE libpng.OLB "lib/crea libpng.olb *.obj" *.OBJ
$ write sys$output "Building pngtest..."
$ CALL MAKE pngtest.OBJ "cc ''CCOPT' pngtest" -
pngtest.c png.h pngconf.h
$ call make pngtest.exe -
"LINK pngtest,libpng.olb/lib,''zlibsrc'libgz.olb/lib" -
pngtest.obj libpng.olb
$ write sys$output "Testing Libpng..."
$ run pngtest
$ else
$ mms/macro=('comp',zlibsrc='zlibsrc')
$ endif
$ write sys$output "Libpng build completed"
$ exit
$!
$!
$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES
$ V = 'F$Verify(0)
$! P1 = What we are trying to make
$! P2 = Command to make it
$! P3 - P8 What it depends on
$
$ If F$Search(P1) .Eqs. "" Then Goto Makeit
$ Time = F$CvTime(F$File(P1,"RDT"))
$arg=3
$Loop:
$ Argument = P'arg
$ If Argument .Eqs. "" Then Goto Exit
$ El=0
$Loop2:
$ File = F$Element(El," ",Argument)
$ If File .Eqs. " " Then Goto Endl
$ AFile = ""
$Loop3:
$ OFile = AFile
$ AFile = F$Search(File)
$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl
$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit
$ Goto Loop3
$NextEL:
$ El = El + 1
$ Goto Loop2
$EndL:
$ arg=arg+1
$ If arg .Le. 8 Then Goto Loop
$ Goto Exit
$
$Makeit:
$ VV=F$VERIFY(0)
$ write sys$output P2
$ 'P2
$ VV='F$Verify(VV)
$Exit:
$ If V Then Set Verify
$ENDSUBROUTINE

6
png.c
View File

@ -1,10 +1,10 @@
/* png.c - location for general purpose png functions /* png.c - location for general purpose png functions
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@ -13,7 +13,7 @@
/* version information for c files. This better match the version /* version information for c files. This better match the version
string defined in png.h */ string defined in png.h */
char png_libpng_ver[] = "0.87"; char png_libpng_ver[] = "0.88";
/* place to hold the signiture string for a png file. */ /* place to hold the signiture string for a png file. */
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};

12
png.h
View File

@ -1,8 +1,8 @@
/* png.h - header file for png reference library /* png.h - header file for png reference library
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
Jan 15, 1996 Jan 25, 1996
Note: This is a beta version. It reads and writes valid files Note: This is a beta version. It reads and writes valid files
on the platforms I have, but it has had limited portability on the platforms I have, but it has had limited portability
@ -27,7 +27,7 @@
with testing, bug fixes, and patience. You know who you are. This with testing, bug fixes, and patience. You know who you are. This
wouldn't have been possible without all of you. wouldn't have been possible without all of you.
Thanks to Frank J. T. Wojcik for reviewing the documentation Thanks to Frank J. T. Wojcik for helping with the documentation
The PNG Reference Library is supplied "AS IS". The Contributing Authors The PNG Reference Library is supplied "AS IS". The Contributing Authors
and Group 42, Inc. disclaim all warranties, expressed or implied, and Group 42, Inc. disclaim all warranties, expressed or implied,
@ -74,10 +74,10 @@
/* version information for png.h - this should match the version /* version information for png.h - this should match the version
number in png.c */ number in png.c */
#define PNG_LIBPNG_VER_STRING "0.87" #define PNG_LIBPNG_VER_STRING "0.88"
/* careful here. I wanted to use 087, but that would be octal. Version /* careful here. I wanted to use 088, but that would be octal. Version
1.0 will be 100 here, etc. */ 1.0 will be 100 here, etc. */
#define PNG_LIBPNG_VER 87 #define PNG_LIBPNG_VER 88
/* variables defined in png.c - only it needs to define PNG_NO_EXTERN */ /* variables defined in png.c - only it needs to define PNG_NO_EXTERN */
#ifndef PNG_NO_EXTERN #ifndef PNG_NO_EXTERN

View File

@ -54,7 +54,8 @@ version 0.8
changed external functions passing floats to doubles (k&r problems?) changed external functions passing floats to doubles (k&r problems?)
put all the configurable stuff in pngconf.h put all the configurable stuff in pngconf.h
enabled png_set_shift to work with paletted images on read enabled png_set_shift to work with paletted images on read
added png_read_update_info() - updates info structure with transformations added png_read_update_info() - updates info structure with
transformations
version 0.81 version 0.81
incorporated Tim Wegner's medium model code (thanks, Tim) incorporated Tim Wegner's medium model code (thanks, Tim)
version 0.85 version 0.85
@ -69,4 +70,7 @@ version 0.87
fixed medium model bugs fixed medium model bugs
fixed other bugs introduced in 0.85 and 0.86 fixed other bugs introduced in 0.85 and 0.86
added some minor documentation added some minor documentation
version 0.88
fixed progressive bugs
replaced tabs with spaces
cleaned up documentation

View File

@ -1,10 +1,10 @@
/* pngconf.c - machine configurable file for libpng /* pngconf.c - machine configurable file for libpng
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
*/ */
/* Any machine specific code is near the front of this file, so if you /* Any machine specific code is near the front of this file, so if you
@ -27,7 +27,7 @@
Unless this gets smaller then the size of a row (compressed), Unless this gets smaller then the size of a row (compressed),
it should not make much difference how big this is. */ it should not make much difference how big this is. */
#define PNG_ZBUF_SIZE 32768 #define PNG_ZBUF_SIZE 8192
/* While libpng currently uses zlib for it's compression, it has been designed /* While libpng currently uses zlib for it's compression, it has been designed
to stand on it's own. Towards this end, there are two defines that are to stand on it's own. Towards this end, there are two defines that are

View File

@ -1,10 +1,10 @@
/* pngerror.c - stub functions for i/o and memory allocation /* pngerror.c - stub functions for i/o and memory allocation
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
This file provides a location for all error handling. Users which This file provides a location for all error handling. Users which
need special error handling are expected to write replacement functions need special error handling are expected to write replacement functions

View File

@ -1,10 +1,10 @@
/* pngio.c - stub functions for i/o and memory allocation /* pngio.c - stub functions for i/o and memory allocation
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
This file provides a location for all input/output. Users which need This file provides a location for all input/output. Users which need
special handling are expected to write functions which have the same special handling are expected to write functions which have the same

View File

@ -1,10 +1,10 @@
/* pngmem.c - stub functions for memory allocation /* pngmem.c - stub functions for memory allocation
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
This file provides a location for all memory allocation. Users which This file provides a location for all memory allocation. Users which
need special memory handling are expected to modify the code in this file need special memory handling are expected to modify the code in this file

View File

@ -1,10 +1,10 @@
/* pngpread.c - read a png file in push mode /* pngpread.c - read a png file in push mode
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@ -55,6 +55,13 @@ png_process_some_data(png_structp png_ptr, png_infop info)
png_push_read_text(png_ptr, info); png_push_read_text(png_ptr, info);
break; break;
} }
#endif
#if defined(PNG_READ_zTXt_SUPPORTED)
case PNG_READ_zTXt_MODE:
{
png_push_read_ztxt(png_ptr, info);
break;
}
#endif #endif
case PNG_READ_END_MODE: case PNG_READ_END_MODE:
{ {
@ -173,7 +180,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info)
} }
if (png_ptr->mode != PNG_HAVE_IHDR) if (png_ptr->mode != PNG_HAVE_IHDR)
png_error(png_ptr, "Out of Place PLTE"); png_error(png_ptr, "Out of Place gAMA");
png_handle_gAMA(png_ptr, info, png_ptr->push_length); png_handle_gAMA(png_ptr, info, png_ptr->push_length);
png_push_check_crc(png_ptr); png_push_check_crc(png_ptr);
@ -396,8 +403,13 @@ png_push_skip(png_structp png_ptr)
png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_size -= save_size;
png_ptr->current_buffer_ptr += (png_size_t)save_size; png_ptr->current_buffer_ptr += (png_size_t)save_size;
} }
if (!png_ptr->skip_length && png_ptr->buffer_size >= 4) if (!png_ptr->skip_length)
{ {
if (png_ptr->buffer_size < 4)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_check_crc(png_ptr); png_push_check_crc(png_ptr);
png_ptr->process_mode = PNG_READ_CHUNK_MODE; png_ptr->process_mode = PNG_READ_CHUNK_MODE;
} }
@ -564,8 +576,14 @@ png_push_read_idat(png_structp png_ptr)
png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_size -= save_size;
png_ptr->current_buffer_ptr += (png_size_t)save_size; png_ptr->current_buffer_ptr += (png_size_t)save_size;
} }
if (!png_ptr->idat_size && png_ptr->buffer_size >= 4) if (!png_ptr->idat_size)
{ {
if (png_ptr->buffer_size < 4)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_check_crc(png_ptr); png_push_check_crc(png_ptr);
png_ptr->have_chunk_header = 0; png_ptr->have_chunk_header = 0;
} }
@ -861,11 +879,17 @@ png_push_read_text(png_structp png_ptr, png_infop info)
png_ptr->current_text_left -= text_size; png_ptr->current_text_left -= text_size;
png_ptr->current_text_ptr += (png_size_t)text_size; png_ptr->current_text_ptr += (png_size_t)text_size;
} }
if (!(png_ptr->current_text_left) && png_ptr->buffer_size >= 4) if (!(png_ptr->current_text_left))
{ {
png_charp text; png_charp text;
png_charp key; png_charp key;
if (png_ptr->buffer_size < 4)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_check_crc(png_ptr); png_push_check_crc(png_ptr);
key = png_ptr->current_text; key = png_ptr->current_text;
@ -879,8 +903,17 @@ png_push_read_text(png_structp png_ptr, png_infop info)
png_read_tEXt(png_ptr, info, key, text, png_read_tEXt(png_ptr, info, key, text,
png_ptr->current_text_size - (text - key)); png_ptr->current_text_size - (text - key));
if (png_ptr->mode == PNG_AT_LAST_IDAT ||
png_ptr->mode == PNG_AFTER_IDAT)
{
png_ptr->process_mode = PNG_READ_END_MODE;
}
else
{
png_ptr->process_mode = PNG_READ_CHUNK_MODE; png_ptr->process_mode = PNG_READ_CHUNK_MODE;
} }
}
} }
#endif #endif
@ -915,13 +948,19 @@ png_push_read_ztxt(png_structp png_ptr, png_infop info)
png_ptr->current_text_left -= text_size; png_ptr->current_text_left -= text_size;
png_ptr->current_text_ptr += (png_size_t)text_size; png_ptr->current_text_ptr += (png_size_t)text_size;
} }
if (!(png_ptr->current_text_left) && png_ptr->buffer_size >= 4) if (!(png_ptr->current_text_left))
{ {
png_charp text; png_charp text;
png_charp key; png_charp key;
int ret; int ret;
png_uint_32 text_size, key_size; png_uint_32 text_size, key_size;
if (png_ptr->buffer_size < 4)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_check_crc(png_ptr); png_push_check_crc(png_ptr);
key = png_ptr->current_text; key = png_ptr->current_text;
@ -1028,6 +1067,15 @@ png_push_read_ztxt(png_structp png_ptr, png_infop info)
text_size -= key_size; text_size -= key_size;
png_read_zTXt(png_ptr, info, key, text, text_size, 0); png_read_zTXt(png_ptr, info, key, text, text_size, 0);
if (png_ptr->mode == PNG_AT_LAST_IDAT ||
png_ptr->mode == PNG_AFTER_IDAT)
{
png_ptr->process_mode = PNG_READ_END_MODE;
}
else
{
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
}
} }
} }
#endif #endif
@ -1098,6 +1146,11 @@ png_push_read_end(png_structp png_ptr, png_infop info)
{ {
if (png_ptr->push_length) if (png_ptr->push_length)
png_error(png_ptr, "Invalid IEND chunk"); png_error(png_ptr, "Invalid IEND chunk");
if (png_ptr->buffer_size < 4)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_check_crc(png_ptr); png_push_check_crc(png_ptr);
png_ptr->mode = PNG_AFTER_IEND; png_ptr->mode = PNG_AFTER_IEND;
png_ptr->process_mode = PNG_READ_DONE_MODE; png_ptr->process_mode = PNG_READ_DONE_MODE;

View File

@ -1,9 +1,9 @@
/* pngrcb.c - callbacks while reading a png file /* pngrcb.c - callbacks while reading a png file
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL

View File

@ -1,10 +1,10 @@
/* pngread.c - read a png file /* pngread.c - read a png file
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL

View File

@ -1,10 +1,10 @@
/* pngrtran.c - transforms the data in a row for png readers /* pngrtran.c - transforms the data in a row for png readers
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL

View File

@ -1,10 +1,10 @@
/* pngrutil.c - utilities to read a png file /* pngrutil.c - utilities to read a png file
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL

View File

@ -2,10 +2,10 @@
/* pngtrans.c - transforms the data in a row /* pngtrans.c - transforms the data in a row
routines used by both readers and writers routines used by both readers and writers
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL

View File

@ -1,10 +1,10 @@
/* pngwrite.c - general routines to write a png file /* pngwrite.c - general routines to write a png file
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
*/ */
/* get internal access to png.h */ /* get internal access to png.h */

View File

@ -1,10 +1,10 @@
/* pngwtran.c - transforms the data in a row for png writers /* pngwtran.c - transforms the data in a row for png writers
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL

View File

@ -1,10 +1,10 @@
/* pngwutil.c - utilities to write a png file /* pngwutil.c - utilities to write a png file
libpng 1.0 beta 2 - version 0.87 libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 15, 1996 January 25, 1996
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
#include "png.h" #include "png.h"

View File

@ -1,8 +1,8 @@
readme.txt - for libpng 0.87 readme.txt - for libpng 0.88
This is a bug fix for the second beta version of libpng 1.0, and This is a bug fix for the second beta version of libpng 1.0, and
a first try at a progressive (push) reader. It hasn't been a more secure progressive (push) reader. The progressive reader
tested as much as the pull reader, but seems to work ok. hasn't been tested as much as the pull reader, but seems to work ok.
I've implemented the callback functions for the error/warning I've implemented the callback functions for the error/warning
messages and the input/output. See the libpng.txt messages and the input/output. See the libpng.txt