mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c21f90c334 | ||
|
|
e5a37797b4 | ||
|
|
b2e01bd505 | ||
|
|
4ee97b0891 | ||
|
|
69b1448f19 | ||
|
|
6d76471acd | ||
|
|
0f71645dfe |
488
ansi2knr.c
Normal file
488
ansi2knr.c
Normal 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
2
build.bat
Normal 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
|
||||
51
descrip.mms
Normal file
51
descrip.mms
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
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,\
|
||||
pngrio.obj, pngwio.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
|
||||
pngrio.obj : png.h, pngconf.h
|
||||
pngwio.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
|
||||
|
||||
306
example.c
306
example.c
@@ -15,7 +15,7 @@
|
||||
#include <png.h>
|
||||
|
||||
/* check to see if a file is a png file using png_check_sig() */
|
||||
int check_png(char *file_name)
|
||||
int check_png(char * file_name)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[8];
|
||||
@@ -40,77 +40,85 @@ int check_png(char *file_name)
|
||||
void read_png(char *file_name)
|
||||
{
|
||||
FILE *fp;
|
||||
png_struct *png_ptr;
|
||||
png_info *info_ptr;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
|
||||
/* open the file */
|
||||
fp = fopen(file_name, "rb");
|
||||
if (!fp)
|
||||
return;
|
||||
|
||||
/* allocate the necessary structures */
|
||||
png_ptr = malloc(sizeof (png_struct));
|
||||
/* Create and initialize the png_struct with the desired error handler
|
||||
functions. If you want to use the default stderr and longjump method,
|
||||
you can supply NULL for the last three parameters. We also check that
|
||||
the header file is compatible with the library version.
|
||||
*/
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
(void *)user_error_ptr, user_error_fn, user_warning_fn);
|
||||
|
||||
if (!png_ptr)
|
||||
{
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
info_ptr = malloc(sizeof (png_info));
|
||||
info_ptr = png_create_info_struct();
|
||||
if (!info_ptr)
|
||||
{
|
||||
fclose(fp);
|
||||
free(png_ptr);
|
||||
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* set error handling */
|
||||
/* set error handling if you are using the setjmp/longjmp method */
|
||||
if (setjmp(png_ptr->jmpbuf))
|
||||
{
|
||||
png_read_destroy(png_ptr, info_ptr, (png_info *)0);
|
||||
/* Free all of the memory associated with the png_ptr and info_ptr */
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||
fclose(fp);
|
||||
free(png_ptr);
|
||||
free(info_ptr);
|
||||
/* If we get here, we had a problem reading the file */
|
||||
return;
|
||||
}
|
||||
|
||||
/* initialize the structures, info first for error handling */
|
||||
png_info_init(info_ptr);
|
||||
png_read_init(png_ptr);
|
||||
|
||||
/* set up the input control */
|
||||
/* set up the input control if you are using standard C streams */
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
/* if you are using replacement read functions, instead of calling
|
||||
png_init_io() here you would call */
|
||||
png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);
|
||||
/* where user_io_ptr is a structure you want available to the callbacks */
|
||||
|
||||
/* read the file information */
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
/* set up the transformations you want. Note that these are
|
||||
all optional. Only call them if you want them */
|
||||
|
||||
/* expand paletted colors into true rgb */
|
||||
/* expand paletted colors into true RGB triplets */
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_expand(png_ptr);
|
||||
|
||||
/* expand grayscale images to the full 8 bits */
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||
info_ptr->bit_depth < 8)
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY && info_ptr->bit_depth < 8)
|
||||
png_set_expand(png_ptr);
|
||||
|
||||
/* expand images with transparency to full alpha channels */
|
||||
/* expand paletted or RGB images with transparency to full alpha channels
|
||||
* so the data will be available as RGBA quartets */
|
||||
if (info_ptr->valid & PNG_INFO_tRNS)
|
||||
png_set_expand(png_ptr);
|
||||
|
||||
/* Set the background color to draw transparent and alpha
|
||||
images over */
|
||||
images over. It is possible to set the red, green, and blue
|
||||
components directly for paletted images. */
|
||||
|
||||
png_color_16 my_background;
|
||||
|
||||
if (info_ptr->valid & PNG_INFO_bKGD)
|
||||
png_set_background(png_ptr, &(info_ptr->background),
|
||||
PNG_GAMMA_FILE, 1, 1.0);
|
||||
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
else
|
||||
png_set_background(png_ptr, &my_background,
|
||||
PNG_GAMMA_SCREEN, 0, 1.0);
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
|
||||
|
||||
/* tell libpng to handle the gamma conversion for you */
|
||||
if (info_ptr->valid & PNG_INFO_gAMA)
|
||||
@@ -118,18 +126,17 @@ void read_png(char *file_name)
|
||||
else
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.45);
|
||||
|
||||
/* tell libpng to strip 16 bit depth files down to 8 bits */
|
||||
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
|
||||
if (info_ptr->bit_depth == 16)
|
||||
png_set_strip_16(png_ptr);
|
||||
|
||||
/* dither rgb files down to 8 bit palettes & reduce palettes
|
||||
/* dither rgb files down to 8 bit palette & reduce palettes
|
||||
to the number of colors available on your screen */
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
if (info_ptr->valid & PNG_INFO_PLTE)
|
||||
png_set_dither(png_ptr, info_ptr->palette,
|
||||
info_ptr->num_palette, max_screen_colors,
|
||||
info_ptr->histogram);
|
||||
png_set_dither(png_ptr, info_ptr->palette, info_ptr->num_palette,
|
||||
max_screen_colors, info_ptr->histogram);
|
||||
else
|
||||
{
|
||||
png_color std_color_cube[MAX_SCREEN_COLORS] =
|
||||
@@ -140,9 +147,8 @@ void read_png(char *file_name)
|
||||
}
|
||||
}
|
||||
|
||||
/* invert monocrome files */
|
||||
if (info_ptr->bit_depth == 1 &&
|
||||
info_ptr->color_type == PNG_COLOR_GRAY)
|
||||
/* invert monocrome files to have 0 as white and 1 as black */
|
||||
if (info_ptr->bit_depth == 1 && info_ptr->color_type == PNG_COLOR_GRAY)
|
||||
png_set_invert(png_ptr);
|
||||
|
||||
/* shift the pixels down to their true bit depth */
|
||||
@@ -150,7 +156,8 @@ void read_png(char *file_name)
|
||||
info_ptr->bit_depth > info_ptr->sig_bit)
|
||||
png_set_shift(png_ptr, &(info_ptr->sig_bit));
|
||||
|
||||
/* pack pixels into bytes */
|
||||
/* pack multiple pixels with bit depths of 1, 2, and 4 into bytes
|
||||
(useful only for paletted and grayscale images) */
|
||||
if (info_ptr->bit_depth < 8)
|
||||
png_set_packing(png_ptr);
|
||||
|
||||
@@ -163,28 +170,28 @@ void read_png(char *file_name)
|
||||
if (info_ptr->bit_depth == 16)
|
||||
png_set_swap(png_ptr);
|
||||
|
||||
/* add a filler byte to rgb files */
|
||||
if (info_ptr->bit_depth == 8 &&
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_RGB)
|
||||
/* add a filler byte to RGB files (before or after each RGB triplet) */
|
||||
if (info_ptr->bit_depth == 8 && info_ptr->color_type == PNG_COLOR_TYPE_RGB)
|
||||
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
|
||||
|
||||
/* turn on interlace handling if you are not using png_read_image() */
|
||||
if (info_ptr->interlace_type)
|
||||
number_passes = png_set_interlace_handling(png_ptr);
|
||||
else
|
||||
number_passes = 1;
|
||||
number_passes = png_set_interlace_handling(png_ptr);
|
||||
|
||||
/* optional call to update palette with transformations */
|
||||
png_start_read_image(png_ptr);
|
||||
|
||||
/* optional call to update the info structure */
|
||||
/* optional call to gamma correct and add the background to the palette
|
||||
and update info structure. */
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
|
||||
/* allocate the memory to hold the image using the fields
|
||||
of png_info. */
|
||||
|
||||
/* the easiest way to read the image */
|
||||
png_bytef *row_pointers[height];
|
||||
png_bytep row_pointers[height];
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
row_pointers[row] = malloc(info_ptr->rowbytes);
|
||||
}
|
||||
|
||||
png_read_image(png_ptr, row_pointers);
|
||||
|
||||
/* the other way to read images - deal with interlacing */
|
||||
@@ -197,7 +204,7 @@ void read_png(char *file_name)
|
||||
/* If you are only reading on row at a time, this works */
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
png_bytef *row_pointers = row[y];
|
||||
png_bytep row_pointers = row[y];
|
||||
png_read_rows(png_ptr, &row_pointers, NULL, 1);
|
||||
}
|
||||
|
||||
@@ -208,16 +215,11 @@ void read_png(char *file_name)
|
||||
so here */
|
||||
}
|
||||
|
||||
/* read the rest of the file, getting any additional chunks
|
||||
in info_ptr */
|
||||
/* read the rest of the file, getting any additional chunks in info_ptr */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
|
||||
/* clean up after the read, and free any memory allocated */
|
||||
png_read_destroy(png_ptr, info_ptr, (png_info *)0);
|
||||
|
||||
/* free the structures */
|
||||
free(png_ptr);
|
||||
free(info_ptr);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
|
||||
|
||||
/* close the file */
|
||||
fclose(fp);
|
||||
@@ -226,52 +228,180 @@ void read_png(char *file_name)
|
||||
return;
|
||||
}
|
||||
|
||||
/* progressively read a file */
|
||||
|
||||
int
|
||||
initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
||||
{
|
||||
/* Create and initialize the png_struct with the desired error handler
|
||||
functions. If you want to use the default stderr and longjump method,
|
||||
you can supply NULL for the last three parameters. We also check that
|
||||
the library version is compatible in case we are using dynamically
|
||||
linked libraries.
|
||||
*/
|
||||
*png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
(void *)user_error_ptr, user_error_fn, user_warning_fn);
|
||||
|
||||
if (! *png_ptr)
|
||||
{
|
||||
*info_ptr = NULL;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
*info_ptr = png_create_info_struct(png_ptr);
|
||||
|
||||
if (! *info_ptr)
|
||||
{
|
||||
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (setjmp((*png_ptr)->jmpbuf))
|
||||
{
|
||||
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* this one's new. You will need to provide all three
|
||||
function callbacks, even if you aren't using them all.
|
||||
These functions shouldn't be dependent on global or
|
||||
static variables if you are decoding several images
|
||||
simultaneously. You should store stream specific data
|
||||
in a separate struct, given as the second parameter,
|
||||
and retrieve the pointer from inside the callbacks using
|
||||
the function png_get_progressive_ptr(png_ptr). */
|
||||
png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
|
||||
info_callback, row_callback, end_callback);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
process_data(png_structp *png_ptr, png_infop *info_ptr,
|
||||
png_bytep buffer, png_uint_32 length)
|
||||
{
|
||||
if (setjmp((*png_ptr)->jmpbuf))
|
||||
{
|
||||
/* Free the png_ptr and info_ptr memory on error */
|
||||
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* this one's new also. Simply give it chunks of data as
|
||||
they arrive from the data stream (in order, of course).
|
||||
On Segmented machines, don't give it any more than 64K.
|
||||
The library seems to run fine with sizes of 4K, although
|
||||
you can give it much less if necessary (I assume you can
|
||||
give it chunks of 1 byte, but I haven't tried with less
|
||||
than 256 bytes yet). When this function returns, you may
|
||||
want to display any rows that were generated in the row
|
||||
callback, if you aren't already displaying them there. */
|
||||
png_process_data(*png_ptr, *info_ptr, buffer, length);
|
||||
return OK;
|
||||
}
|
||||
|
||||
info_callback(png_structp png_ptr, png_infop info)
|
||||
{
|
||||
/* do any setup here, including setting any of the transformations
|
||||
mentioned in the Reading PNG files section. For now, you _must_
|
||||
call either png_start_read_image() or png_read_update_info()
|
||||
after all the transformations are set (even if you don't set
|
||||
any). You may start getting rows before png_process_data()
|
||||
returns, so this is your last chance to prepare for that. */
|
||||
}
|
||||
|
||||
row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
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 will be called for every row in every 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.
|
||||
The rows and passes are called in order, so you don't really
|
||||
need the row_num and pass, but I'm supplying them because it
|
||||
may make your life easier.
|
||||
|
||||
For the non-NULL rows of interlaced images, you must call
|
||||
png_progressive_combine_row() passing in the row and the
|
||||
old row. You can call this function for NULL rows (it will
|
||||
just return) and for non-interlaced images (it just does the
|
||||
memcpy for you) if it will make the code easier. Thus, you
|
||||
can just do this for all cases: */
|
||||
|
||||
png_progressive_combine_row(png_ptr, old_row, new_row);
|
||||
|
||||
/* where old_row is what was displayed for previous rows. Note
|
||||
that the first pass (pass == 0 really) will completely cover
|
||||
the old row, so the rows do not have to be initialized. After
|
||||
the first pass (and only for interlaced images), you will have
|
||||
to pass the current row, and the function will combine the
|
||||
old row and the new row. */
|
||||
}
|
||||
|
||||
end_callback(png_structp png_ptr, png_infop info)
|
||||
{
|
||||
/* this function is called when the whole image has been read,
|
||||
including any chunks after the image (up to and including
|
||||
the IEND). You will usually have the same info chunk as you
|
||||
had in the header, although some data may have been added
|
||||
to the comments and time fields.
|
||||
|
||||
Most people won't do much here, perhaps setting a flag that
|
||||
marks the image as finished. */
|
||||
}
|
||||
|
||||
/* write a png file */
|
||||
void write_png(char *file_name, ... other image information ...)
|
||||
{
|
||||
FILE *fp;
|
||||
png_struct *png_ptr;
|
||||
png_info *info_ptr;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
|
||||
/* open the file */
|
||||
fp = fopen(file_name, "wb");
|
||||
if (!fp)
|
||||
return;
|
||||
|
||||
/* allocate the necessary structures */
|
||||
png_ptr = malloc(sizeof (png_struct));
|
||||
/* Create and initialize the png_struct with the desired error handler
|
||||
functions. If you want to use the default stderr and longjump method,
|
||||
you can supply NULL for the last three parameters. We also check that
|
||||
the library version is compatible in case we are using dynamically
|
||||
linked libraries.
|
||||
*/
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
(void *)user_error_ptr, user_error_fn, user_warning_fn);
|
||||
|
||||
if (!png_ptr)
|
||||
{
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
info_ptr = malloc(sizeof (png_info));
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (!info_ptr)
|
||||
{
|
||||
fclose(fp);
|
||||
free(png_ptr);
|
||||
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* set error handling */
|
||||
if (setjmp(png_ptr->jmpbuf))
|
||||
{
|
||||
png_write_destroy(png_ptr);
|
||||
fclose(fp);
|
||||
free(png_ptr);
|
||||
free(info_ptr);
|
||||
/* If we get here, we had a problem reading the file */
|
||||
fclose(fp);
|
||||
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* initialize the structures */
|
||||
png_info_init(info_ptr);
|
||||
png_write_init(png_ptr);
|
||||
|
||||
/* set up the output control */
|
||||
/* set up the output control if you are using standard C streams */
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
/* if you are using replacement message functions, here you would call */
|
||||
png_set_message_fn(png_ptr, (void *)msg_ptr, user_error_fn, user_warning_fn);
|
||||
/* where msg_ptr is a structure you want available to the callbacks */
|
||||
|
||||
/* set the file information here */
|
||||
info_ptr->width = ;
|
||||
info_ptr->height = ;
|
||||
@@ -285,15 +415,23 @@ void write_png(char *file_name, ... other image information ...)
|
||||
|
||||
/* optional significant bit chunk */
|
||||
info_ptr->valid |= PNG_INFO_sBIT;
|
||||
info_ptr->sig_bit = true_bit_depth;
|
||||
|
||||
/* optional gamma chunk */
|
||||
/* if we are dealing with a grayscale image then */
|
||||
info_ptr->sig_bit.gray = true_bit_depth;
|
||||
/* otherwise, if we are dealing with a color image then */
|
||||
info_ptr->sig_bit.red = true_red_bit_depth;
|
||||
info_ptr->sig_bit.green = true_green_bit_depth;
|
||||
info_ptr->sig_bit.blue = true_blue_bit_depth;
|
||||
/* if the image has an alpha channel then */
|
||||
info_ptr->sig_bit.alpha = true_alpha_bit_depth;
|
||||
|
||||
/* optional gamma chunk is strongly suggested if you have any guess
|
||||
as to the correct gamma of the image */
|
||||
info_ptr->valid |= PNG_INFO_gAMA;
|
||||
info_ptr->gamma = gamma;
|
||||
|
||||
/* other optional chunks */
|
||||
/* other optional chunks like cHRM, bKGD, tRNS, tEXt, tIME, oFFs, pHYs, */
|
||||
|
||||
/* write the file information */
|
||||
/* write the file header information */
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
/* set up the transformations you want. Note that these are
|
||||
@@ -325,8 +463,10 @@ void write_png(char *file_name, ... other image information ...)
|
||||
else
|
||||
number_passes = 1;
|
||||
|
||||
/* the easiest way to write the image */
|
||||
png_bytef *row_pointers[height];
|
||||
/* the easiest way to write the image (you may choose to allocate the
|
||||
memory differently, however) */
|
||||
png_byte row_pointers[height][width];
|
||||
|
||||
png_write_image(png_ptr, row_pointers);
|
||||
|
||||
/* the other way to write the image - deal with interlacing */
|
||||
@@ -339,24 +479,28 @@ void write_png(char *file_name, ... other image information ...)
|
||||
/* If you are only writing one row at a time, this works */
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
png_bytef *row_pointers = row[y];
|
||||
png_bytep row_pointers = row[y];
|
||||
png_write_rows(png_ptr, &row_pointers, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* You can write optional chunks like tEXt, tIME at the end as well.
|
||||
* Note that if you wrote tEXt or zTXt chunks before the image, and
|
||||
* you aren't writing out more at the end, you have to set
|
||||
* info_ptr->num_text = 0 or they will be written out again.
|
||||
*/
|
||||
|
||||
/* write the rest of the file */
|
||||
png_write_end(png_ptr, info_ptr);
|
||||
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
png_write_destroy(png_ptr);
|
||||
|
||||
/* if you malloced the palette, free it here */
|
||||
if (info_ptr->palette)
|
||||
free(info_ptr->palette);
|
||||
|
||||
/* free the structures */
|
||||
free(png_ptr);
|
||||
free(info_ptr);
|
||||
/* if you allocated any text comments, free them here */
|
||||
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
||||
|
||||
/* close the file */
|
||||
fclose(fp);
|
||||
|
||||
1496
libpng.txt
1496
libpng.txt
File diff suppressed because it is too large
Load Diff
9
makefile
9
makefile
@@ -13,8 +13,8 @@ RANLIB=echo
|
||||
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
|
||||
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||
pngwtran.o pngmem.o pngerror.o pngpread.o
|
||||
|
||||
all: libpng.a pngtest
|
||||
|
||||
@@ -45,7 +45,8 @@ clean:
|
||||
|
||||
png.o: png.h pngconf.h
|
||||
pngerror.o: png.h pngconf.h
|
||||
pngio.o: png.h pngconf.h
|
||||
pngrio.o: png.h pngconf.h
|
||||
pngwio.o: png.h pngconf.h
|
||||
pngmem.o: png.h pngconf.h
|
||||
pngrcb.o: png.h pngconf.h
|
||||
pngread.o: png.h pngconf.h
|
||||
@@ -56,3 +57,5 @@ 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
|
||||
|
||||
|
||||
115
makefile.aco
Normal file
115
makefile.aco
Normal file
@@ -0,0 +1,115 @@
|
||||
# makefile for libpng on Acorn RISCOS
|
||||
# Project: libpng
|
||||
|
||||
|
||||
# Toolflags:
|
||||
CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah
|
||||
C++flags = -c -depend !Depend -IC: -throwback
|
||||
Linkflags = -aif -c++ -o $@
|
||||
ObjAsmflags = -throwback -NoCache -depend !Depend
|
||||
CMHGflags =
|
||||
LibFileflags = -c -o $@
|
||||
Squeezeflags = -o $@
|
||||
|
||||
|
||||
# Final targets:
|
||||
@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \
|
||||
@.o.pngpread @.o.pngrcb @.o.pngread @.o.pngrtran @.o.pngrutil \
|
||||
@.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
|
||||
LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngwio \
|
||||
@.o.pngmem @.o.pngpread @.o.pngrcb @.o.pngread @.o.pngrtran \
|
||||
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
|
||||
@.test: @.tests.pngtest
|
||||
echo Please run "Test" in directory tests
|
||||
@.tests.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
|
||||
Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
|
||||
|
||||
|
||||
# User-editable dependencies:
|
||||
.c.o:
|
||||
cc $(ccflags) -o $@ $<
|
||||
|
||||
|
||||
# Static dependencies:
|
||||
@.o.example: @.tests.c.example
|
||||
cc $(ccflags) -o @.o.example @.tests.c.example
|
||||
@.o.pngtest: @.tests.c.pngtest
|
||||
cc $(ccflags) -o @.o.pngtest @.tests.c.pngtest
|
||||
|
||||
|
||||
# Dynamic dependencies:
|
||||
o.png: c.png
|
||||
o.png: h.png
|
||||
o.png: Zlib:h.zlib
|
||||
o.png: Zlib:h.zconf
|
||||
o.png: h.pngconf
|
||||
o.pngerror: c.pngerror
|
||||
o.pngerror: h.png
|
||||
o.pngerror: Zlib:h.zlib
|
||||
o.pngerror: Zlib:h.zconf
|
||||
o.pngerror: h.pngconf
|
||||
o.pngrio: c.pngrio
|
||||
o.pngrio: h.png
|
||||
o.pngrio: Zlib:h.zlib
|
||||
o.pngrio: Zlib:h.zconf
|
||||
o.pngrio: h.pngconf
|
||||
o.pngwio: c.pngwio
|
||||
o.pngwio: h.png
|
||||
o.pngwio: Zlib:h.zlib
|
||||
o.pngwio: Zlib:h.zconf
|
||||
o.pngwio: h.pngconf
|
||||
o.pngmem: c.pngmem
|
||||
o.pngmem: h.png
|
||||
o.pngmem: Zlib:h.zlib
|
||||
o.pngmem: Zlib:h.zconf
|
||||
o.pngmem: h.pngconf
|
||||
o.pngpread: c.pngpread
|
||||
o.pngpread: h.png
|
||||
o.pngpread: Zlib:h.zlib
|
||||
o.pngpread: Zlib:h.zconf
|
||||
o.pngpread: h.pngconf
|
||||
o.pngrcb: c.pngrcb
|
||||
o.pngrcb: h.png
|
||||
o.pngrcb: Zlib:h.zlib
|
||||
o.pngrcb: Zlib:h.zconf
|
||||
o.pngrcb: h.pngconf
|
||||
o.pngread: c.pngread
|
||||
o.pngread: h.png
|
||||
o.pngread: Zlib:h.zlib
|
||||
o.pngread: Zlib:h.zconf
|
||||
o.pngread: h.pngconf
|
||||
o.pngrtran: c.pngrtran
|
||||
o.pngrtran: h.png
|
||||
o.pngrtran: Zlib:h.zlib
|
||||
o.pngrtran: Zlib:h.zconf
|
||||
o.pngrtran: h.pngconf
|
||||
o.pngrutil: c.pngrutil
|
||||
o.pngrutil: h.png
|
||||
o.pngrutil: Zlib:h.zlib
|
||||
o.pngrutil: Zlib:h.zconf
|
||||
o.pngrutil: h.pngconf
|
||||
o.pngtrans: c.pngtrans
|
||||
o.pngtrans: h.png
|
||||
o.pngtrans: Zlib:h.zlib
|
||||
o.pngtrans: Zlib:h.zconf
|
||||
o.pngtrans: h.pngconf
|
||||
o.pngwrite: c.pngwrite
|
||||
o.pngwrite: h.png
|
||||
o.pngwrite: Zlib:h.zlib
|
||||
o.pngwrite: Zlib:h.zconf
|
||||
o.pngwrite: h.pngconf
|
||||
o.pngwtran: c.pngwtran
|
||||
o.pngwtran: h.png
|
||||
o.pngwtran: Zlib:h.zlib
|
||||
o.pngwtran: Zlib:h.zconf
|
||||
o.pngwtran: h.pngconf
|
||||
o.pngwutil: c.pngwutil
|
||||
o.pngwutil: h.png
|
||||
o.pngwutil: Zlib:h.zlib
|
||||
o.pngwutil: Zlib:h.zconf
|
||||
o.pngwutil: h.pngconf
|
||||
o.pngtest: tests.c.pngtest
|
||||
o.pngtest: h.png
|
||||
o.pngtest: Zlib:h.zlib
|
||||
o.pngtest: Zlib:h.zconf
|
||||
o.pngtest: h.pngconf
|
||||
42
makefile.ama
Normal file
42
makefile.ama
Normal 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 pngrio.o pngwio.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
31
makefile.atr
Normal 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)(pngrio.o) $(LBR)(pngwio.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
165
makefile.bor
Normal 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) \
|
||||
pngerror.$(O) \
|
||||
pngmem.$(O) \
|
||||
pngpread.$(O) \
|
||||
pngrcb.$(O) \
|
||||
pngread.$(O) \
|
||||
pngrio.$(O) \
|
||||
pngrtran.$(O) \
|
||||
pngrutil.$(O) \
|
||||
pngtrans.$(O) \
|
||||
pngwrite.$(O) \
|
||||
pngwtran.$(O) \
|
||||
pngwio.$(O) \
|
||||
pngwutil.$(O)
|
||||
|
||||
LIBOBJS = \
|
||||
+png.$(O) \
|
||||
+pngerror.$(O) \
|
||||
+pngmem.$(O) \
|
||||
+pngpread.$(O) \
|
||||
+pngread.$(O) \
|
||||
+pngrcb.$(O) \
|
||||
+pngrio.$(O) \
|
||||
+pngrtran.$(O) \
|
||||
+pngrutil.$(O) \
|
||||
+pngtrans.$(O) \
|
||||
+pngwrite.$(O) \
|
||||
+pngwtran.$(O) \
|
||||
+pngwio.$(O)
|
||||
+pngwutil.$(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
|
||||
pngrio.obj: pngrio.c
|
||||
pngwio.obj: pngwio.c
|
||||
pngtrans.obj: pngtrans.c
|
||||
pngwrite.obj: pngwrite.c
|
||||
pngwtran.obj: pngwtran.c
|
||||
pngwutil.obj: pngwutil.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
|
||||
51
makefile.dj2
Normal file
51
makefile.dj2
Normal file
@@ -0,0 +1,51 @@
|
||||
# DJGPP (DOS gcc) 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 pngrio.o pngwio.o pngwrite.o pngrtran.o pngwtran.o \
|
||||
pngmem.o pngerror.o pngpread.o
|
||||
|
||||
all: libpng.a pngtest
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
ar rc $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
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
|
||||
pngrio.o: png.h pngconf.h
|
||||
pngwio.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
|
||||
|
||||
74
makefile.elf
Normal file
74
makefile.elf
Normal file
@@ -0,0 +1,74 @@
|
||||
# makefile for libpng on (linux) ELF
|
||||
# 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 -O2 -Wall -fPIC
|
||||
LDFLAGS=-L. -Wl,-rpath,. -L../zlib/ -Wl,-rpath,../zlib/ -lpng -lz -lm
|
||||
|
||||
RANLIB=ranlib
|
||||
#RANLIB=echo
|
||||
|
||||
PNGVER = 0.89
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.h
|
||||
prefix=/usr/local
|
||||
|
||||
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
|
||||
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||
pngwtran.o pngmem.o pngerror.o pngpread.o
|
||||
|
||||
all: libpng.so pngtest
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
ar rc $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
libpng.so: libpng.so.1
|
||||
ln -sf libpng.so.1 libpng.so
|
||||
|
||||
libpng.so.1: libpng.so.1.$(PNGVER)
|
||||
ln -sf libpng.so.1.$(PNGVER) libpng.so.1
|
||||
|
||||
libpng.so.1.$(PNGVER): $(OBJS)
|
||||
gcc -shared -Wl,-soname,libpng.so.1 -o libpng.so.1.$(PNGVER) $(OBJS)
|
||||
|
||||
pngtest: pngtest.o libpng.so
|
||||
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
|
||||
|
||||
test: pngtest
|
||||
./pngtest
|
||||
|
||||
install: libpng.so.1.$(PNGVER)
|
||||
-@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.so.1.$(PNGVER) $(prefix)/lib
|
||||
chmod 755 $(prefix)/lib/libpng.so.1.$(PNGVER)
|
||||
-@/bin/rm $(prefix)/lib/libpng.so.1 $(prefix)/lib/libpng.so
|
||||
(cd $(prefix)/lib; ln -sf libpng.so.1.$(PNGVER) libpng.so.1; \
|
||||
ln -sf libpng.so.1 libpng.so)
|
||||
|
||||
clean:
|
||||
rm -f *.o libpng.so.1.$(PNGVER) libpng.so.1 libpng.so 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
|
||||
pngrio.o: png.h pngconf.h
|
||||
pngwio.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
|
||||
72
makefile.knr
Normal file
72
makefile.knr
Normal file
@@ -0,0 +1,72 @@
|
||||
# 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 pngrio.o pngwio.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
|
||||
pngrio.o: png.h pngconf.h
|
||||
pngwio.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
|
||||
61
makefile.mip
Normal file
61
makefile.mip
Normal file
@@ -0,0 +1,61 @@
|
||||
# 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 pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||
pngwtran.o pngmem.o pngerror.o pngpread.o
|
||||
|
||||
all: libpng.a pngtest
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
ar rc $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
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
|
||||
pngrio.o: png.h pngconf.h
|
||||
pngwio.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
|
||||
81
makefile.msc
Normal file
81
makefile.msc
Normal file
@@ -0,0 +1,81 @@
|
||||
# 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) pngrio$(O) pngwio$(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)
|
||||
|
||||
pngrio$(O): png.h pngconf.h
|
||||
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwio$(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
|
||||
|
||||
61
makefile.std
Normal file
61
makefile.std
Normal file
@@ -0,0 +1,61 @@
|
||||
# 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 pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||
pngwtran.o pngmem.o pngerror.o pngpread.o
|
||||
|
||||
all: libpng.a pngtest
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
ar rc $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
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
|
||||
pngrio.o: png.h pngconf.h
|
||||
pngwio.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
|
||||
|
||||
72
makefile.tc
Normal file
72
makefile.tc
Normal file
@@ -0,0 +1,72 @@
|
||||
# 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) pngrio$(O) pngwio$(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) +pngrio$(O) +pngwio$(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
|
||||
|
||||
pngrio$(O): png.h pngconf.h
|
||||
$(CC) -c $(CFLAGS) $*.c
|
||||
|
||||
pngwio$(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
|
||||
123
makevms.com
Normal file
123
makevms.com
Normal file
@@ -0,0 +1,123 @@
|
||||
$! 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 pngrio.OBJ "cc ''CCOPT' pngrio" -
|
||||
pngrio.c png.h pngconf.h
|
||||
$ CALL MAKE pngwio.OBJ "cc ''CCOPT' pngwio" -
|
||||
pngwio.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
|
||||
|
||||
151
png.c
151
png.c
@@ -1,10 +1,10 @@
|
||||
|
||||
/* png.c - location for general purpose png functions
|
||||
|
||||
libpng 1.0 beta 2 - version 0.81
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 24, 1995
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -13,115 +13,108 @@
|
||||
|
||||
/* version information for c files. This better match the version
|
||||
string defined in png.h */
|
||||
char png_libpng_ver[] = "0.81";
|
||||
char png_libpng_ver[] = "0.89";
|
||||
|
||||
/* place to hold the signiture string for a png file. */
|
||||
png_byte 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};
|
||||
|
||||
/* constant strings for known chunk types. If you need to add a chunk,
|
||||
add a string holding the name here. If you want to make the code
|
||||
portable to EBCDIC machines, use ASCII numbers, not characters. */
|
||||
png_byte png_IHDR[4] = { 73, 72, 68, 82};
|
||||
png_byte png_IDAT[4] = { 73, 68, 65, 84};
|
||||
png_byte png_IEND[4] = { 73, 69, 78, 68};
|
||||
png_byte png_PLTE[4] = { 80, 76, 84, 69};
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
png_byte png_gAMA[4] = {103, 65, 77, 65};
|
||||
#endif
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
|
||||
png_byte png_sBIT[4] = {115, 66, 73, 84};
|
||||
#endif
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
|
||||
png_byte png_cHRM[4] = { 99, 72, 82, 77};
|
||||
#endif
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
|
||||
png_byte png_tRNS[4] = {116, 82, 78, 83};
|
||||
#endif
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
|
||||
png_byte png_bKGD[4] = { 98, 75, 71, 68};
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
|
||||
png_byte png_hIST[4] = {104, 73, 83, 84};
|
||||
#endif
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED)
|
||||
png_byte png_tEXt[4] = {116, 69, 88, 116};
|
||||
#endif
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
png_byte png_zTXt[4] = {122, 84, 88, 116};
|
||||
#endif
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
png_byte png_pHYs[4] = {112, 72, 89, 115};
|
||||
#endif
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
png_byte png_oFFs[4] = {111, 70, 70, 115};
|
||||
#endif
|
||||
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
png_byte png_tIME[4] = {116, 73, 77, 69};
|
||||
#endif
|
||||
png_byte FARDATA png_IHDR[4] = { 73, 72, 68, 82};
|
||||
png_byte FARDATA png_IDAT[4] = { 73, 68, 65, 84};
|
||||
png_byte FARDATA png_IEND[4] = { 73, 69, 78, 68};
|
||||
png_byte FARDATA png_PLTE[4] = { 80, 76, 84, 69};
|
||||
png_byte FARDATA png_gAMA[4] = {103, 65, 77, 65};
|
||||
png_byte FARDATA png_sBIT[4] = {115, 66, 73, 84};
|
||||
png_byte FARDATA png_cHRM[4] = { 99, 72, 82, 77};
|
||||
png_byte FARDATA png_tRNS[4] = {116, 82, 78, 83};
|
||||
png_byte FARDATA png_bKGD[4] = { 98, 75, 71, 68};
|
||||
png_byte FARDATA png_hIST[4] = {104, 73, 83, 84};
|
||||
png_byte FARDATA png_tEXt[4] = {116, 69, 88, 116};
|
||||
png_byte FARDATA png_zTXt[4] = {122, 84, 88, 116};
|
||||
png_byte FARDATA png_pHYs[4] = {112, 72, 89, 115};
|
||||
png_byte FARDATA png_oFFs[4] = {111, 70, 70, 115};
|
||||
png_byte FARDATA png_tIME[4] = {116, 73, 77, 69};
|
||||
|
||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* start of interlace block */
|
||||
int png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||
int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* offset to next interlace block */
|
||||
int png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* start of interlace block in the y direction */
|
||||
int png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* offset to next interlace block in the y direction */
|
||||
int png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
/* width of interlace block */
|
||||
/* this is not currently used - if you need it, uncomment it here and
|
||||
in png.h
|
||||
int png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
||||
int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
||||
*/
|
||||
|
||||
/* height of interlace block */
|
||||
/* this is not currently used - if you need it, uncomment it here and
|
||||
in png.h
|
||||
int png_pass_height[] = {8, 8, 4, 4, 4, 2, 2, 1};
|
||||
int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
*/
|
||||
|
||||
/* mask to determine which pixels are valid in a pass */
|
||||
int png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||
int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||
|
||||
/* mask to determine which pixels to overwrite while displaying */
|
||||
int png_pass_dsp_mask[] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
int FARDATA png_pass_dsp_mask[] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
|
||||
|
||||
int
|
||||
png_check_sig(png_byte *sig, int num)
|
||||
png_check_sig(png_bytep sig, int num)
|
||||
{
|
||||
if (num > 8)
|
||||
num = 8;
|
||||
if (num < 1)
|
||||
return 0;
|
||||
|
||||
return (!memcmp(sig, png_sig, num));
|
||||
return (!png_memcmp(sig, png_sig, num));
|
||||
}
|
||||
|
||||
/* Function to allocate memory for zlib. */
|
||||
voidpf
|
||||
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
{
|
||||
return ((voidpf)png_large_malloc((png_struct FAR *)png_ptr,
|
||||
(png_uint_32)items * (png_uint_32)size));
|
||||
png_voidp ptr;
|
||||
png_uint_32 num_bytes;
|
||||
|
||||
ptr = png_large_malloc((png_structp)png_ptr,
|
||||
(png_uint_32)items * (png_uint_32)size);
|
||||
num_bytes = (png_uint_32)items * (png_uint_32)size;
|
||||
if (num_bytes > (png_uint_32)0x7fff)
|
||||
{
|
||||
png_memset(ptr, 0, (png_size_t)0x8000L);
|
||||
png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
|
||||
(png_size_t)(num_bytes - (png_uint_32)0x8000L));
|
||||
}
|
||||
else
|
||||
{
|
||||
png_memset(ptr, 0, (png_size_t)num_bytes);
|
||||
}
|
||||
return (voidpf)(ptr);
|
||||
}
|
||||
|
||||
/* function to free memory for zlib */
|
||||
void
|
||||
png_zfree(voidpf png_ptr, voidpf ptr)
|
||||
{
|
||||
png_large_free((png_struct FAR *)png_ptr, (voidpf)ptr);
|
||||
png_large_free((png_structp)png_ptr, (png_voidp)ptr);
|
||||
}
|
||||
|
||||
/* reset the crc variable to 32 bits of 1's. Care must be taken
|
||||
in case crc is > 32 bits to leave the top bits 0 */
|
||||
void
|
||||
png_reset_crc(png_struct *png_ptr)
|
||||
png_reset_crc(png_structp png_ptr)
|
||||
{
|
||||
/* set crc to all 1's */
|
||||
png_ptr->crc = 0xffffffffL;
|
||||
@@ -161,10 +154,10 @@ make_crc_table(void)
|
||||
initialized to all 1's, and the transmitted value is the 1's complement
|
||||
of the final running crc. */
|
||||
static png_uint_32
|
||||
update_crc(png_uint_32 crc, png_bytef *buf, png_uint_32 len)
|
||||
update_crc(png_uint_32 crc, png_bytep buf, png_uint_32 len)
|
||||
{
|
||||
png_uint_32 c;
|
||||
png_bytef *p;
|
||||
png_bytep p;
|
||||
png_uint_32 n;
|
||||
|
||||
c = crc;
|
||||
@@ -189,15 +182,47 @@ update_crc(png_uint_32 crc, png_bytef *buf, png_uint_32 len)
|
||||
would need to use huge pointers to access all that data. If you
|
||||
need this, put huge here and above. */
|
||||
void
|
||||
png_calculate_crc(png_struct *png_ptr, png_bytef *ptr,
|
||||
png_calculate_crc(png_structp png_ptr, png_bytep ptr,
|
||||
png_uint_32 length)
|
||||
{
|
||||
png_ptr->crc = update_crc(png_ptr->crc, ptr, length);
|
||||
}
|
||||
void
|
||||
png_info_init(png_info *info)
|
||||
|
||||
png_infop
|
||||
png_create_info_struct(png_structp png_ptr)
|
||||
{
|
||||
/* set everything to 0 */
|
||||
memset(info, 0, sizeof (png_info));
|
||||
png_infop info_ptr;
|
||||
|
||||
if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL)
|
||||
{
|
||||
png_memset(info_ptr, 0, sizeof(png_info));
|
||||
png_ptr->do_free |= PNG_FREE_INFO;
|
||||
}
|
||||
|
||||
return info_ptr;
|
||||
}
|
||||
|
||||
void
|
||||
png_info_init(png_infop info)
|
||||
{
|
||||
/* set everything to 0 */
|
||||
png_memset(info, 0, sizeof (png_info));
|
||||
}
|
||||
|
||||
/* This function returns a pointer to the io_ptr associated with the user
|
||||
functions. The application should free any memory associated with this
|
||||
pointer before png_write_destroy and png_read_destroy are called. */
|
||||
png_voidp
|
||||
png_get_io_ptr(png_structp png_ptr)
|
||||
{
|
||||
return png_ptr->io_ptr;
|
||||
}
|
||||
|
||||
/* Initialize the default input/output functions for the png file. If you
|
||||
change the read, or write routines, you can call either png_set_read_fn()
|
||||
or png_set_write_fn() instead of png_init_io(). */
|
||||
void
|
||||
png_init_io(png_structp png_ptr, FILE *fp)
|
||||
{
|
||||
png_ptr->io_ptr = (png_voidp)fp;
|
||||
}
|
||||
|
||||
95
pngchang.txt
95
pngchang.txt
@@ -1,31 +1,31 @@
|
||||
pngchange.txt - changes for libpng
|
||||
|
||||
version 0.2
|
||||
added reader into png.h
|
||||
fixed small problems in stub file
|
||||
added reader into png.h
|
||||
fixed small problems in stub file
|
||||
version 0.3
|
||||
added pull reader
|
||||
split up pngwrite.c to several files
|
||||
added pnglib.txt
|
||||
added example.c
|
||||
cleaned up writer, adding a few new tranformations
|
||||
fixed some bugs in writer
|
||||
interfaced with zlib 0.5
|
||||
added K&R support
|
||||
added check for 64 KB blocks for 16 bit machines
|
||||
added pull reader
|
||||
split up pngwrite.c to several files
|
||||
added pnglib.txt
|
||||
added example.c
|
||||
cleaned up writer, adding a few new tranformations
|
||||
fixed some bugs in writer
|
||||
interfaced with zlib 0.5
|
||||
added K&R support
|
||||
added check for 64 KB blocks for 16 bit machines
|
||||
version 0.4
|
||||
cleaned up code and commented code
|
||||
simplified time handling into png_time
|
||||
created png_color_16 and png_color_8 to handle color needs
|
||||
cleaned up color type defines
|
||||
fixed various bugs
|
||||
made various names more consistant
|
||||
interfaced with zlib 0.71
|
||||
cleaned up zTXt reader and writer (using zlib's Reset functions)
|
||||
split transformations into pngrtran.c and pngwtran.c
|
||||
cleaned up code and commented code
|
||||
simplified time handling into png_time
|
||||
created png_color_16 and png_color_8 to handle color needs
|
||||
cleaned up color type defines
|
||||
fixed various bugs
|
||||
made various names more consistant
|
||||
interfaced with zlib 0.71
|
||||
cleaned up zTXt reader and writer (using zlib's Reset functions)
|
||||
split transformations into pngrtran.c and pngwtran.c
|
||||
version 0.5
|
||||
interfaced with zlib 0.8
|
||||
fixed many reading and writing bugs
|
||||
interfaced with zlib 0.8
|
||||
fixed many reading and writing bugs
|
||||
saved using 3 spaces instead of tabs
|
||||
version 0.6
|
||||
added png_large_malloc() and png_large_free()
|
||||
@@ -54,7 +54,50 @@ version 0.8
|
||||
changed external functions passing floats to doubles (k&r problems?)
|
||||
put all the configurable stuff in pngconf.h
|
||||
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
|
||||
incorporated Tim Wegner's medium model code (thanks, Tim)
|
||||
version 0.85
|
||||
added more medium model code (almost everythings a far)
|
||||
added i/o, error, and memory callback functions
|
||||
fixed some bugs (16 bit, 4 bit interlaced, etc.)
|
||||
added first run progressive reader (barely tested)
|
||||
version 0.86
|
||||
fixed bugs
|
||||
improved documentation
|
||||
version 0.87
|
||||
fixed medium model bugs
|
||||
fixed other bugs introduced in 0.85 and 0.86
|
||||
added some minor documentation
|
||||
version 0.88
|
||||
fixed progressive bugs
|
||||
replaced tabs with spaces
|
||||
cleaned up documentation
|
||||
added callbacks for read/write and warning/error functions
|
||||
version 0.89
|
||||
added new initialization API to make libpng work better with shared libs
|
||||
we now have png_create_read_struct(), png_create_write_struct(),
|
||||
png_create_info_struct(), png_destroy_read_struct(), and
|
||||
png_destroy_write_struct() instead of the separate calls to
|
||||
malloc and png_read_init(), png_info_init(), and png_write_init()
|
||||
changed warning/error callback functions to fix bug - this means you
|
||||
should use the new initialization API if you were using the old
|
||||
png_set_message_fn() calls, and that the old API no longer exists
|
||||
so that people are aware that they need to change their code
|
||||
changed filter selection API to allow selection of multiple filters
|
||||
since it didn't work in previous versions of libpng anyways
|
||||
optimized filter selection code
|
||||
fixed png_set_background() to allow using an arbitrary RGB color for
|
||||
paletted images
|
||||
fixed gamma and background correction for paletted images, so
|
||||
png_correct_palette is not needed unless you are correcting an
|
||||
external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED
|
||||
in pngconf.h)
|
||||
fixed bug with Borland 64K memory allocation (Alexander Lehmann)
|
||||
fixed bug in interlace handling (Smaraderagd, I think)
|
||||
added more error checking for writing and image to reduce invalid files
|
||||
separated read and write functions so that they won't both be linked
|
||||
into a binary when only reading or writing functionality is used
|
||||
new pngtest image also has interlacing and zTXt
|
||||
updated dcumentation to reflect new API
|
||||
|
||||
128
pngconf.h
128
pngconf.h
@@ -1,10 +1,10 @@
|
||||
|
||||
/* pngconf.c - machine configurable file for libpng
|
||||
|
||||
libpng 1.0 beta 2 - version 0.81
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 24, 1995
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
@@ -48,6 +48,14 @@
|
||||
#define PNG_MAX_ALLOC_64K
|
||||
#endif
|
||||
|
||||
/* this protects us against compilers which run on a windowing system
|
||||
and thus don't have or would rather us not use the stdio types:
|
||||
stdin, stdout, and stderr. The only one currently used is stderr
|
||||
in png_error() and png_warning(). #defining PNG_NO_STDIO will
|
||||
prevent these from being compiled and used. */
|
||||
|
||||
/* #define PNG_NO_STDIO */
|
||||
|
||||
/* this macro protects us against machines that don't have function
|
||||
prototypes. If your compiler does not handle function prototypes,
|
||||
define this macro. I've always been able to use _NO_PROTO as the
|
||||
@@ -60,7 +68,7 @@
|
||||
#else
|
||||
|
||||
#ifdef _NO_PROTO
|
||||
#define PNGARG(arglist)
|
||||
#define PNGARG(arglist) ()
|
||||
#else
|
||||
#define PNGARG(arglist) arglist
|
||||
#endif /* _NO_PROTO */
|
||||
@@ -70,7 +78,7 @@
|
||||
#endif /* PNGARG */
|
||||
|
||||
/* enough people need this for various reasons to include it here */
|
||||
#ifndef MACOS
|
||||
#if !defined(MACOS) && !defined(RISCOS)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
/* need the time information for reading tIME chunks */
|
||||
@@ -129,6 +137,19 @@
|
||||
|
||||
#endif /* PNG_INTERNAL */
|
||||
|
||||
/* the following uses const char * instead of char * for error
|
||||
and warning message functions, so some compilers won't complain.
|
||||
If you want to use const, define PNG_USE_CONST here. It is not
|
||||
normally defined to make configuration easier, as it is not a
|
||||
critical part of the code.
|
||||
*/
|
||||
|
||||
#ifdef PNG_USE_CONST
|
||||
# define PNG_CONST const
|
||||
#else
|
||||
# define PNG_CONST
|
||||
#endif
|
||||
|
||||
/* The following defines give you the ability to remove code
|
||||
from the library that you will not be using. I wish I
|
||||
could figure out how to automate this, but I can't do
|
||||
@@ -144,7 +165,7 @@
|
||||
*/
|
||||
|
||||
/* Any transformations you will not be using can be undef'ed here */
|
||||
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#define PNG_READ_INTERLACING_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_SHIFT_SUPPORTED
|
||||
@@ -158,6 +179,7 @@
|
||||
#define PNG_READ_FILLER_SUPPORTED
|
||||
#define PNG_READ_GAMMA_SUPPORTED
|
||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#undef PNG_CORRECT_PALETTE_SUPPORTED
|
||||
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED
|
||||
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||
@@ -166,6 +188,7 @@
|
||||
#define PNG_WRITE_SWAP_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_SUPPORTED
|
||||
#define PNG_WRITE_FILLER_SUPPORTED
|
||||
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||
|
||||
/* any chunks you are not interested in, you can undef here. The
|
||||
ones that allocate memory may be expecially important (hIST,
|
||||
@@ -213,25 +236,105 @@ typedef unsigned char png_byte;
|
||||
change (I'm not sure if you will or not, so I thought I'd be safe) */
|
||||
typedef size_t png_size_t;
|
||||
|
||||
/* The following is needed for medium model support. It cannot be in the
|
||||
PNG_INTERNAL section. Needs modification for other compilers besides
|
||||
/* The following is needed for medium model support. It cannot be in the
|
||||
PNG_INTERNAL section. Needs modification for other compilers besides
|
||||
MSC. Model independent support declares all arrays that might be very
|
||||
large using the far keyword. The Zlib version used must also support
|
||||
model independent data. As of version Zlib .95, the necessary changes
|
||||
model independent data. As of version Zlib .95, the necessary changes
|
||||
have been made in Zlib. The USE_FAR_KEYWORD define triggers other
|
||||
changes that are needed. Most of the far keyword changes are hidden
|
||||
inside typedefs with suffix "f". Tim Wegner */
|
||||
|
||||
#if defined(FAR) && defined(M_I86MM) /* MSC Medium model */
|
||||
# define USE_FAR_KEYWORD
|
||||
/* SJT: Separate compiler dependencies */
|
||||
/* SJT: problem here is that zlib.h always defines FAR */
|
||||
#ifdef __BORLANDC__
|
||||
#if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
|
||||
#define LDATA 1
|
||||
#else
|
||||
#define LDATA 0
|
||||
#endif
|
||||
|
||||
#if !defined(__WIN32__) && !defined(__FLAT__)
|
||||
#define PNG_MAX_MALLOC_64K
|
||||
#if (LDATA != 1)
|
||||
#ifndef FAR
|
||||
#define FAR __far
|
||||
#endif
|
||||
#define USE_FAR_KEYWORD
|
||||
#endif /* LDATA != 1 */
|
||||
|
||||
/* SJT: Possibly useful for moving data out of default segment.
|
||||
Uncomment it if you want. Could also define FARDATA as const
|
||||
if your compiler supports it.
|
||||
# define FARDATA FAR
|
||||
*/
|
||||
#endif /* __WIN32__, __FLAT__ */
|
||||
|
||||
#endif /* __BORLANDC__ */
|
||||
|
||||
|
||||
/* SJT: Suggest testing for specific compiler first before
|
||||
testing for FAR. The Watcom compiler defines both __MEDIUM__
|
||||
and M_I86MM, making reliance oncertain keywords suspect
|
||||
*/
|
||||
|
||||
/* MSC Medium model */
|
||||
#if defined(FAR)
|
||||
# if defined(M_I86MM)
|
||||
# define USE_FAR_KEYWORD
|
||||
# define FARDATA FAR /* SJT: added */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* SJT: default case */
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
/* SJT: At this point FAR is always defined */
|
||||
|
||||
/* not used anymore, but kept for compatability */
|
||||
typedef unsigned char FAR png_bytef;
|
||||
|
||||
/* SJT: */
|
||||
#ifndef FARDATA
|
||||
#define FARDATA
|
||||
#endif
|
||||
|
||||
/* End medium model changes to be in zconf.h */
|
||||
|
||||
/* SJT: More typedefs */
|
||||
typedef void FAR * png_voidp;
|
||||
|
||||
|
||||
/* SJT: Add typedefs for pointers */
|
||||
typedef png_byte FAR * png_bytep;
|
||||
typedef png_uint_32 FAR * png_uint_32p;
|
||||
typedef png_int_32 FAR * png_int_32p;
|
||||
typedef png_uint_16 FAR * png_uint_16p;
|
||||
typedef png_int_16 FAR * png_int_16p;
|
||||
typedef PNG_CONST char FAR * png_const_charp;
|
||||
typedef char FAR * png_charp;
|
||||
|
||||
/* SJT: Pointers to pointers; i.e. arrays */
|
||||
typedef png_byte FAR * FAR * png_bytepp;
|
||||
typedef png_uint_32 FAR * FAR * png_uint_32pp;
|
||||
typedef png_int_32 FAR * FAR * png_int_32pp;
|
||||
typedef png_uint_16 FAR * FAR * png_uint_16pp;
|
||||
typedef png_int_16 FAR * FAR * png_int_16pp;
|
||||
typedef PNG_CONST char FAR * FAR * png_const_charpp;
|
||||
typedef char FAR * FAR * png_charpp;
|
||||
|
||||
|
||||
/* SJT: libpng typedefs for types in zlib. If Zlib changes
|
||||
or another compression library is used, then change these.
|
||||
Eliminates need to change all the source files.
|
||||
*/
|
||||
typedef charf * png_zcharp;
|
||||
typedef charf * FAR * png_zcharpp;
|
||||
typedef z_stream * png_zstreamp; /* zlib won't accept far z_stream */
|
||||
|
||||
|
||||
/* User may want to use these so not in PNG_INTERNAL. Any library functions
|
||||
that are passed far data must be model independent. */
|
||||
#if defined(USE_FAR_KEYWORD) /* memory model independent fns */
|
||||
@@ -239,6 +342,7 @@ typedef unsigned char FAR png_bytef;
|
||||
# define png_strcat _fstrcat
|
||||
# define png_strlen _fstrlen
|
||||
# define png_strcmp _fstrcmp
|
||||
# define png_memcmp _fmemcmp /* SJT: added */
|
||||
# define png_memcpy _fmemcpy
|
||||
# define png_memset _fmemset
|
||||
#else /* use the usual functions */
|
||||
@@ -246,11 +350,11 @@ typedef unsigned char FAR png_bytef;
|
||||
# define png_strcat strcat
|
||||
# define png_strlen strlen
|
||||
# define png_strcmp strcmp
|
||||
# define png_memcmp memcmp /* SJT: added */
|
||||
# define png_memcpy memcpy
|
||||
# define png_memset memset
|
||||
#endif
|
||||
/* End of memory model independent support */
|
||||
|
||||
|
||||
#endif /* PNGCONF_H */
|
||||
|
||||
|
||||
95
pngerror.c
95
pngerror.c
@@ -1,25 +1,63 @@
|
||||
|
||||
/* pngstub.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.81
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 24, 1995
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
|
||||
This file provides a location for all error handling. Users which
|
||||
need special error handling are expected to modify the code in this
|
||||
file to meet their needs. See the instructions at each function. */
|
||||
need special error handling are expected to write replacement functions
|
||||
and use png_set_error_fn() to use those functions. See the instructions
|
||||
at each function. */
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
/* This function is called whenever there is an error. Replace with
|
||||
however you wish to handle the error. Note that this function
|
||||
MUST NOT return, or the program will crash */
|
||||
static void png_default_error PNGARG((png_structp png_ptr,
|
||||
png_const_charp message));
|
||||
static void png_default_warning PNGARG((png_structp png_ptr,
|
||||
png_const_charp message));
|
||||
|
||||
/* This function is called whenever there is a fatal error. This function
|
||||
should not be changed. If there is a need to handle errors differently,
|
||||
you should supply a replacement error function and use png_set_error_fn()
|
||||
to replace the error function at run-time. */
|
||||
void
|
||||
png_error(png_structf *png_ptr, char *message)
|
||||
png_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
if (png_ptr->error_fn)
|
||||
(*(png_ptr->error_fn))(png_ptr, message);
|
||||
|
||||
/* if the following returns or doesn't exist, use the default function,
|
||||
which will not return */
|
||||
png_default_error(png_ptr, message);
|
||||
}
|
||||
|
||||
/* This function is called whenever there is a non-fatal error. This function
|
||||
should not be changed. If there is a need to handle warnings differently,
|
||||
you should supply a replacement warning function and use
|
||||
png_set_error_fn() to replace the warning function at run-time. */
|
||||
void
|
||||
png_warning(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
if (png_ptr->warning_fn)
|
||||
(*(png_ptr->warning_fn))(png_ptr, message);
|
||||
else
|
||||
png_default_warning(png_ptr, message);
|
||||
}
|
||||
|
||||
/* This is the default error handling function. Note that replacements for
|
||||
this function MUST NOT RETURN, or the program will likely crash. This
|
||||
function is used by default, or if the program supplies NULL for the
|
||||
error function pointer in png_set_error_fn(). */
|
||||
static void
|
||||
png_default_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
#ifndef PNG_NO_STDIO
|
||||
fprintf(stderr, "libpng error: %s\n", message);
|
||||
#endif
|
||||
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
{
|
||||
jmp_buf jmpbuf;
|
||||
@@ -31,16 +69,43 @@ png_error(png_structf *png_ptr, char *message)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This function is called when there is a warning, but the library
|
||||
thinks it can continue anyway. You don't have to do anything here
|
||||
if you don't want to. In the default configuration, png_ptr is
|
||||
/* This function is called when there is a warning, but the library thinks
|
||||
it can continue anyway. Replacement functions don't have to do anything
|
||||
here if you don't want to. In the default configuration, png_ptr is
|
||||
not used, but it is passed in case it may be useful. */
|
||||
void
|
||||
png_warning(png_struct *png_ptr, char *message)
|
||||
static void
|
||||
png_default_warning(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
if (!png_ptr)
|
||||
return;
|
||||
|
||||
#ifndef PNG_NO_STDIO
|
||||
fprintf(stderr, "libpng warning: %s\n", message);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This function is called when the application wants to use another method
|
||||
of handling errors and warnings. Note that the error function MUST NOT
|
||||
return to the calling routine or serious problems will occur. The return
|
||||
method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) */
|
||||
void
|
||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||
{
|
||||
png_ptr->error_ptr = error_ptr;
|
||||
png_ptr->error_fn = error_fn;
|
||||
png_ptr->warning_fn = warning_fn;
|
||||
}
|
||||
|
||||
|
||||
/* This function returns a pointer to the error_ptr associated with the user
|
||||
functions. The application should free any memory associated with this
|
||||
pointer before png_write_destroy and png_read_destroy are called. */
|
||||
png_voidp
|
||||
png_get_error_ptr(png_structp png_ptr)
|
||||
{
|
||||
return png_ptr->error_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
180
pngio.c
180
pngio.c
@@ -1,180 +0,0 @@
|
||||
|
||||
/* pngstub.c - stub functions for i/o and memory allocation
|
||||
|
||||
libpng 1.0 beta 2 - version 0.81
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 24, 1995
|
||||
|
||||
This file provides a location for all input/output. Users which need
|
||||
special handling are expected to modify the code in this file to meet
|
||||
their needs. See the instructions at each function. */
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
/* Write the data to whatever output you are using. The default
|
||||
routine writes to a file pointer. If you need to write to something
|
||||
else, this is the place to do it. We suggest saving the old code
|
||||
for future use, possibly in a #define. Note that this routine sometimes
|
||||
gets called with very small lengths, so you should implement some kind
|
||||
of simple buffering if you are using unbuffered writes. This should
|
||||
never be asked to write more then 64K on a 16 bit machine. The cast
|
||||
to png_size_t is there for insurance, but if you are having problems
|
||||
with it, you can take it out. Just be sure to cast length to whatever
|
||||
fwrite needs in that spot if you don't have a function prototype for
|
||||
it. */
|
||||
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
void
|
||||
png_write_data(png_struct *png_ptr, png_bytef *data, png_uint_32 length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
|
||||
check = fwrite(data, 1, (png_size_t)length, png_ptr->fp);
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* this is the model-independent version. Since the standard I/O library
|
||||
can't handle far buffers in the medium and small models, we have to copy
|
||||
the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* for FP_OFF */
|
||||
#include <dos.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
png_write_data(png_struct *png_ptr, png_bytef *data, png_uint_32 length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
png_byte *n_data;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
#ifdef _MSC_VER
|
||||
/* do it this way just to quiet warning */
|
||||
FP_OFF(n_data) = FP_OFF(data);
|
||||
if(FP_SEG(n_data) == FP_SEG(data))
|
||||
#else
|
||||
/* this works in MSC also but with lost segment warning */
|
||||
n_data = (png_byte *)data;
|
||||
if((png_bytef *)n_data == data)
|
||||
#endif
|
||||
{
|
||||
check = fwrite(n_data, 1, (png_size_t)length, png_ptr->fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t written, remaining, err;
|
||||
check = 0;
|
||||
remaining = (png_size_t)length;
|
||||
do
|
||||
{
|
||||
written = MIN(NEAR_BUF_SIZE,remaining);
|
||||
png_memcpy(buf,data,written); /* copy far buffer to near buffer */
|
||||
err = fwrite(buf, 1, written, png_ptr->fp);
|
||||
if(err != written)
|
||||
break;
|
||||
else
|
||||
check += err;
|
||||
data += written;
|
||||
remaining -= written;
|
||||
}
|
||||
while(remaining != 0);
|
||||
}
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Read the data from whatever input you are using. The default
|
||||
routine reads from a file pointer. If you need to read from something
|
||||
else, this is the place to do it. We suggest saving the old code
|
||||
for future use. Note that this routine sometimes gets called with
|
||||
very small lengths, so you should implement some kind of simple
|
||||
buffering if you are using unbuffered reads. This should
|
||||
never be asked to read more then 64K on a 16 bit machine. The cast
|
||||
to png_size_t is there for insurance, but if you are having problems
|
||||
with it, you can take it out. Just be sure to cast length to whatever
|
||||
fread needs in that spot if you don't have a function prototype for
|
||||
it. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
void
|
||||
png_read_data(png_struct *png_ptr, png_bytef *data, png_uint_32 length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
|
||||
check = fread(data, 1, (size_t)length, png_ptr->fp);
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
}
|
||||
#else
|
||||
void
|
||||
png_read_data(png_struct *png_ptr, png_bytef *data, png_uint_32 length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
png_byte *n_data;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
#ifdef _MSC_VER
|
||||
/* do it this way just to quiet warning */
|
||||
FP_OFF(n_data) = FP_OFF(data);
|
||||
if(FP_SEG(n_data) == FP_SEG(data))
|
||||
#else
|
||||
/* this works in MSC also but with lost segment warning */
|
||||
n_data = (png_byte *)data;
|
||||
if((png_bytef *)n_data == data)
|
||||
#endif
|
||||
{
|
||||
check = fread(n_data, 1, (size_t)length, png_ptr->fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t read, remaining, err;
|
||||
check = 0;
|
||||
remaining = (png_size_t)length;
|
||||
do
|
||||
{
|
||||
read = MIN(NEAR_BUF_SIZE,remaining);
|
||||
err = fread(buf, 1, read, png_ptr->fp);
|
||||
png_memcpy(data,buf,read); /* copy far buffer to near buffer */
|
||||
if(err != read)
|
||||
break;
|
||||
else
|
||||
check += err;
|
||||
data += read;
|
||||
remaining -= read;
|
||||
}
|
||||
while(remaining != 0);
|
||||
}
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "read Error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize the input/output for the png file. If you change
|
||||
the read and write routines, you will probably need to change
|
||||
this routine (or write your own). If you change the parameters
|
||||
of this routine, remember to change png.h also. */
|
||||
void
|
||||
png_init_io(png_struct *png_ptr, FILE *fp)
|
||||
{
|
||||
png_ptr->fp = fp;
|
||||
}
|
||||
|
||||
438
pngmem.c
438
pngmem.c
@@ -1,10 +1,10 @@
|
||||
|
||||
/* pngstub.c - stub functions for i/o and memory allocation
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
|
||||
libpng 1.0 beta 2 - version 0.81
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 24, 1995
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
|
||||
This file provides a location for all memory allocation. Users which
|
||||
need special memory handling are expected to modify the code in this file
|
||||
@@ -13,169 +13,270 @@
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
/* Borland DOS special memory handler */
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* if you change this, be sure to change the one in png.h also */
|
||||
|
||||
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
||||
* by a single call to calloc() if this is thought to improve performance.
|
||||
*/
|
||||
png_voidp
|
||||
png_create_struct(uInt type)
|
||||
{
|
||||
png_size_t type;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = sizeof(png_info);
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = sizeof(png_struct);
|
||||
else
|
||||
return (png_voidp)NULL;
|
||||
|
||||
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
|
||||
{
|
||||
png_memset(struct_ptr, 0, size);
|
||||
}
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
if (struct_ptr)
|
||||
farfree (struct_ptr);
|
||||
}
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
64K. However, zlib may allocate more then 64K if you don't tell
|
||||
it not to. See zconf.h and png.h for more information. zlib does
|
||||
need to allocate exactly 64K, so whatever you call here must
|
||||
have the ability to do that. */
|
||||
|
||||
/* Borland compilers have this habit of not giving you 64K chunks
|
||||
that start on the segment in DOS mode. This has not been observed
|
||||
in Windows, and of course it doesn't matter in 32 bit mode, as there
|
||||
are no segments. Now libpng doesn't need that much memory normally,
|
||||
but zlib does, so we have to normalize it, if necessary. It would be
|
||||
better if zlib worked in less then 64K, but it doesn't, so we
|
||||
have to deal with it. Truely, we are misusing farmalloc here,
|
||||
as it is designed for use with huge pointers, which don't care
|
||||
about segments. So we allocate a large amount of memory, and
|
||||
divvy off segments when needed.
|
||||
*/
|
||||
#ifdef __TURBOC__
|
||||
#ifndef __WIN32__
|
||||
#ifndef __FLAT__
|
||||
/* Borland seems to have a problem in DOS mode for exactly 64K.
|
||||
It gives you a segment with an offset of 8 (perhaps to store it's
|
||||
memory stuff). zlib doesn't like this at all, so we have to
|
||||
detect and deal with it. This code should not be needed in
|
||||
Windows or OS/2 modes, and only in 16 bit mode. This code has
|
||||
been updated by Alexander Lehmann for version 0.89 to waste less
|
||||
memory.
|
||||
*/
|
||||
|
||||
/* NUM_SEG is the number of segments allocated at once */
|
||||
#define NUM_SEG 4
|
||||
typedef struct borland_seg_struct
|
||||
png_voidp
|
||||
png_large_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
void *mem_ptr;
|
||||
void *seg_ptr[NUM_SEG];
|
||||
int seg_used[NUM_SEG];
|
||||
int num_used;
|
||||
} borland_seg;
|
||||
|
||||
borland_seg *save_array;
|
||||
int num_save_array;
|
||||
int max_save_array;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
voidpf
|
||||
png_large_malloc(png_structf *png_ptr, png_uint_32 size)
|
||||
{
|
||||
voidpf ret;
|
||||
png_voidp ret;
|
||||
if (!png_ptr || !size)
|
||||
return ((void *)0);
|
||||
return ((voidp)NULL);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||
#endif
|
||||
|
||||
#ifdef __TURBOC__
|
||||
# if defined(__WIN32__) || defined(__FLAT__)
|
||||
ret = malloc(size);
|
||||
# else
|
||||
|
||||
if (size == 65536L)
|
||||
if (size == (png_uint_32)(65536L))
|
||||
{
|
||||
unsigned long offset;
|
||||
if (!save_array)
|
||||
if (!png_ptr->offset_table)
|
||||
{
|
||||
/* try to see if we need to do any of this fancy stuff */
|
||||
ret = farmalloc(size);
|
||||
offset = (unsigned long)(ret);
|
||||
offset &= 0xffffL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = (void *)0;
|
||||
}
|
||||
if (save_array || offset)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (ret)
|
||||
farfree(ret);
|
||||
ret = (void *)0;
|
||||
|
||||
if (!save_array)
|
||||
if (!ret || ((long)ret & 0xffff))
|
||||
{
|
||||
unsigned long offset;
|
||||
png_byte huge *ptr;
|
||||
int num_blocks;
|
||||
png_uint_32 total_size;
|
||||
png_bytep table;
|
||||
int i;
|
||||
png_byte huge * hptr;
|
||||
|
||||
num_save_array = 1;
|
||||
save_array = malloc(num_save_array * sizeof (borland_seg));
|
||||
if (!save_array)
|
||||
png_error(png_ptr, "Out of Memory 1");
|
||||
save_array->mem_ptr = farmalloc(
|
||||
(unsigned long)(NUM_SEG) * 65536L + 65532L);
|
||||
if (!save_array->mem_ptr)
|
||||
png_error(png_ptr, "Out of Memory 2");
|
||||
offset = (unsigned long)(ret);
|
||||
offset &= 0xffffL;
|
||||
ptr = save_array->mem_ptr;
|
||||
if (offset)
|
||||
ptr += 65536L - offset;
|
||||
for (i = 0; i < NUM_SEG; i++, ptr += 65536L)
|
||||
{
|
||||
save_array->seg_ptr[i] = ptr;
|
||||
save_array->seg_used[i] = 0;
|
||||
}
|
||||
save_array->num_used = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_save_array; i++)
|
||||
{
|
||||
for (j = 0; j < NUM_SEG; j++)
|
||||
{
|
||||
if (!save_array[i].seg_used[j])
|
||||
{
|
||||
ret = save_array[i].seg_ptr[j];
|
||||
save_array[i].seg_used[j] = 1;
|
||||
save_array[i].num_used++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
farfree(ret);
|
||||
ret = NULL;
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
unsigned long offset;
|
||||
png_byte huge *ptr;
|
||||
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
|
||||
if (num_blocks < 1)
|
||||
num_blocks = 1;
|
||||
if (png_ptr->zlib_mem_level >= 7)
|
||||
num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
|
||||
else
|
||||
num_blocks++;
|
||||
|
||||
save_array = realloc(save_array,
|
||||
(num_save_array + 1) * sizeof (borland_seg));
|
||||
if (!save_array)
|
||||
png_error(png_ptr, "Out of Memory 3");
|
||||
save_array[num_save_array].mem_ptr = farmalloc(
|
||||
(unsigned long)(NUM_SEG) * 65536L + 65532L);
|
||||
if (!save_array[num_save_array].mem_ptr)
|
||||
png_error(png_ptr, "Out of Memory 4");
|
||||
offset = (unsigned long)(ret);
|
||||
offset &= 0xffffL;
|
||||
ptr = save_array[num_save_array].mem_ptr;
|
||||
if (offset)
|
||||
ptr += 65536L - offset;
|
||||
for (i = 0; i < NUM_SEG; i++, ptr += 65536L)
|
||||
total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16;
|
||||
|
||||
table = farmalloc(total_size);
|
||||
|
||||
if (!table)
|
||||
{
|
||||
save_array[num_save_array].seg_ptr[i] = ptr;
|
||||
save_array[num_save_array].seg_used[i] = 0;
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
}
|
||||
ret = save_array[num_save_array].seg_ptr[0];
|
||||
save_array[num_save_array].seg_used[0] = 1;
|
||||
save_array[num_save_array].num_used = 1;
|
||||
num_save_array++;
|
||||
|
||||
if ((long)table & 0xfff0)
|
||||
{
|
||||
png_error(png_ptr, "Farmalloc didn't return normalized pointer");
|
||||
}
|
||||
|
||||
png_ptr->offset_table = table;
|
||||
png_ptr->offset_table_ptr = farmalloc(
|
||||
num_blocks * sizeof (png_bytep));
|
||||
|
||||
if (!png_ptr->offset_table_ptr)
|
||||
{
|
||||
png_error(png_ptr, "Out of memory");
|
||||
}
|
||||
|
||||
hptr = (png_byte huge *)table;
|
||||
if ((long)hptr & 0xf)
|
||||
{
|
||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
||||
hptr += 16L;
|
||||
}
|
||||
for (i = 0; i < num_blocks; i++)
|
||||
{
|
||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||
hptr += 65536L;
|
||||
}
|
||||
|
||||
png_ptr->offset_table_number = num_blocks;
|
||||
png_ptr->offset_table_count = 0;
|
||||
png_ptr->offset_table_count_free = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
|
||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = farmalloc(size);
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
}
|
||||
|
||||
# endif /* __WIN32__ */
|
||||
#else /* __TURBOC__ */
|
||||
# ifdef _MSC_VER
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* free a pointer allocated by png_large_malloc(). In the default
|
||||
configuration, png_ptr is not used, but is passed in case it
|
||||
is needed. If ptr is NULL, return without taking any action. */
|
||||
void
|
||||
png_large_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (!png_ptr)
|
||||
return;
|
||||
|
||||
if (ptr != NULL)
|
||||
{
|
||||
if (png_ptr->offset_table)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < png_ptr->offset_table_count; i++)
|
||||
{
|
||||
if (ptr == png_ptr->offset_table_ptr[i])
|
||||
{
|
||||
ptr = 0;
|
||||
png_ptr->offset_table_count_free++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)
|
||||
{
|
||||
farfree(png_ptr->offset_table);
|
||||
farfree(png_ptr->offset_table_ptr);
|
||||
png_ptr->offset_table = 0;
|
||||
png_ptr->offset_table_ptr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ptr)
|
||||
farfree(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
#else /* Not the Borland DOS special memory handler */
|
||||
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
* memset can be replaced by a single call to calloc() if this is thought
|
||||
* to improve performance noticably.
|
||||
*/
|
||||
png_voidp
|
||||
png_create_struct(uInt type)
|
||||
{
|
||||
size_t size;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = sizeof(png_info);
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = sizeof(png_struct);
|
||||
else
|
||||
return (png_voidp)NULL;
|
||||
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
if ((struct_ptr = (png_voidp)halloc(size,1)) != NULL)
|
||||
# else
|
||||
if ((struct_ptr = (png_voidp)malloc(size)) != NULL)
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
png_memset(struct_ptr, 0, size);
|
||||
}
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
|
||||
|
||||
/* Free memory allocated by a png_create_struct() call */
|
||||
void
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
if (struct_ptr)
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(struct_ptr);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(struct_ptr);
|
||||
# else
|
||||
free(struct_ptr);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
64K. However, zlib may allocate more then 64K if you don't tell
|
||||
it not to. See zconf.h and png.h for more information. zlib does
|
||||
need to allocate exactly 64K, so whatever you call here must
|
||||
have the ability to do that. */
|
||||
|
||||
png_voidp
|
||||
png_large_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
if (!png_ptr || !size)
|
||||
return ((voidp)0);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||
#endif
|
||||
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
ret = farmalloc(size);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
ret = halloc(size, 1);
|
||||
# else
|
||||
/* everybody else, so normal malloc should do it. */
|
||||
# else
|
||||
ret = malloc(size);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (ret == NULL)
|
||||
@@ -190,92 +291,63 @@ png_large_malloc(png_structf *png_ptr, png_uint_32 size)
|
||||
configuration, png_ptr is not used, but is passed in case it
|
||||
is needed. If ptr is NULL, return without taking any action. */
|
||||
void
|
||||
png_large_free(png_structf *png_ptr, voidpf ptr)
|
||||
png_large_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (!png_ptr)
|
||||
return;
|
||||
|
||||
if (ptr != (void *)0)
|
||||
if (ptr != NULL)
|
||||
{
|
||||
#ifdef __TURBOC__
|
||||
# if defined(__WIN32__) || defined(__FLAT__)
|
||||
if (ptr)
|
||||
free(ptr);
|
||||
# else
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < num_save_array; i++)
|
||||
{
|
||||
for (j = 0; j < NUM_SEG; j++)
|
||||
{
|
||||
if (ptr == save_array[i].seg_ptr[j])
|
||||
{
|
||||
save_array[i].seg_used[j] = 0;
|
||||
ptr = 0;
|
||||
save_array[i].num_used--;
|
||||
if (!save_array[i].num_used)
|
||||
{
|
||||
int k;
|
||||
|
||||
num_save_array--;
|
||||
farfree(save_array[i].mem_ptr);
|
||||
for (k = i; k < num_save_array; k++)
|
||||
save_array[k] = save_array[k + 1];
|
||||
if (!num_save_array)
|
||||
{
|
||||
free(save_array);
|
||||
save_array = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ptr)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ptr)
|
||||
farfree(ptr);
|
||||
# endif
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(ptr);
|
||||
#else
|
||||
# ifdef _MSC_VER
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(ptr);
|
||||
# else
|
||||
# else
|
||||
free(ptr);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
|
||||
/* Allocate memory. This is called for smallish blocks only It
|
||||
should not get anywhere near 64K. */
|
||||
should not get anywhere near 64K. On segmented machines, this
|
||||
must come from the local heap (for zlib). Currently, zlib is
|
||||
the only one that uses this, so you should only get one call
|
||||
to this, and that a small block. */
|
||||
void *
|
||||
png_malloc(png_struct *png_ptr, png_uint_32 size)
|
||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
if (!png_ptr || !size)
|
||||
{
|
||||
return ((void *)0);
|
||||
}
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||
#endif
|
||||
|
||||
|
||||
ret = malloc((png_size_t)size);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
png_error(png_ptr, "Out of Memory 6");
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Reallocate memory. This will not get near 64K on a
|
||||
even marginally reasonable file. */
|
||||
even marginally reasonable file. This is not used in
|
||||
the current version of the library. */
|
||||
void *
|
||||
png_realloc(png_struct *png_ptr, void *ptr, png_uint_32 size,
|
||||
png_realloc(png_structp png_ptr, void * ptr, png_uint_32 size,
|
||||
png_uint_32 old_size)
|
||||
{
|
||||
void *ret;
|
||||
@@ -302,7 +374,7 @@ png_realloc(png_struct *png_ptr, void *ptr, png_uint_32 size,
|
||||
configuration, png_ptr is not used, but is passed incase it
|
||||
is needed. If ptr is NULL, return without taking any action. */
|
||||
void
|
||||
png_free(png_struct *png_ptr, void *ptr)
|
||||
png_free(png_structp png_ptr, void * ptr)
|
||||
{
|
||||
if (!png_ptr)
|
||||
return;
|
||||
|
||||
1324
pngpread.c
Normal file
1324
pngpread.c
Normal file
File diff suppressed because it is too large
Load Diff
100
pngrcb.c
100
pngrcb.c
@@ -1,16 +1,16 @@
|
||||
/* pngrcb.c - callbacks while reading a png file
|
||||
|
||||
libpng 1.0 beta 2 - version 0.81
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 24, 1995
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
void
|
||||
png_read_IHDR(png_struct *png_ptr, png_info *info,
|
||||
png_read_IHDR(png_structp png_ptr, png_infop info,
|
||||
png_uint_32 width, png_uint_32 height, int bit_depth,
|
||||
int color_type, int compression_type, int filter_type,
|
||||
int interlace_type)
|
||||
@@ -20,11 +20,11 @@ png_read_IHDR(png_struct *png_ptr, png_info *info,
|
||||
|
||||
info->width = width;
|
||||
info->height = height;
|
||||
info->bit_depth = bit_depth;
|
||||
info->color_type = color_type;
|
||||
info->compression_type = compression_type;
|
||||
info->filter_type = filter_type;
|
||||
info->interlace_type = interlace_type;
|
||||
info->bit_depth = (png_byte)bit_depth;
|
||||
info->color_type =(png_byte) color_type;
|
||||
info->compression_type = (png_byte)compression_type;
|
||||
info->filter_type = (png_byte)filter_type;
|
||||
info->interlace_type = (png_byte)interlace_type;
|
||||
if (info->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
info->channels = 1;
|
||||
else if (info->color_type & PNG_COLOR_MASK_COLOR)
|
||||
@@ -33,25 +33,25 @@ png_read_IHDR(png_struct *png_ptr, png_info *info,
|
||||
info->channels = 1;
|
||||
if (info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
info->channels++;
|
||||
info->pixel_depth = info->channels * info->bit_depth;
|
||||
info->pixel_depth = (png_byte)(info->channels * info->bit_depth);
|
||||
info->rowbytes = ((info->width * info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
|
||||
void
|
||||
png_read_PLTE(png_struct *png_ptr, png_info *info,
|
||||
png_color *palette, int num)
|
||||
png_read_PLTE(png_structp png_ptr, png_infop info,
|
||||
png_colorp palette, int num)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
return;
|
||||
|
||||
info->palette = palette;
|
||||
info->num_palette = num;
|
||||
info->num_palette = (png_uint_16)num;
|
||||
info->valid |= PNG_INFO_PLTE;
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||
void
|
||||
png_read_gAMA(png_struct *png_ptr, png_info *info, float gamma)
|
||||
png_read_gAMA(png_structp png_ptr, png_infop info, double gamma)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
return;
|
||||
@@ -63,22 +63,22 @@ png_read_gAMA(png_struct *png_ptr, png_info *info, float gamma)
|
||||
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
void
|
||||
png_read_sBIT(png_struct *png_ptr, png_info *info,
|
||||
png_color_8 *sig_bit)
|
||||
png_read_sBIT(png_structp png_ptr, png_infop info,
|
||||
png_color_8p sig_bit)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
return;
|
||||
|
||||
memcpy(&(info->sig_bit), sig_bit, sizeof (png_color_8));
|
||||
png_memcpy(&(info->sig_bit), sig_bit, sizeof (png_color_8));
|
||||
info->valid |= PNG_INFO_sBIT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||
void
|
||||
png_read_cHRM(png_struct *png_ptr, png_info *info,
|
||||
float white_x, float white_y, float red_x, float red_y,
|
||||
float green_x, float green_y, float blue_x, float blue_y)
|
||||
png_read_cHRM(png_structp png_ptr, png_infop info,
|
||||
double white_x, double white_y, double red_x, double red_y,
|
||||
double green_x, double green_y, double blue_x, double blue_y)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
return;
|
||||
@@ -97,8 +97,8 @@ png_read_cHRM(png_struct *png_ptr, png_info *info,
|
||||
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||
void
|
||||
png_read_tRNS(png_struct *png_ptr, png_info *info,
|
||||
png_byte *trans, int num_trans, png_color_16 *trans_values)
|
||||
png_read_tRNS(png_structp png_ptr, png_infop info,
|
||||
png_bytep trans, int num_trans, png_color_16p trans_values)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
return;
|
||||
@@ -109,30 +109,30 @@ png_read_tRNS(png_struct *png_ptr, png_info *info,
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&(info->trans_values), trans_values,
|
||||
png_memcpy(&(info->trans_values), trans_values,
|
||||
sizeof(png_color_16));
|
||||
}
|
||||
info->num_trans = num_trans;
|
||||
info->num_trans = (png_uint_16)num_trans;
|
||||
info->valid |= PNG_INFO_tRNS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||
void
|
||||
png_read_bKGD(png_struct *png_ptr, png_info *info,
|
||||
png_color_16 *background)
|
||||
png_read_bKGD(png_structp png_ptr, png_infop info,
|
||||
png_color_16p background)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
return;
|
||||
|
||||
memcpy(&(info->background), background, sizeof(png_color_16));
|
||||
png_memcpy(&(info->background), background, sizeof(png_color_16));
|
||||
info->valid |= PNG_INFO_bKGD;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
void
|
||||
png_read_hIST(png_struct *png_ptr, png_info *info, png_uint_16 *hist)
|
||||
png_read_hIST(png_structp png_ptr, png_infop info, png_uint_16p hist)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
return;
|
||||
@@ -144,7 +144,7 @@ png_read_hIST(png_struct *png_ptr, png_info *info, png_uint_16 *hist)
|
||||
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
void
|
||||
png_read_pHYs(png_struct *png_ptr, png_info *info,
|
||||
png_read_pHYs(png_structp png_ptr, png_infop info,
|
||||
png_uint_32 res_x, png_uint_32 res_y, int unit_type)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
@@ -152,14 +152,14 @@ png_read_pHYs(png_struct *png_ptr, png_info *info,
|
||||
|
||||
info->x_pixels_per_unit = res_x;
|
||||
info->y_pixels_per_unit = res_y;
|
||||
info->phys_unit_type = unit_type;
|
||||
info->phys_unit_type = (png_byte)unit_type;
|
||||
info->valid |= PNG_INFO_pHYs;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||
void
|
||||
png_read_oFFs(png_struct *png_ptr, png_info *info,
|
||||
png_read_oFFs(png_structp png_ptr, png_infop info,
|
||||
png_uint_32 offset_x, png_uint_32 offset_y, int unit_type)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
@@ -167,28 +167,28 @@ png_read_oFFs(png_struct *png_ptr, png_info *info,
|
||||
|
||||
info->x_offset = offset_x;
|
||||
info->y_offset = offset_y;
|
||||
info->offset_unit_type = unit_type;
|
||||
info->offset_unit_type = (png_byte)unit_type;
|
||||
info->valid |= PNG_INFO_oFFs;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||
void
|
||||
png_read_tIME(png_struct *png_ptr, png_info *info,
|
||||
png_time *mod_time)
|
||||
png_read_tIME(png_structp png_ptr, png_infop info,
|
||||
png_timep mod_time)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
return;
|
||||
|
||||
memcpy(&(info->mod_time), mod_time, sizeof (png_time));
|
||||
png_memcpy(&(info->mod_time), mod_time, sizeof (png_time));
|
||||
info->valid |= PNG_INFO_tIME;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
void
|
||||
png_read_zTXt(png_struct *png_ptr, png_info *info,
|
||||
charf *key, charf *text, png_uint_32 text_len, int compression)
|
||||
png_read_zTXt(png_structp png_ptr, png_infop info,
|
||||
png_charp key, png_charp text, png_uint_32 text_len, int compression)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
return;
|
||||
@@ -201,17 +201,23 @@ png_read_zTXt(png_struct *png_ptr, png_info *info,
|
||||
|
||||
old_max = info->max_text;
|
||||
info->max_text = info->num_text + 16;
|
||||
info->text = (png_text *)png_realloc(png_ptr,
|
||||
info->text,
|
||||
info->max_text * sizeof (png_text),
|
||||
old_max * sizeof (png_text));
|
||||
{
|
||||
png_textp old_text;
|
||||
|
||||
old_text = info->text;
|
||||
info->text = (png_textp)png_large_malloc(png_ptr,
|
||||
info->max_text * sizeof (png_text));
|
||||
png_memcpy(info->text, old_text,
|
||||
(png_size_t)(old_max * sizeof (png_text)));
|
||||
png_large_free(png_ptr, old_text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info->max_text = info->num_text + 16;
|
||||
info->text = (png_text *)png_malloc(png_ptr,
|
||||
info->max_text * sizeof (png_text));
|
||||
info->max_text = 16;
|
||||
info->num_text = 0;
|
||||
info->text = (png_textp)png_large_malloc(png_ptr,
|
||||
info->max_text * sizeof (png_text));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,8 +231,8 @@ png_read_zTXt(png_struct *png_ptr, png_info *info,
|
||||
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
void
|
||||
png_read_tEXt(png_struct *png_ptr, png_info *info,
|
||||
charf *key, charf *text, png_uint_32 text_len)
|
||||
png_read_tEXt(png_structp png_ptr, png_infop info,
|
||||
png_charp key, png_charp text, png_uint_32 text_len)
|
||||
{
|
||||
if (!png_ptr || !info)
|
||||
return;
|
||||
|
||||
588
pngread.c
588
pngread.c
@@ -1,46 +1,133 @@
|
||||
|
||||
/* pngread.c - read a png file
|
||||
|
||||
libpng 1.0 beta 2 - version 0.81
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 24, 1995
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
/* initialize png structure for reading, and allocate any memory needed */
|
||||
void
|
||||
png_read_init(png_struct *png_ptr)
|
||||
/* Create a png structure for reading, and allocate any memory needed. */
|
||||
png_structp
|
||||
png_create_read_struct(png_const_charp user_png_ver, voidp error_ptr,
|
||||
png_error_ptr warn_fn, png_error_ptr error_fn)
|
||||
{
|
||||
jmp_buf tmp_jmp;
|
||||
png_structp png_ptr;
|
||||
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
png_memset(png_ptr, 0, sizeof (png_struct));
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
|
||||
{
|
||||
return (png_structp)NULL;
|
||||
}
|
||||
|
||||
if (setjmp(png_ptr->jmpbuf))
|
||||
{
|
||||
png_large_free(png_ptr, png_ptr->zbuf);
|
||||
png_free(png_ptr, png_ptr->zstream);
|
||||
png_destroy_struct(png_ptr);
|
||||
return (png_structp)NULL;
|
||||
}
|
||||
|
||||
png_set_error_fn(png_ptr, error_ptr, warn_fn, error_fn);
|
||||
|
||||
if (user_png_ver == NULL || strcmp(user_png_ver, png_libpng_ver))
|
||||
{
|
||||
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0])
|
||||
{
|
||||
png_error(png_ptr, "Incompatible libpng versions");
|
||||
}
|
||||
else
|
||||
{
|
||||
png_warning(png_ptr, "Different libpng versions");
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_large_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_ptr->zstream = &(png_ptr->zstream_struct);
|
||||
|
||||
png_ptr->zstream = (z_stream *)png_malloc(png_ptr, sizeof (z_stream));
|
||||
png_ptr->zstream->zalloc = png_zalloc;
|
||||
png_ptr->zstream->zfree = png_zfree;
|
||||
png_ptr->zstream->opaque = (voidp)png_ptr;
|
||||
inflateInit(png_ptr->zstream);
|
||||
png_ptr->zstream->opaque = (voidpf)png_ptr;
|
||||
|
||||
switch (inflateInit(png_ptr->zstream))
|
||||
{
|
||||
case Z_OK: /* Do nothing */ break;
|
||||
case Z_MEM_ERROR:
|
||||
case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break;
|
||||
case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break;
|
||||
default: png_error(png_ptr, "Unknown zlib error");
|
||||
}
|
||||
|
||||
png_ptr->zstream->next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream->avail_out = (uInt)png_ptr->zbuf_size;
|
||||
|
||||
png_set_read_fn(png_ptr, NULL, NULL);
|
||||
|
||||
png_ptr->do_free |= PNG_FREE_STRUCT;
|
||||
|
||||
return (png_ptr);
|
||||
}
|
||||
|
||||
|
||||
/* initialize png structure for reading, and allocate any memory needed */
|
||||
/* This interface is depreciated in favour of the png_create_read_struct() */
|
||||
void
|
||||
png_read_init(png_structp png_ptr)
|
||||
{
|
||||
jmp_buf tmp_jmp; /* to save current jump buffer */
|
||||
|
||||
/* save jump buffer and error functions */
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
|
||||
/* reset all variables to 0 */
|
||||
png_memset(png_ptr, 0, sizeof (png_struct));
|
||||
|
||||
/* restore jump buffer */
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_large_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
|
||||
png_ptr->zstream = (z_stream *)png_malloc(png_ptr, sizeof (z_stream));
|
||||
png_ptr->zstream->zalloc = png_zalloc;
|
||||
png_ptr->zstream->zfree = png_zfree;
|
||||
png_ptr->zstream->opaque = (voidpf)png_ptr;
|
||||
|
||||
switch (inflateInit(png_ptr->zstream))
|
||||
{
|
||||
case Z_OK: /* Do nothing */ break;
|
||||
case Z_MEM_ERROR:
|
||||
case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break;
|
||||
case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break;
|
||||
default: png_error(png_ptr, "Unknown zlib error");
|
||||
}
|
||||
|
||||
png_ptr->zstream->next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream->avail_out = (uInt)png_ptr->zbuf_size;
|
||||
|
||||
png_set_read_fn(png_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
/* read the information before the actual image data. */
|
||||
void
|
||||
png_read_info(png_struct *png_ptr, png_info *info)
|
||||
png_read_info(png_structp png_ptr, png_infop info)
|
||||
{
|
||||
png_byte chunk_start[8];
|
||||
png_uint_32 length;
|
||||
|
||||
png_read_data(png_ptr, chunk_start, 8);
|
||||
if (memcmp(chunk_start, png_sig, 8))
|
||||
png_error(png_ptr, "Not a Png File");
|
||||
if (!png_check_sig(chunk_start, 8))
|
||||
{
|
||||
if (!png_check_sig(chunk_start, 4))
|
||||
png_error(png_ptr, "Not a PNG file");
|
||||
else
|
||||
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
@@ -50,168 +137,111 @@ png_read_info(png_struct *png_ptr, png_info *info)
|
||||
length = png_get_uint_32(chunk_start);
|
||||
png_reset_crc(png_ptr);
|
||||
png_calculate_crc(png_ptr, chunk_start + 4, 4);
|
||||
if (!memcmp(chunk_start + 4, png_IHDR, 4))
|
||||
{
|
||||
if (png_ptr->mode != PNG_BEFORE_IHDR)
|
||||
png_error(png_ptr, "Out of Place IHDR");
|
||||
|
||||
if (!png_memcmp(chunk_start + 4, png_IHDR, 4))
|
||||
png_handle_IHDR(png_ptr, info, length);
|
||||
png_ptr->mode = PNG_HAVE_IHDR;
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_PLTE, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_PLTE, 4))
|
||||
png_handle_PLTE(png_ptr, info, length);
|
||||
else if (!png_memcmp(chunk_start + 4, png_IDAT, 4))
|
||||
{
|
||||
if (png_ptr->mode != PNG_HAVE_IHDR)
|
||||
png_error(png_ptr, "Missing IHDR");
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
|
||||
if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
png_crc_skip(png_ptr, length);
|
||||
else
|
||||
#else
|
||||
{
|
||||
png_handle_PLTE(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
png_ptr->mode = PNG_HAVE_PLTE;
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_IDAT, 4))
|
||||
{
|
||||
png_ptr->idat_size = length;
|
||||
png_ptr->mode = PNG_HAVE_IDAT;
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
break;
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_IEND, 4))
|
||||
{
|
||||
png_error(png_ptr, "No Image in File");
|
||||
}
|
||||
else if (!png_memcmp(chunk_start + 4, png_IEND, 4))
|
||||
png_error(png_ptr, "No image in file");
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_gAMA, 4))
|
||||
{
|
||||
if (png_ptr->mode != PNG_HAVE_IHDR)
|
||||
png_error(png_ptr, "Out of Place PLTE");
|
||||
|
||||
else if (!png_memcmp(chunk_start + 4, png_gAMA, 4))
|
||||
png_handle_gAMA(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_sBIT, 4))
|
||||
{
|
||||
if (png_ptr->mode != PNG_HAVE_IHDR)
|
||||
png_error(png_ptr, "Out of Place sBIT");
|
||||
|
||||
else if (!png_memcmp(chunk_start + 4, png_sBIT, 4))
|
||||
png_handle_sBIT(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_cHRM, 4))
|
||||
{
|
||||
if (png_ptr->mode != PNG_HAVE_IHDR)
|
||||
png_error(png_ptr, "Out of Place cHRM");
|
||||
|
||||
else if (!png_memcmp(chunk_start + 4, png_cHRM, 4))
|
||||
png_handle_cHRM(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_tRNS, 4))
|
||||
{
|
||||
if (png_ptr->mode != PNG_HAVE_IHDR &&
|
||||
png_ptr->mode != PNG_HAVE_PLTE)
|
||||
png_error(png_ptr, "Out of Place tRNS");
|
||||
|
||||
else if (!png_memcmp(chunk_start + 4, png_tRNS, 4))
|
||||
png_handle_tRNS(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_bKGD, 4))
|
||||
{
|
||||
if (png_ptr->mode != PNG_HAVE_IHDR &&
|
||||
png_ptr->mode != PNG_HAVE_PLTE)
|
||||
png_error(png_ptr, "Out of Place bKGD");
|
||||
|
||||
else if (!png_memcmp(chunk_start + 4, png_bKGD, 4))
|
||||
png_handle_bKGD(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_hIST, 4))
|
||||
{
|
||||
if (png_ptr->mode != PNG_HAVE_PLTE)
|
||||
png_error(png_ptr, "Out of Place hIST");
|
||||
|
||||
else if (!png_memcmp(chunk_start + 4, png_hIST, 4))
|
||||
png_handle_hIST(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_pHYs, 4))
|
||||
{
|
||||
if (png_ptr->mode != PNG_HAVE_IHDR &&
|
||||
png_ptr->mode != PNG_HAVE_PLTE)
|
||||
png_error(png_ptr, "Out of Place pHYs");
|
||||
|
||||
else if (!png_memcmp(chunk_start + 4, png_pHYs, 4))
|
||||
png_handle_pHYs(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_oFFs, 4))
|
||||
{
|
||||
if (png_ptr->mode != PNG_HAVE_IHDR &&
|
||||
png_ptr->mode != PNG_HAVE_PLTE)
|
||||
png_error(png_ptr, "Out of Place oFFs");
|
||||
|
||||
else if (!png_memcmp(chunk_start + 4, png_oFFs, 4))
|
||||
png_handle_oFFs(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_tIME, 4))
|
||||
{
|
||||
if (png_ptr->mode == PNG_BEFORE_IHDR ||
|
||||
png_ptr->mode == PNG_AFTER_IEND)
|
||||
png_error(png_ptr, "Out of Place tIME");
|
||||
|
||||
else if (!png_memcmp(chunk_start + 4, png_tIME, 4))
|
||||
png_handle_tIME(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_tEXt, 4))
|
||||
{
|
||||
if (png_ptr->mode == PNG_BEFORE_IHDR ||
|
||||
png_ptr->mode == PNG_AFTER_IEND)
|
||||
png_error(png_ptr, "Out of Place tEXt");
|
||||
|
||||
else if (!png_memcmp(chunk_start + 4, png_tEXt, 4))
|
||||
png_handle_tEXt(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_zTXt, 4))
|
||||
{
|
||||
if (png_ptr->mode == PNG_BEFORE_IHDR ||
|
||||
png_ptr->mode == PNG_AFTER_IEND)
|
||||
png_error(png_ptr, "Out of Place zTXt");
|
||||
|
||||
else if (!png_memcmp(chunk_start + 4, png_zTXt, 4))
|
||||
png_handle_zTXt(png_ptr, info, length);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
if (chunk_start[4] < 41 || chunk_start[4] > 122 ||
|
||||
(chunk_start[4] > 90 && chunk_start[4] < 97) ||
|
||||
chunk_start[5] < 41 || chunk_start[5] > 122 ||
|
||||
(chunk_start[5] > 90 && chunk_start[5] < 97) ||
|
||||
chunk_start[6] < 41 || chunk_start[6] > 122 ||
|
||||
(chunk_start[6] > 90 && chunk_start[6] < 97) ||
|
||||
chunk_start[7] < 41 || chunk_start[7] > 122 ||
|
||||
(chunk_start[7] > 90 && chunk_start[7] < 97))
|
||||
{
|
||||
char msg[45];
|
||||
|
||||
sprintf(msg, "Invalid chunk type 0x%02X 0x%02X 0x%02X 0x%02X",
|
||||
chunk_start[4], chunk_start[5], chunk_start[6], chunk_start[7]);
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
|
||||
if ((chunk_start[4] & 0x20) == 0)
|
||||
png_error(png_ptr, "Unknown Critical Chunk");
|
||||
{
|
||||
char msg[40];
|
||||
|
||||
sprintf(msg, "Unknown critical chunk %c%c%c%c",
|
||||
chunk_start[4], chunk_start[5], chunk_start[6], chunk_start[7]);
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
|
||||
png_crc_skip(png_ptr, length);
|
||||
}
|
||||
png_read_data(png_ptr, chunk_start, 4);
|
||||
crc = png_get_uint_32(chunk_start);
|
||||
if (((crc ^ 0xffffffffL) & 0xffffffffL) !=
|
||||
(png_ptr->crc & 0xffffffffL))
|
||||
if (((crc ^ 0xffffffffL) & 0xffffffffL) != (png_ptr->crc & 0xffffffffL))
|
||||
png_error(png_ptr, "Bad CRC value");
|
||||
}
|
||||
}
|
||||
|
||||
/* optional call to update the users info structure */
|
||||
void
|
||||
png_read_update_info(png_struct *png_ptr, png_info *info_ptr)
|
||||
png_read_update_info(png_structp png_ptr, png_infop info)
|
||||
{
|
||||
if (!(png_ptr->row_init))
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
png_read_start_row(png_ptr);
|
||||
png_read_transform_info(png_ptr, info_ptr);
|
||||
png_read_transform_info(png_ptr, info);
|
||||
}
|
||||
|
||||
/* initialize palette, background, etc, after transformations
|
||||
@@ -219,17 +249,17 @@ png_read_update_info(png_struct *png_ptr, png_info *info_ptr)
|
||||
the user to obtail a gamma corrected palette, for example.
|
||||
If the user doesn't call this, we will do it ourselves. */
|
||||
void
|
||||
png_start_read_image(png_struct *png_ptr)
|
||||
png_start_read_image(png_structp png_ptr)
|
||||
{
|
||||
if (!(png_ptr->row_init))
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
png_read_start_row(png_ptr);
|
||||
}
|
||||
|
||||
void
|
||||
png_read_row(png_struct *png_ptr, png_bytef *row, png_byte *dsp_row)
|
||||
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
{
|
||||
int ret;
|
||||
if (!(png_ptr->row_init))
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
png_read_start_row(png_ptr);
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED)
|
||||
@@ -309,8 +339,8 @@ png_read_row(png_struct *png_ptr, png_bytef *row, png_byte *dsp_row)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (png_ptr->mode != PNG_HAVE_IDAT)
|
||||
png_error(png_ptr, "invalid attempt to read row data");
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT))
|
||||
png_error(png_ptr, "Invalid attempt to read row data");
|
||||
|
||||
png_ptr->zstream->next_out = png_ptr->row_buf;
|
||||
png_ptr->zstream->avail_out = (uInt)png_ptr->irowbytes;
|
||||
@@ -334,9 +364,8 @@ png_read_row(png_struct *png_ptr, png_bytef *row, png_byte *dsp_row)
|
||||
png_reset_crc(png_ptr);
|
||||
|
||||
png_crc_read(png_ptr, buf, 4);
|
||||
if (memcmp(buf, png_IDAT, 4))
|
||||
png_error(png_ptr, "Not enough image data");
|
||||
|
||||
if (png_memcmp(buf, png_IDAT, 4))
|
||||
png_error(png_ptr, "Not enough IDATs for image");
|
||||
}
|
||||
png_ptr->zstream->avail_in = (uInt)png_ptr->zbuf_size;
|
||||
png_ptr->zstream->next_in = png_ptr->zbuf;
|
||||
@@ -351,17 +380,15 @@ png_read_row(png_struct *png_ptr, png_bytef *row, png_byte *dsp_row)
|
||||
if (png_ptr->zstream->avail_out || png_ptr->zstream->avail_in ||
|
||||
png_ptr->idat_size)
|
||||
png_error(png_ptr, "Extra compressed data");
|
||||
png_ptr->mode = PNG_AT_LAST_IDAT;
|
||||
png_ptr->mode |= PNG_AT_LAST_IDAT;
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
break;
|
||||
}
|
||||
if (ret != Z_OK)
|
||||
png_error(png_ptr, "Compression Error");
|
||||
|
||||
png_error(png_ptr, png_ptr->zstream->msg ? png_ptr->zstream->msg :
|
||||
"Decompression error");
|
||||
} while (png_ptr->zstream->avail_out);
|
||||
|
||||
if (ret == Z_STREAM_END)
|
||||
png_ptr->zlib_finished = 1;
|
||||
|
||||
png_ptr->row_info.color_type = png_ptr->color_type;
|
||||
png_ptr->row_info.width = png_ptr->iwidth;
|
||||
png_ptr->row_info.channels = png_ptr->channels;
|
||||
@@ -370,10 +397,9 @@ png_read_row(png_struct *png_ptr, png_bytef *row, png_byte *dsp_row)
|
||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||
|
||||
if (png_ptr->row_buf[0])
|
||||
png_read_filter_row(&(png_ptr->row_info),
|
||||
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
||||
(int)(png_ptr->row_buf[0]));
|
||||
png_read_filter_row(png_ptr, &(png_ptr->row_info),
|
||||
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
||||
(int)(png_ptr->row_buf[0]));
|
||||
|
||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, (png_size_t)png_ptr->rowbytes + 1);
|
||||
|
||||
@@ -425,51 +451,58 @@ png_read_row(png_struct *png_ptr, png_bytef *row, png_byte *dsp_row)
|
||||
also, but you may. If the image is not interlaced, or if you have
|
||||
not called png_set_interlace_handling(), the display_row buffer will
|
||||
be ignored, so pass NULL to it. */
|
||||
|
||||
void
|
||||
png_read_rows(png_struct *png_ptr, png_bytef **row,
|
||||
png_byte **display_row, png_uint_32 num_rows)
|
||||
png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||
png_bytepp display_row, png_uint_32 num_rows)
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_bytef **rp;
|
||||
png_byte **dp;
|
||||
png_bytepp rp;
|
||||
png_bytepp dp;
|
||||
|
||||
rp = row;
|
||||
dp = display_row;
|
||||
for (i = 0; i < num_rows; i++)
|
||||
{
|
||||
png_bytef *rptr;
|
||||
png_byte *dptr;
|
||||
rp = row;
|
||||
dp = display_row;
|
||||
for (i = 0; i < num_rows; i++)
|
||||
{
|
||||
png_bytep rptr;
|
||||
png_bytep dptr;
|
||||
|
||||
if (rp)
|
||||
rptr = *rp;
|
||||
else
|
||||
rptr = NULL;
|
||||
if (dp)
|
||||
dptr = *dp;
|
||||
else
|
||||
dptr = NULL;
|
||||
png_read_row(png_ptr, rptr, dptr);
|
||||
if (row)
|
||||
rp++;
|
||||
if (display_row)
|
||||
dp++;
|
||||
}
|
||||
if (rp)
|
||||
rptr = *rp;
|
||||
else
|
||||
rptr = NULL;
|
||||
if (dp)
|
||||
dptr = *dp;
|
||||
else
|
||||
dptr = NULL;
|
||||
png_read_row(png_ptr, rptr, dptr);
|
||||
if (row)
|
||||
rp++;
|
||||
if (display_row)
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
|
||||
/* read the image. If the image has an alpha channel or a transparency
|
||||
chunk, and you have called png_handle_alpha(), you will need to
|
||||
chunk, and you have called png_handle_alpha(), you will need to
|
||||
initialize the image to the current image that png will be overlaying.
|
||||
Note that png_set_interlace_handling() has no effect on this call.
|
||||
You only need to call this function once. If you desire to have
|
||||
an image for each pass of a interlaced image, use png_read_rows() */
|
||||
We set the num_rows again here, in case it was incorrectly set in
|
||||
png_read_start_row() by a call to png_read_update_info() or
|
||||
png_start_read_image() if png_set_interlace_handling() wasn't called
|
||||
prior to either of these functions like it should have been. You only
|
||||
need to call this function once. If you desire to have an image for
|
||||
each pass of a interlaced image, use png_read_rows() instead */
|
||||
void
|
||||
png_read_image(png_struct *png_ptr, png_bytef **image)
|
||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||
{
|
||||
png_uint_32 i;
|
||||
int pass, j;
|
||||
png_bytef **rp;
|
||||
png_bytepp rp;
|
||||
|
||||
pass = png_set_interlace_handling(png_ptr);
|
||||
|
||||
png_ptr->num_rows = png_ptr->height; /* Make sure this is set correctly */
|
||||
|
||||
for (j = 0; j < pass; j++)
|
||||
{
|
||||
rp = image;
|
||||
@@ -485,7 +518,7 @@ png_read_image(png_struct *png_ptr, png_bytef **image)
|
||||
file, will verify the end is accurate, and will read any comments
|
||||
or time information at the end of the file, if info is not NULL. */
|
||||
void
|
||||
png_read_end(png_struct *png_ptr, png_info *info)
|
||||
png_read_end(png_structp png_ptr, png_infop info)
|
||||
{
|
||||
png_byte chunk_start[8];
|
||||
png_uint_32 length;
|
||||
@@ -504,57 +537,55 @@ png_read_end(png_struct *png_ptr, png_info *info)
|
||||
png_reset_crc(png_ptr);
|
||||
png_calculate_crc(png_ptr, chunk_start + 4, 4);
|
||||
|
||||
if (!memcmp(chunk_start + 4, png_IHDR, 4))
|
||||
if (!png_memcmp(chunk_start + 4, png_IHDR, 4))
|
||||
{
|
||||
png_error(png_ptr, "invalid chunk after IDAT");
|
||||
png_error(png_ptr, "Invalid IHDR after IDAT");
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_PLTE, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_PLTE, 4))
|
||||
{
|
||||
png_error(png_ptr, "invalid chunk after IDAT");
|
||||
png_error(png_ptr, "Invalid PLTE after IDAT");
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_gAMA, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_gAMA, 4))
|
||||
{
|
||||
png_error(png_ptr, "invalid chunk after IDAT");
|
||||
png_error(png_ptr, "Invalid gAMA after IDAT");
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_sBIT, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_sBIT, 4))
|
||||
{
|
||||
png_error(png_ptr, "invalid chunk after IDAT");
|
||||
png_error(png_ptr, "Invalid sBIT after IDAT");
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_cHRM, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_cHRM, 4))
|
||||
{
|
||||
png_error(png_ptr, "invalid chunk after IDAT");
|
||||
png_error(png_ptr, "Invalid cHRM after IDAT");
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_tRNS, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_tRNS, 4))
|
||||
{
|
||||
png_error(png_ptr, "invalid chunk after IDAT");
|
||||
png_error(png_ptr, "Invalid tRNS after IDAT");
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_bKGD, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_bKGD, 4))
|
||||
{
|
||||
png_error(png_ptr, "invalid chunk after IDAT");
|
||||
png_error(png_ptr, "Invalid bKGD after IDAT");
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_hIST, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_hIST, 4))
|
||||
{
|
||||
png_error(png_ptr, "invalid chunk after IDAT");
|
||||
png_error(png_ptr, "Invalid hIST after IDAT");
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_IDAT, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_IDAT, 4))
|
||||
{
|
||||
if (length > 0 || png_ptr->mode != PNG_AT_LAST_IDAT)
|
||||
png_error(png_ptr, "too many IDAT's found");
|
||||
if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_error(png_ptr, "Too many IDAT's found");
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_pHYs, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_pHYs, 4))
|
||||
{
|
||||
png_error(png_ptr, "invalid chunk after IDAT");
|
||||
png_error(png_ptr, "Invalid pHYs after IDAT");
|
||||
}
|
||||
else if (!memcmp(chunk_start + 4, png_oFFs, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_oFFs, 4))
|
||||
{
|
||||
png_error(png_ptr, "invalid chunk after IDAT");
|
||||
png_error(png_ptr, "Invalid oFFs after IDAT");
|
||||
}
|
||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_tIME, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_tIME, 4))
|
||||
{
|
||||
if (png_ptr->mode == PNG_BEFORE_IHDR ||
|
||||
png_ptr->mode == PNG_AFTER_IEND)
|
||||
png_error(png_ptr, "Out of Place tIME");
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
|
||||
if (info)
|
||||
png_handle_tIME(png_ptr, info, length);
|
||||
@@ -563,11 +594,9 @@ png_read_end(png_struct *png_ptr, png_info *info)
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_tEXt, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_tEXt, 4))
|
||||
{
|
||||
if (png_ptr->mode == PNG_BEFORE_IHDR ||
|
||||
png_ptr->mode == PNG_AFTER_IEND)
|
||||
png_error(png_ptr, "Out of Place tEXt");
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
|
||||
if (info)
|
||||
png_handle_tEXt(png_ptr, info, length);
|
||||
@@ -576,11 +605,9 @@ png_read_end(png_struct *png_ptr, png_info *info)
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
else if (!memcmp(chunk_start + 4, png_zTXt, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_zTXt, 4))
|
||||
{
|
||||
if (png_ptr->mode == PNG_BEFORE_IHDR ||
|
||||
png_ptr->mode == PNG_AFTER_IEND)
|
||||
png_error(png_ptr, "Out of Place zTXt");
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
|
||||
if (info)
|
||||
png_handle_zTXt(png_ptr, info, length);
|
||||
@@ -588,56 +615,95 @@ png_read_end(png_struct *png_ptr, png_info *info)
|
||||
png_crc_skip(png_ptr, length);
|
||||
}
|
||||
#endif
|
||||
else if (!memcmp(chunk_start + 4, png_IEND, 4))
|
||||
else if (!png_memcmp(chunk_start + 4, png_IEND, 4))
|
||||
{
|
||||
png_ptr->mode = PNG_AFTER_IEND;
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
png_ptr->mode |= PNG_AFTER_IEND;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((chunk_start[4] & 0x20) == 0)
|
||||
png_error(png_ptr, "Unknown Critical Chunk");
|
||||
if (chunk_start[4] < 41 || chunk_start[4] > 122 ||
|
||||
(chunk_start[4] > 90 && chunk_start[4] < 97) ||
|
||||
chunk_start[5] < 41 || chunk_start[5] > 122 ||
|
||||
(chunk_start[5] > 90 && chunk_start[5] < 97) ||
|
||||
chunk_start[6] < 41 || chunk_start[6] > 122 ||
|
||||
(chunk_start[6] > 90 && chunk_start[6] < 97) ||
|
||||
chunk_start[7] < 41 || chunk_start[7] > 122 ||
|
||||
(chunk_start[7] > 90 && chunk_start[7] < 97))
|
||||
{
|
||||
png_error(png_ptr, "Invalid chunk type");
|
||||
}
|
||||
|
||||
if ((chunk_start[4] & 0x20) == 0)
|
||||
png_error(png_ptr, "Unknown critical chunk");
|
||||
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
png_crc_skip(png_ptr, length);
|
||||
}
|
||||
png_read_data(png_ptr, chunk_start, 4);
|
||||
crc = png_get_uint_32(chunk_start);
|
||||
if (((crc ^ 0xffffffffL) & 0xffffffffL) !=
|
||||
(png_ptr->crc & 0xffffffffL))
|
||||
if (((crc ^ 0xffffffffL) & 0xffffffffL) != (png_ptr->crc & 0xffffffffL))
|
||||
png_error(png_ptr, "Bad CRC value");
|
||||
if (png_ptr->mode == PNG_AT_LAST_IDAT)
|
||||
png_ptr->mode = PNG_AFTER_IDAT;
|
||||
} while (png_ptr->mode != PNG_AFTER_IEND);
|
||||
} while (!(png_ptr->mode & PNG_AFTER_IEND));
|
||||
}
|
||||
|
||||
/* free all memory used by the read */
|
||||
void
|
||||
png_read_destroy(png_struct *png_ptr, png_info *info, png_info *end_info)
|
||||
png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
png_infopp end_info_ptr)
|
||||
{
|
||||
png_structp png_ptr = NULL;
|
||||
png_infop info_ptr = NULL, end_info = NULL;
|
||||
|
||||
if (png_ptr_ptr)
|
||||
png_ptr = *png_ptr_ptr;
|
||||
|
||||
if (info_ptr_ptr)
|
||||
info_ptr = *info_ptr_ptr;
|
||||
|
||||
if (end_info_ptr)
|
||||
end_info = *end_info_ptr;
|
||||
|
||||
png_read_destroy(png_ptr, info_ptr, end_info);
|
||||
|
||||
if (info_ptr)
|
||||
{
|
||||
png_destroy_struct((voidp)info_ptr);
|
||||
*info_ptr_ptr = (png_infop)NULL;
|
||||
}
|
||||
|
||||
if (end_info)
|
||||
{
|
||||
png_destroy_struct((voidp)end_info);
|
||||
*end_info_ptr = (png_infop)NULL;
|
||||
}
|
||||
|
||||
if (png_ptr)
|
||||
{
|
||||
png_destroy_struct((voidp)png_ptr);
|
||||
*png_ptr_ptr = (png_structp)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* free all memory used by the read (old) */
|
||||
void
|
||||
png_read_destroy(png_structp png_ptr, png_infop info, png_infop end_info)
|
||||
{
|
||||
int i;
|
||||
jmp_buf tmp_jmp;
|
||||
png_error_ptr error_fn;
|
||||
png_error_ptr warning_fn;
|
||||
png_voidp error_ptr;
|
||||
|
||||
if (info)
|
||||
{
|
||||
/* I'm not sure I should be freeing this */
|
||||
if (info->palette != png_ptr->palette)
|
||||
png_free(png_ptr, info->palette);
|
||||
/* I'm not sure I should be freeing this */
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_bKGD_SUPPORTED)
|
||||
if (info->trans != png_ptr->trans)
|
||||
png_free(png_ptr, info->trans);
|
||||
#endif
|
||||
/* I'm not sure I should be freeing this */
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
if (info->hist != png_ptr->hist)
|
||||
png_free(png_ptr, info->hist);
|
||||
#endif
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
for (i = 0; i < info->num_text; i++)
|
||||
{
|
||||
png_large_free(png_ptr, info->text[i].key);
|
||||
}
|
||||
|
||||
png_free(png_ptr, info->text);
|
||||
png_large_free(png_ptr, info->text);
|
||||
#endif
|
||||
png_memset(info, 0, sizeof(png_info));
|
||||
}
|
||||
@@ -650,7 +716,7 @@ png_read_destroy(png_struct *png_ptr, png_info *info, png_info *end_info)
|
||||
png_large_free(png_ptr, end_info->text[i].key);
|
||||
}
|
||||
|
||||
png_free(png_ptr, end_info->text);
|
||||
png_large_free(png_ptr, end_info->text);
|
||||
#endif
|
||||
png_memset(end_info, 0, sizeof(png_info));
|
||||
}
|
||||
@@ -660,56 +726,74 @@ png_read_destroy(png_struct *png_ptr, png_info *info, png_info *end_info)
|
||||
png_large_free(png_ptr, png_ptr->prev_row);
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
png_large_free(png_ptr, png_ptr->palette_lookup);
|
||||
png_free(png_ptr, png_ptr->dither_index);
|
||||
png_large_free(png_ptr, png_ptr->dither_index);
|
||||
#endif
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->gamma_table);
|
||||
png_large_free(png_ptr, png_ptr->gamma_table);
|
||||
#endif
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->gamma_from_1);
|
||||
png_free(png_ptr, png_ptr->gamma_to_1);
|
||||
png_large_free(png_ptr, png_ptr->gamma_from_1);
|
||||
png_large_free(png_ptr, png_ptr->gamma_to_1);
|
||||
#endif
|
||||
if (png_ptr->do_free & PNG_FREE_PALETTE)
|
||||
png_large_free(png_ptr, png_ptr->palette);
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_bKGD_SUPPORTED)
|
||||
if (png_ptr->do_free & PNG_FREE_TRANS)
|
||||
png_large_free(png_ptr, png_ptr->trans);
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
if (png_ptr->do_free & PNG_FREE_HIST)
|
||||
png_large_free(png_ptr, png_ptr->hist);
|
||||
#endif
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
if (png_ptr->gamma_16_table)
|
||||
{
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_table[i]);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_table[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->gamma_16_table);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_table);
|
||||
if (png_ptr->gamma_16_from_1)
|
||||
{
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_from_1[i]);
|
||||
}
|
||||
}
|
||||
png_free(png_ptr, png_ptr->gamma_16_from_1);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_from_1);
|
||||
if (png_ptr->gamma_16_to_1)
|
||||
{
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_to_1[i]);
|
||||
}
|
||||
}
|
||||
png_free(png_ptr, png_ptr->gamma_16_to_1);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_to_1);
|
||||
#endif
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->trans);
|
||||
#endif
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->hist);
|
||||
#endif
|
||||
if (!png_ptr->user_palette)
|
||||
png_free(png_ptr, png_ptr->palette);
|
||||
|
||||
inflateEnd(png_ptr->zstream);
|
||||
png_free(png_ptr, png_ptr->zstream);
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
png_large_free(png_ptr, png_ptr->save_buffer);
|
||||
#endif
|
||||
|
||||
/* Save the important info out of the png_struct, in case it is
|
||||
* being used again.
|
||||
*/
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
|
||||
error_fn = png_ptr->error_fn;
|
||||
warning_fn = png_ptr->warning_fn;
|
||||
error_ptr = png_ptr->error_ptr;
|
||||
|
||||
png_memset(png_ptr, 0, sizeof (png_struct));
|
||||
|
||||
png_ptr->error_fn = error_fn;
|
||||
png_ptr->warning_fn = warning_fn;
|
||||
png_ptr->error_ptr = error_ptr;
|
||||
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
}
|
||||
|
||||
|
||||
141
pngrio.c
Normal file
141
pngrio.c
Normal file
@@ -0,0 +1,141 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
|
||||
This file provides a location for all input. Users which need
|
||||
special handling are expected to write a function which has the same
|
||||
arguments as this, and perform a similar function, but possibly has
|
||||
a different input method. Note that you shouldn't change this
|
||||
function, but rather write a replacement function and then make
|
||||
libpng use it at run time with png_set_read_fn(...) */
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
/* Read the data from whatever input you are using. The default routine
|
||||
reads from a file pointer. Note that this routine sometimes gets called
|
||||
with very small lengths, so you should implement some kind of simple
|
||||
buffering if you are using unbuffered reads. This should never be asked
|
||||
to read more then 64K on a 16 bit machine. The cast to png_size_t is
|
||||
there to quiet some compilers */
|
||||
void
|
||||
png_read_data(png_structp png_ptr, png_bytep data, png_uint_32 length)
|
||||
{
|
||||
if (png_ptr->read_data_fn)
|
||||
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL read function");
|
||||
}
|
||||
|
||||
/* This is the function which does the actual reading of data. If you are
|
||||
not reading from a standard C stream, you should create a replacement
|
||||
read_data function and use it at run time with png_set_read_fn(), rather
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_uint_32 length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
|
||||
check = fread(data, 1, (size_t)length, (FILE *)png_ptr->io_ptr);
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* this is the model-independent version. Since the standard I/O library
|
||||
can't handle far buffers in the medium and small models, we have to copy
|
||||
the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* for FP_OFF */
|
||||
#include <dos.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_uint_32 length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
png_byte *n_data;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
#ifdef _MSC_VER
|
||||
/* do it this way just to quiet warning */
|
||||
FP_OFF(n_data) = FP_OFF(data);
|
||||
if (FP_SEG(n_data) == FP_SEG(data))
|
||||
#else
|
||||
/* this works in MSC also but with lost segment warning */
|
||||
n_data = (png_byte *)data;
|
||||
if ((png_bytep)n_data == data)
|
||||
#endif
|
||||
{
|
||||
check = fread(n_data, 1, (size_t)length, (FILE *)png_ptr->io_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t read, remaining, err;
|
||||
check = 0;
|
||||
remaining = (png_size_t)length;
|
||||
do
|
||||
{
|
||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||
err = fread(buf, 1, read, (FILE *)png_ptr->io_ptr);
|
||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
||||
if(err != read)
|
||||
break;
|
||||
else
|
||||
check += err;
|
||||
data += read;
|
||||
remaining -= read;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "read Error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function allows the application to supply a new input function
|
||||
for libpng if standard C streams aren't being used.
|
||||
|
||||
This function takes as its arguments:
|
||||
png_ptr - pointer to a png input data structure
|
||||
io_ptr - pointer to user supplied structure containing info about
|
||||
the input functions. May be NULL.
|
||||
read_data_fn - pointer to a new input function which takes as it's
|
||||
arguments a pointer to a png_struct, a pointer to
|
||||
a location where input data can be stored, and a 32-bit
|
||||
unsigned int which is the number of bytes to be read.
|
||||
To exit and output any fatal error messages the new write
|
||||
function should call png_error(png_ptr, "Error msg"). */
|
||||
void
|
||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
png_ptr->io_ptr = io_ptr;
|
||||
|
||||
if (read_data_fn)
|
||||
png_ptr->read_data_fn = read_data_fn;
|
||||
else
|
||||
png_ptr->read_data_fn = png_default_read_data;
|
||||
|
||||
/* It is an error to write to a read device */
|
||||
png_ptr->write_data_fn = NULL;
|
||||
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
png_ptr->output_flush_fn = NULL;
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
}
|
||||
|
||||
810
pngrtran.c
810
pngrtran.c
File diff suppressed because it is too large
Load Diff
509
pngrutil.c
509
pngrutil.c
File diff suppressed because it is too large
Load Diff
294
pngtest.c
294
pngtest.c
@@ -1,10 +1,10 @@
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
|
||||
libpng 1.0 beta 2 - version 0.81
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 24, 1995
|
||||
*/
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -15,28 +15,35 @@
|
||||
#endif
|
||||
|
||||
/* defined so I can write to a file on gui/windowing platforms */
|
||||
#define STDERR stderr
|
||||
/* #define STDERR stderr */
|
||||
#define STDERR stdout /* for DOS */
|
||||
|
||||
/* input and output filenames */
|
||||
char inname[] = "pngtest.png";
|
||||
char outname[] = "pngout.png";
|
||||
|
||||
png_struct read_ptr;
|
||||
png_struct write_ptr;
|
||||
png_info info_ptr;
|
||||
png_info end_info;
|
||||
#ifdef RISCOS
|
||||
char *inname = "pngtest_pn";
|
||||
char *outname = "pngout_png";
|
||||
#else
|
||||
char *inname = "pngtest.png";
|
||||
char *outname = "pngout.png";
|
||||
#endif
|
||||
|
||||
char inbuf[256], outbuf[256];
|
||||
|
||||
int main()
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fpin, *fpout;
|
||||
png_byte *row_buf;
|
||||
png_uint_32 rowbytes;
|
||||
FILE *fpin, *fpout;
|
||||
png_structp read_ptr;
|
||||
png_structp write_ptr;
|
||||
png_infop info_ptr;
|
||||
png_infop end_info;
|
||||
png_bytep row_buf;
|
||||
png_byte *near_row_buf;
|
||||
png_uint_32 rowbytes;
|
||||
png_uint_32 y;
|
||||
int channels, num_pass, pass;
|
||||
int channels, num_pass, pass;
|
||||
|
||||
row_buf = (png_byte *)0;
|
||||
row_buf = (png_bytep)NULL;
|
||||
near_row_buf = (png_byte *)NULL;
|
||||
|
||||
fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
|
||||
|
||||
@@ -48,142 +55,165 @@ int main()
|
||||
fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver);
|
||||
}
|
||||
|
||||
fpin = fopen(inname, "rb");
|
||||
if (!fpin)
|
||||
{
|
||||
fprintf(STDERR, "Could not find input file %s\n", inname);
|
||||
return 1;
|
||||
}
|
||||
if (argc > 1)
|
||||
inname = argv[1];
|
||||
|
||||
fpout = fopen(outname, "wb");
|
||||
if (!fpout)
|
||||
{
|
||||
fprintf(STDERR, "could not open output file %s\n", outname);
|
||||
fclose(fpin);
|
||||
return 1;
|
||||
}
|
||||
if (argc > 2)
|
||||
outname = argv[2];
|
||||
|
||||
if (setjmp(read_ptr.jmpbuf))
|
||||
{
|
||||
fprintf(STDERR, "libpng read error\n");
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
}
|
||||
if (argc > 3)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [infile.png] [outfile.png]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (setjmp(write_ptr.jmpbuf))
|
||||
{
|
||||
fprintf(STDERR, "libpng write error\n");
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
}
|
||||
fpin = fopen(inname, "rb");
|
||||
if (!fpin)
|
||||
{
|
||||
fprintf(STDERR, "Could not find input file %s\n", inname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
png_read_init(&read_ptr);
|
||||
png_write_init(&write_ptr);
|
||||
png_info_init(&info_ptr);
|
||||
png_info_init(&end_info);
|
||||
fpout = fopen(outname, "wb");
|
||||
if (!fpout)
|
||||
{
|
||||
fprintf(STDERR, "Could not open output file %s\n", outname);
|
||||
fclose(fpin);
|
||||
return 1;
|
||||
}
|
||||
|
||||
png_init_io(&read_ptr, fpin);
|
||||
png_init_io(&write_ptr, fpout);
|
||||
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (void *)NULL,
|
||||
(png_error_ptr)NULL, (png_error_ptr)NULL);
|
||||
write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (void *)NULL,
|
||||
(png_error_ptr)NULL, (png_error_ptr)NULL);
|
||||
info_ptr = png_create_info_struct(read_ptr);
|
||||
end_info = png_create_info_struct(read_ptr);
|
||||
|
||||
png_read_info(&read_ptr, &info_ptr);
|
||||
png_write_info(&write_ptr, &info_ptr);
|
||||
if (setjmp(read_ptr->jmpbuf))
|
||||
{
|
||||
fprintf(STDERR, "libpng read error\n");
|
||||
png_destroy_read_struct(&read_ptr, &info_ptr, &end_info);
|
||||
png_destroy_write_struct(&write_ptr, (png_infopp)NULL);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((info_ptr.color_type & 3) == 2)
|
||||
channels = 3;
|
||||
else
|
||||
channels = 1;
|
||||
if (info_ptr.color_type & 4)
|
||||
channels++;
|
||||
if (setjmp(write_ptr->jmpbuf))
|
||||
{
|
||||
fprintf(STDERR, "libpng write error\n");
|
||||
png_destroy_read_struct(&read_ptr, &info_ptr, &end_info);
|
||||
png_destroy_write_struct(&write_ptr, (png_infopp)NULL);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rowbytes = ((info_ptr.width * info_ptr.bit_depth * channels + 7) >> 3);
|
||||
row_buf = (png_byte *)malloc((size_t)rowbytes);
|
||||
if (!row_buf)
|
||||
{
|
||||
fprintf(STDERR, "no memory to allocate row buffer\n");
|
||||
png_read_destroy(&read_ptr, &info_ptr, (png_info *)0);
|
||||
png_write_destroy(&write_ptr);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
}
|
||||
png_init_io(read_ptr, fpin);
|
||||
png_init_io(write_ptr, fpout);
|
||||
|
||||
if (info_ptr.interlace_type)
|
||||
{
|
||||
num_pass = png_set_interlace_handling(&read_ptr);
|
||||
num_pass = png_set_interlace_handling(&write_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
num_pass = 1;
|
||||
}
|
||||
png_read_info(read_ptr, info_ptr);
|
||||
png_write_info(write_ptr, info_ptr);
|
||||
|
||||
for (pass = 0; pass < num_pass; pass++)
|
||||
{
|
||||
for (y = 0; y < info_ptr.height; y++)
|
||||
{
|
||||
png_read_rows(&read_ptr, (png_bytef **)&row_buf, (png_bytef **)0, 1);
|
||||
png_write_rows(&write_ptr, (png_bytef **)&row_buf, 1);
|
||||
}
|
||||
}
|
||||
if ((info_ptr->color_type & PNG_COLOR_TYPE_PALETTE)==PNG_COLOR_TYPE_PALETTE)
|
||||
channels = 1;
|
||||
else
|
||||
channels = 3;
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
channels++;
|
||||
|
||||
png_read_end(&read_ptr, &end_info);
|
||||
png_write_end(&write_ptr, &end_info);
|
||||
rowbytes = ((info_ptr->width * info_ptr->bit_depth * channels + 7) >> 3);
|
||||
near_row_buf = (png_byte *)malloc((size_t)rowbytes);
|
||||
row_buf = (png_bytep)near_row_buf;
|
||||
if (!row_buf)
|
||||
{
|
||||
fprintf(STDERR, "No memory to allocate row buffer\n");
|
||||
png_destroy_read_struct(&read_ptr, &info_ptr, &end_info);
|
||||
png_destroy_write_struct(&write_ptr, (png_infopp)NULL);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
png_read_destroy(&read_ptr, &info_ptr, &end_info);
|
||||
png_write_destroy(&write_ptr);
|
||||
if (info_ptr->interlace_type)
|
||||
{
|
||||
num_pass = png_set_interlace_handling(read_ptr);
|
||||
num_pass = png_set_interlace_handling(write_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
num_pass = 1;
|
||||
}
|
||||
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
for (pass = 0; pass < num_pass; pass++)
|
||||
{
|
||||
for (y = 0; y < info_ptr->height; y++)
|
||||
{
|
||||
#ifdef TESTING
|
||||
fprintf(STDERR, "Processing line #%ld\n", y);
|
||||
#endif
|
||||
png_read_rows(read_ptr, (png_bytepp)&row_buf, (png_bytepp)0, 1);
|
||||
png_write_rows(write_ptr, (png_bytepp)&row_buf, 1);
|
||||
}
|
||||
}
|
||||
|
||||
free(row_buf);
|
||||
png_read_end(read_ptr, end_info);
|
||||
png_write_end(write_ptr, end_info);
|
||||
|
||||
fpin = fopen(inname, "rb");
|
||||
png_destroy_read_struct(&read_ptr, &info_ptr, &end_info);
|
||||
png_destroy_write_struct(&write_ptr, (png_infopp)NULL);
|
||||
|
||||
if (!fpin)
|
||||
{
|
||||
fprintf(STDERR, "could not find file %s\n", inname);
|
||||
return 1;
|
||||
}
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
|
||||
fpout = fopen(outname, "rb");
|
||||
if (!fpout)
|
||||
{
|
||||
fprintf(STDERR, "could not find file %s\n", outname);
|
||||
fclose(fpin);
|
||||
return 1;
|
||||
}
|
||||
free((void *)near_row_buf);
|
||||
|
||||
while (1)
|
||||
{
|
||||
int num_in, num_out;
|
||||
fpin = fopen(inname, "rb");
|
||||
|
||||
num_in = fread(inbuf, 1, 256, fpin);
|
||||
num_out = fread(outbuf, 1, 256, fpout);
|
||||
if (!fpin)
|
||||
{
|
||||
fprintf(STDERR, "Could not find file %s\n", inname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (num_in != num_out)
|
||||
{
|
||||
fprintf(STDERR, "files are of a different size\n");
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
}
|
||||
fpout = fopen(outname, "rb");
|
||||
if (!fpout)
|
||||
{
|
||||
fprintf(STDERR, "Could not find file %s\n", outname);
|
||||
fclose(fpin);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!num_in)
|
||||
break;
|
||||
while (1)
|
||||
{
|
||||
int num_in, num_out;
|
||||
|
||||
if (memcmp(inbuf, outbuf, num_in))
|
||||
{
|
||||
fprintf(STDERR, "files are different\n");
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
num_in = fread(inbuf, 1, 256, fpin);
|
||||
num_out = fread(outbuf, 1, 256, fpout);
|
||||
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
if (num_in != num_out)
|
||||
{
|
||||
fprintf(STDERR, "Files %s and %s are of a different size\n",
|
||||
inname, outname);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!num_in)
|
||||
break;
|
||||
|
||||
if (memcmp(inbuf, outbuf, num_in))
|
||||
{
|
||||
fprintf(STDERR, "Files %s and %s are different\n", inname, outname);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
fprintf(STDERR, "libpng passes test\n");
|
||||
|
||||
return 0;
|
||||
|
||||
BIN
pngtest.png
BIN
pngtest.png
Binary file not shown.
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 8.3 KiB |
20
pngtodo.txt
20
pngtodo.txt
@@ -1,18 +1,16 @@
|
||||
pngtodo.txt - list of things to do for libpng
|
||||
|
||||
for 0.9
|
||||
medium memory model
|
||||
improved dithering?
|
||||
|
||||
for 1.1
|
||||
push reader
|
||||
|
||||
for 1.1 or later
|
||||
overlaying one image on top of another
|
||||
optional palette creation
|
||||
histogram creation
|
||||
text conversion between different code types
|
||||
improved dithering
|
||||
final bug fixes
|
||||
cHRM transformation
|
||||
better documentation
|
||||
|
||||
after 1.0
|
||||
overlaying one image on top of another
|
||||
optional palette creation
|
||||
histogram creation
|
||||
text conversion between different code types
|
||||
support for other chunks being defined (sCAl, the gIF series,
|
||||
and others that people come up with).
|
||||
pull writer
|
||||
|
||||
50
pngtrans.c
50
pngtrans.c
@@ -2,10 +2,10 @@
|
||||
/* pngtrans.c - transforms the data in a row
|
||||
routines used by both readers and writers
|
||||
|
||||
libpng 1.0 beta 2 - version 0.81
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 24, 1995
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -14,7 +14,7 @@
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* turn on bgr to rgb mapping */
|
||||
void
|
||||
png_set_bgr(png_struct *png_ptr)
|
||||
png_set_bgr(png_structp png_ptr)
|
||||
{
|
||||
png_ptr->transformations |= PNG_BGR;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ png_set_bgr(png_struct *png_ptr)
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* turn on 16 bit byte swapping */
|
||||
void
|
||||
png_set_swap(png_struct *png_ptr)
|
||||
png_set_swap(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->bit_depth == 16)
|
||||
png_ptr->transformations |= PNG_SWAP_BYTES;
|
||||
@@ -33,7 +33,7 @@ png_set_swap(png_struct *png_ptr)
|
||||
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
/* turn on pixel packing */
|
||||
void
|
||||
png_set_packing(png_struct *png_ptr)
|
||||
png_set_packing(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->bit_depth < 8)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ png_set_packing(png_struct *png_ptr)
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
void
|
||||
png_set_shift(png_struct *png_ptr, png_color_8 *true_bits)
|
||||
png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||
{
|
||||
png_ptr->transformations |= PNG_SHIFT;
|
||||
png_ptr->shift = *true_bits;
|
||||
@@ -54,7 +54,7 @@ png_set_shift(png_struct *png_ptr, png_color_8 *true_bits)
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
int
|
||||
png_set_interlace_handling(png_struct *png_ptr)
|
||||
png_set_interlace_handling(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
@@ -68,11 +68,15 @@ png_set_interlace_handling(png_struct *png_ptr)
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
void
|
||||
png_set_filler(png_struct *png_ptr, int filler, int filler_loc)
|
||||
png_set_filler(png_structp png_ptr, int filler, int filler_loc)
|
||||
{
|
||||
png_ptr->transformations |= PNG_FILLER;
|
||||
png_ptr->filler = (png_byte)filler;
|
||||
png_ptr->filler_loc = (png_byte)filler_loc;
|
||||
if (filler_loc == PNG_FILLER_AFTER)
|
||||
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
png_ptr->bit_depth == 8)
|
||||
png_ptr->usr_channels = 4;
|
||||
@@ -80,13 +84,13 @@ png_set_filler(png_struct *png_ptr, int filler, int filler_loc)
|
||||
|
||||
/* old functions kept around for compatability purposes */
|
||||
void
|
||||
png_set_rgbx(png_struct *png_ptr)
|
||||
png_set_rgbx(png_structp png_ptr)
|
||||
{
|
||||
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
|
||||
}
|
||||
|
||||
void
|
||||
png_set_xrgb(png_struct *png_ptr)
|
||||
png_set_xrgb(png_structp png_ptr)
|
||||
{
|
||||
png_set_filler(png_ptr, 0xff, PNG_FILLER_BEFORE);
|
||||
}
|
||||
@@ -94,26 +98,26 @@ png_set_xrgb(png_struct *png_ptr)
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
void
|
||||
png_set_invert_mono(png_struct *png_ptr)
|
||||
png_set_invert_mono(png_structp png_ptr)
|
||||
{
|
||||
png_ptr->transformations |= PNG_INVERT_MONO;
|
||||
}
|
||||
|
||||
/* invert monocrome grayscale data */
|
||||
void
|
||||
png_do_invert(png_row_info *row_info, png_bytef *row)
|
||||
png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
if (row && row_info && row_info->bit_depth == 1 &&
|
||||
row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
png_bytef *rp;
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, rp = row;
|
||||
i < row_info->rowbytes;
|
||||
i++, rp++)
|
||||
{
|
||||
*rp = ~(*rp);
|
||||
*rp = (png_byte)(~(*rp));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,11 +126,11 @@ png_do_invert(png_row_info *row_info, png_bytef *row)
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* swaps byte order on 16 bit depth images */
|
||||
void
|
||||
png_do_swap(png_row_info *row_info, png_bytef *row)
|
||||
png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
if (row && row_info && row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytef *rp;
|
||||
png_bytep rp;
|
||||
png_byte t;
|
||||
png_uint_32 i;
|
||||
|
||||
@@ -145,13 +149,13 @@ png_do_swap(png_row_info *row_info, png_bytef *row)
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* swaps red and blue */
|
||||
void
|
||||
png_do_bgr(png_row_info *row_info, png_bytef *row)
|
||||
png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
if (row && row_info && (row_info->color_type & 2))
|
||||
{
|
||||
if (row_info->color_type == 2 && row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytef *rp;
|
||||
png_bytep rp;
|
||||
png_byte t;
|
||||
png_uint_32 i;
|
||||
|
||||
@@ -166,7 +170,7 @@ png_do_bgr(png_row_info *row_info, png_bytef *row)
|
||||
}
|
||||
else if (row_info->color_type == 6 && row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytef *rp;
|
||||
png_bytep rp;
|
||||
png_byte t;
|
||||
png_uint_32 i;
|
||||
|
||||
@@ -181,7 +185,7 @@ png_do_bgr(png_row_info *row_info, png_bytef *row)
|
||||
}
|
||||
else if (row_info->color_type == 2 && row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytef *rp;
|
||||
png_bytep rp;
|
||||
png_byte t[2];
|
||||
png_uint_32 i;
|
||||
|
||||
@@ -199,7 +203,7 @@ png_do_bgr(png_row_info *row_info, png_bytef *row)
|
||||
}
|
||||
else if (row_info->color_type == 6 && row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytef *rp;
|
||||
png_bytep rp;
|
||||
png_byte t[2];
|
||||
png_uint_32 i;
|
||||
|
||||
|
||||
174
pngwio.c
Normal file
174
pngwio.c
Normal file
@@ -0,0 +1,174 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
|
||||
This file provides a location for all output. Users which need
|
||||
special handling are expected to write functions which have the same
|
||||
arguments as these, and perform similar functions, but possibly use
|
||||
different output methods. Note that you shouldn't change these
|
||||
functions, but rather write replacement functions and then change
|
||||
them at run time with png_set_write_fn(...) */
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
/* Write the data to whatever output you are using. The default routine
|
||||
writes to a file pointer. Note that this routine sometimes gets called
|
||||
with very small lengths, so you should implement some kind of simple
|
||||
buffering if you are using unbuffered writes. This should never be asked
|
||||
to write more then 64K on a 16 bit machine. The cast to png_size_t is
|
||||
there to quiet warnings of certain compilers. */
|
||||
|
||||
void
|
||||
png_write_data(png_structp png_ptr, png_bytep data, png_uint_32 length)
|
||||
{
|
||||
if (png_ptr->write_data_fn)
|
||||
(*(png_ptr->write_data_fn))(png_ptr, data, length);
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL write function");
|
||||
}
|
||||
|
||||
/* This is the function which does the actual writing of data. If you are
|
||||
not writing to a standard C stream, you should create a replacement
|
||||
write_data function and use it at run time with png_set_write_fn(), rather
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_uint_32 length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
|
||||
check = fwrite(data, 1, (png_size_t)length, (FILE *)(png_ptr->io_ptr));
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* this is the model-independent version. Since the standard I/O library
|
||||
can't handle far buffers in the medium and small models, we have to copy
|
||||
the data.
|
||||
*/
|
||||
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* for FP_OFF */
|
||||
#include <dos.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_uint_32 length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
png_byte *n_data;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
#ifdef _MSC_VER
|
||||
/* do it this way just to quiet warning */
|
||||
FP_OFF(n_data) = FP_OFF(data);
|
||||
if (FP_SEG(n_data) == FP_SEG(data))
|
||||
#else
|
||||
/* this works in MSC also but with lost segment warning */
|
||||
n_data = (png_byte *)data;
|
||||
if ((png_bytep)n_data == data)
|
||||
#endif
|
||||
{
|
||||
check = fwrite(n_data, 1, (png_size_t)length, (FILE *)(png_ptr->io_ptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t written, remaining, err;
|
||||
check = 0;
|
||||
remaining = (png_size_t)length;
|
||||
do
|
||||
{
|
||||
written = MIN(NEAR_BUF_SIZE, remaining);
|
||||
png_memcpy(buf, data, written); /* copy far buffer to near buffer */
|
||||
err = fwrite(buf, 1, written, (FILE *)(png_ptr->io_ptr));
|
||||
if (err != written)
|
||||
break;
|
||||
else
|
||||
check += err;
|
||||
data += written;
|
||||
remaining -= written;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* This function is called to output any data pending writing (normally
|
||||
to disk). After png_flush is called, there should be no data pending
|
||||
writing in any buffers. */
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
void
|
||||
png_flush(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->output_flush_fn)
|
||||
(*(png_ptr->output_flush_fn))(png_ptr);
|
||||
}
|
||||
|
||||
static void
|
||||
png_default_flush(png_structp png_ptr)
|
||||
{
|
||||
if ((FILE *)(png_ptr->io_ptr))
|
||||
fflush((FILE *)(png_ptr->io_ptr));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function allows the application to supply new output functions for
|
||||
libpng if standard C streams aren't being used.
|
||||
|
||||
This function takes as its arguments:
|
||||
png_ptr - pointer to a png output data structure
|
||||
io_ptr - pointer to user supplied structure containing info about
|
||||
the output functions. May be NULL.
|
||||
write_data_fn - pointer to a new output function which takes as its
|
||||
arguments a pointer to a png_struct, a pointer to
|
||||
data to be written, and a 32-bit unsigned int which is
|
||||
the number of bytes to be written. The new write
|
||||
function should call png_error(png_ptr, "Error msg")
|
||||
to exit and output any fatal error messages.
|
||||
flush_data_fn - pointer to a new flush function which takes as its
|
||||
arguments a pointer to a png_struct. After a call to
|
||||
the flush function, there should be no data in any buffers
|
||||
or pending transmission. If the output method doesn't do
|
||||
any buffering of ouput, a function prototype must still be
|
||||
supplied although it doesn't have to do anything. If
|
||||
PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
||||
time, output_flush_fn will be ignored, although it must be
|
||||
supplied for compatibility. */
|
||||
void
|
||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
{
|
||||
png_ptr->io_ptr = io_ptr;
|
||||
|
||||
if (write_data_fn)
|
||||
png_ptr->write_data_fn = write_data_fn;
|
||||
else
|
||||
png_ptr->write_data_fn = png_default_write_data;
|
||||
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
if (output_flush_fn)
|
||||
png_ptr->output_flush_fn = output_flush_fn;
|
||||
else
|
||||
png_ptr->output_flush_fn = png_default_flush;
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
|
||||
/* It is an error to read while writing a png file */
|
||||
png_ptr->read_data_fn = NULL;
|
||||
}
|
||||
|
||||
350
pngwrite.c
350
pngwrite.c
@@ -1,10 +1,10 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a png file
|
||||
|
||||
libpng 1.0 beta 2 - version 0.81
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 24, 1995
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
*/
|
||||
|
||||
/* get internal access to png.h */
|
||||
@@ -21,7 +21,7 @@
|
||||
If you have long comments, I suggest writing them in png_write_end(),
|
||||
and compressing them. */
|
||||
void
|
||||
png_write_info(png_struct *png_ptr, png_info *info)
|
||||
png_write_info(png_structp png_ptr, png_infop info)
|
||||
{
|
||||
png_write_sig(png_ptr); /* write PNG signature */
|
||||
/* write IHDR information. */
|
||||
@@ -48,6 +48,8 @@ png_write_info(png_struct *png_ptr, png_info *info)
|
||||
#endif
|
||||
if (info->valid & PNG_INFO_PLTE)
|
||||
png_write_PLTE(png_ptr, info->palette, info->num_palette);
|
||||
else if (info->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_error(png_ptr, "Valid palette required for paletted images\n");
|
||||
#if defined(PNG_WRITE_tRNS_SUPPORTED)
|
||||
if (info->valid & PNG_INFO_tRNS)
|
||||
png_write_tRNS(png_ptr, info->trans, &(info->trans_values),
|
||||
@@ -73,10 +75,13 @@ png_write_info(png_struct *png_ptr, png_info *info)
|
||||
#endif
|
||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
if (info->valid & PNG_INFO_tIME)
|
||||
{
|
||||
png_write_tIME(png_ptr, &(info->mod_time));
|
||||
/* Check to see if we need to write text chunks */
|
||||
png_ptr->flags |= PNG_FLAG_WROTE_tIME;
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
/* Check to see if we need to write text chunks */
|
||||
if (info->num_text)
|
||||
{
|
||||
int i; /* local counter */
|
||||
@@ -92,6 +97,8 @@ png_write_info(png_struct *png_ptr, png_info *info)
|
||||
png_write_zTXt(png_ptr, info->text[i].key,
|
||||
info->text[i].text, info->text[i].text_length,
|
||||
info->text[i].compression);
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write compressed text\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -100,6 +107,8 @@ png_write_info(png_struct *png_ptr, png_info *info)
|
||||
/* write uncompressed chunk */
|
||||
png_write_tEXt(png_ptr, info->text[i].key,
|
||||
info->text[i].text, info->text[i].text_length);
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write uncompressed text\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -112,14 +121,18 @@ png_write_info(png_struct *png_ptr, png_info *info)
|
||||
in png_write_info(), do not write them again here. If you have long
|
||||
comments, I suggest writing them here, and compressing them. */
|
||||
void
|
||||
png_write_end(png_struct *png_ptr, png_info *info)
|
||||
png_write_end(png_structp png_ptr, png_infop info)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT))
|
||||
png_error(png_ptr, "No IDATs written into file");
|
||||
|
||||
/* see if user wants us to write information chunks */
|
||||
if (info)
|
||||
{
|
||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
/* check to see if user has supplied a time chunk */
|
||||
if (info->valid & PNG_INFO_tIME)
|
||||
if (info->valid & PNG_INFO_tIME &&
|
||||
!(png_ptr->flags & PNG_FLAG_WROTE_tIME))
|
||||
png_write_tIME(png_ptr, &(info->mod_time));
|
||||
#endif
|
||||
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
@@ -131,46 +144,51 @@ png_write_end(png_struct *png_ptr, png_info *info)
|
||||
/* loop through comment chunks */
|
||||
for (i = 0; i < info->num_text; i++)
|
||||
{
|
||||
#if defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
/* check to see if comment is to be compressed */
|
||||
if (info->text[i].compression >= 0)
|
||||
{
|
||||
#if defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
/* write compressed chunk */
|
||||
png_write_zTXt(png_ptr, info->text[i].key,
|
||||
info->text[i].text, info->text[i].text_length,
|
||||
info->text[i].compression);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(PNG_WRITE_tEXt_SUPPORTED)
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_WRITE_tEXt_SUPPORTED)
|
||||
{
|
||||
/* write uncompressed chunk */
|
||||
png_write_tEXt(png_ptr, info->text[i].key,
|
||||
info->text[i].text, info->text[i].text_length);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
|
||||
/* write end of png file */
|
||||
png_write_IEND(png_ptr);
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
void
|
||||
png_convert_from_struct_tm(png_time *ptime, struct tm *ttime)
|
||||
png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime)
|
||||
{
|
||||
ptime->year = 1900 + ttime->tm_year;
|
||||
ptime->month = ttime->tm_mon + 1;
|
||||
ptime->day = ttime->tm_mday;
|
||||
ptime->hour = ttime->tm_hour;
|
||||
ptime->minute = ttime->tm_min;
|
||||
ptime->second = ttime->tm_sec;
|
||||
ptime->year = (png_uint_16)(1900 + ttime->tm_year);
|
||||
ptime->month = (png_byte)(ttime->tm_mon + 1);
|
||||
ptime->day = (png_byte)ttime->tm_mday;
|
||||
ptime->hour = (png_byte)ttime->tm_hour;
|
||||
ptime->minute = (png_byte)ttime->tm_min;
|
||||
ptime->second = (png_byte)ttime->tm_sec;
|
||||
}
|
||||
|
||||
void
|
||||
png_convert_from_time_t(png_time *ptime, time_t ttime)
|
||||
png_convert_from_time_t(png_timep ptime, time_t ttime)
|
||||
{
|
||||
struct tm *tbuf;
|
||||
|
||||
@@ -179,22 +197,71 @@ png_convert_from_time_t(png_time *ptime, time_t ttime)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* initialize png structure, and allocate any memory needed */
|
||||
png_structp
|
||||
png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
|
||||
png_error_ptr warn_fn, png_error_ptr error_fn)
|
||||
{
|
||||
png_structp png_ptr;
|
||||
|
||||
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
|
||||
{
|
||||
return (png_structp)NULL;
|
||||
}
|
||||
|
||||
if (setjmp(png_ptr->jmpbuf))
|
||||
{
|
||||
png_large_free(png_ptr, png_ptr->zbuf);
|
||||
png_free(png_ptr, png_ptr->zstream);
|
||||
png_destroy_struct(png_ptr);
|
||||
return (png_structp)NULL;
|
||||
}
|
||||
|
||||
png_set_error_fn(png_ptr, error_ptr, warn_fn, error_fn);
|
||||
|
||||
if (user_png_ver == NULL || strcmp(user_png_ver, png_libpng_ver))
|
||||
{
|
||||
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0])
|
||||
{
|
||||
png_error(png_ptr, "Incompatible libpng versions");
|
||||
}
|
||||
else
|
||||
{
|
||||
png_warning(png_ptr, "Different libpng versions");
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_large_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
|
||||
png_set_write_fn(png_ptr, NULL, NULL, NULL);
|
||||
|
||||
png_ptr->do_free |= PNG_FREE_STRUCT;
|
||||
|
||||
return (png_ptr);
|
||||
}
|
||||
|
||||
|
||||
/* initialize png structure, and allocate any memory needed */
|
||||
void
|
||||
png_write_init(png_struct *png_ptr)
|
||||
png_write_init(png_structp png_ptr)
|
||||
{
|
||||
jmp_buf tmp_jmp; /* to save current jump buffer */
|
||||
|
||||
/* save jump buffer */
|
||||
/* save jump buffer and error functions */
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
|
||||
/* reset all variables to 0 */
|
||||
png_memset(png_ptr, 0, sizeof (png_struct));
|
||||
|
||||
/* restore jump buffer */
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_large_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_set_write_fn(png_ptr, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/* write a few rows of image data. If the image is interlaced,
|
||||
@@ -202,11 +269,11 @@ png_write_init(png_struct *png_ptr)
|
||||
have called png_set_interlace_handling(), you will have to
|
||||
"write" the image seven times */
|
||||
void
|
||||
png_write_rows(png_struct *png_ptr, png_bytef **row,
|
||||
png_write_rows(png_structp png_ptr, png_bytepp row,
|
||||
png_uint_32 num_rows)
|
||||
{
|
||||
png_uint_32 i; /* row counter */
|
||||
png_bytef **rp; /* row pointer */
|
||||
png_bytepp rp; /* row pointer */
|
||||
|
||||
/* loop through the rows */
|
||||
for (i = 0, rp = row; i < num_rows; i++, rp++)
|
||||
@@ -218,11 +285,11 @@ png_write_rows(png_struct *png_ptr, png_bytef **row,
|
||||
/* write the image. You only need to call this function once, even
|
||||
if you are writing an interlaced image. */
|
||||
void
|
||||
png_write_image(png_struct *png_ptr, png_bytef **image)
|
||||
png_write_image(png_structp png_ptr, png_bytepp image)
|
||||
{
|
||||
png_uint_32 i; /* row index */
|
||||
int pass, num_pass; /* pass variables */
|
||||
png_bytef **rp; /* points to current row */
|
||||
png_bytepp rp; /* points to current row */
|
||||
|
||||
/* intialize interlace handling. If image is not interlaced,
|
||||
this will set pass to 1 */
|
||||
@@ -238,9 +305,9 @@ png_write_image(png_struct *png_ptr, png_bytef **image)
|
||||
}
|
||||
}
|
||||
|
||||
/* write a row of image data */
|
||||
/* called by user to write a row of image data */
|
||||
void
|
||||
png_write_row(png_struct *png_ptr, png_bytef *row)
|
||||
png_write_row(png_structp png_ptr, png_bytep row)
|
||||
{
|
||||
/* initialize transformations and other stuff if first time */
|
||||
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
||||
@@ -312,8 +379,8 @@ png_write_row(png_struct *png_ptr, png_bytef *row)
|
||||
png_ptr->row_info.width = png_ptr->usr_width;
|
||||
png_ptr->row_info.channels = png_ptr->usr_channels;
|
||||
png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth;
|
||||
png_ptr->row_info.pixel_depth = png_ptr->row_info.bit_depth *
|
||||
png_ptr->row_info.channels;
|
||||
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
|
||||
png_ptr->row_info.channels);
|
||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||
|
||||
@@ -340,40 +407,36 @@ png_write_row(png_struct *png_ptr, png_bytef *row)
|
||||
if (png_ptr->transformations)
|
||||
png_do_write_transformations(png_ptr);
|
||||
|
||||
/* filter rows that have been proved to help */
|
||||
if (png_ptr->do_filter)
|
||||
{
|
||||
/* save row to previous row */
|
||||
png_memcpy(png_ptr->save_row, png_ptr->row_buf,
|
||||
(png_size_t)png_ptr->row_info.rowbytes + 1);
|
||||
/* find a filter if necessary, filter the row and write it out */
|
||||
png_write_find_filter(png_ptr, &(png_ptr->row_info));
|
||||
}
|
||||
|
||||
/* filter row */
|
||||
png_write_filter_row(&(png_ptr->row_info), png_ptr->row_buf,
|
||||
png_ptr->prev_row);
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
/* Set the automatic flush interval or 0 to turn flushing off */
|
||||
void
|
||||
png_set_flush(png_structp png_ptr, int nrows)
|
||||
{
|
||||
png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);
|
||||
}
|
||||
|
||||
/* trade saved pointer and prev pointer so next row references are correctly */
|
||||
{ /* scope limiter */
|
||||
png_bytef *tptr;
|
||||
/* flush the current output buffers now */
|
||||
void
|
||||
png_write_flush(png_structp png_ptr)
|
||||
{
|
||||
int wrote_IDAT;
|
||||
|
||||
tptr = png_ptr->prev_row;
|
||||
png_ptr->prev_row = png_ptr->save_row;
|
||||
png_ptr->save_row = tptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* set filter row to "none" */
|
||||
png_ptr->row_buf[0] = 0;
|
||||
/* We have already written out all of the data */
|
||||
if (png_ptr->row_number >= png_ptr->num_rows)
|
||||
return;
|
||||
|
||||
/* set up the zlib input buffer */
|
||||
png_ptr->zstream->next_in = png_ptr->row_buf;
|
||||
png_ptr->zstream->avail_in = (uInt)png_ptr->row_info.rowbytes + 1;
|
||||
/* repeat until we have compressed all the data */
|
||||
do
|
||||
{
|
||||
int ret; /* return of zlib */
|
||||
int ret;
|
||||
|
||||
/* compress the data */
|
||||
ret = deflate(png_ptr->zstream, Z_NO_FLUSH);
|
||||
ret = deflate(png_ptr->zstream, Z_SYNC_FLUSH);
|
||||
wrote_IDAT = 0;
|
||||
|
||||
/* check for compression errors */
|
||||
if (ret != Z_OK)
|
||||
{
|
||||
@@ -383,78 +446,209 @@ png_write_row(png_struct *png_ptr, png_bytef *row)
|
||||
png_error(png_ptr, "zlib error");
|
||||
}
|
||||
|
||||
/* see if it is time to write another IDAT */
|
||||
if (!png_ptr->zstream->avail_out)
|
||||
{
|
||||
/* write the IDAT and reset the zlib output buffer */
|
||||
png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
|
||||
png_write_IDAT(png_ptr, png_ptr->zbuf,
|
||||
png_ptr->zbuf_size);
|
||||
png_ptr->zstream->next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream->avail_out = (uInt)png_ptr->zbuf_size;
|
||||
wrote_IDAT = 1;
|
||||
}
|
||||
/* repeat until all data has been compressed */
|
||||
} while (png_ptr->zstream->avail_in);
|
||||
} while(wrote_IDAT == 1);
|
||||
|
||||
/* finish row - updates counters and flushes zlib if last row */
|
||||
png_write_finish_row(png_ptr);
|
||||
/* If there is any data left to be output, write it into a new IDAT */
|
||||
if (png_ptr->zbuf_size != png_ptr->zstream->avail_out)
|
||||
{
|
||||
/* write the IDAT and reset the zlib output buffer */
|
||||
png_write_IDAT(png_ptr, png_ptr->zbuf,
|
||||
png_ptr->zbuf_size - png_ptr->zstream->avail_out);
|
||||
png_ptr->zstream->next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream->avail_out = (uInt)png_ptr->zbuf_size;
|
||||
}
|
||||
png_ptr->flush_rows = 0;
|
||||
png_flush(png_ptr);
|
||||
}
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
|
||||
/* free all memory used by the write */
|
||||
void
|
||||
png_destroy_write_struct(png_structpp png_ptr, png_infopp info_ptr)
|
||||
{
|
||||
if (info_ptr && *info_ptr)
|
||||
{
|
||||
png_destroy_struct((voidp)*info_ptr);
|
||||
*info_ptr = (png_infop)NULL;
|
||||
}
|
||||
|
||||
if (png_ptr && *png_ptr)
|
||||
{
|
||||
png_write_destroy(*png_ptr);
|
||||
png_destroy_struct((voidp)*png_ptr);
|
||||
*png_ptr = (png_structp)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* free any memory used in png struct */
|
||||
|
||||
/* free any memory used in png struct (old) */
|
||||
void
|
||||
png_write_destroy(png_struct *png_ptr)
|
||||
png_write_destroy(png_structp png_ptr)
|
||||
{
|
||||
jmp_buf tmp_jmp; /* save jump buffer */
|
||||
png_error_ptr error_fn;
|
||||
png_error_ptr warning_fn;
|
||||
png_voidp error_ptr;
|
||||
|
||||
/* free any memory zlib uses */
|
||||
deflateEnd(png_ptr->zstream);
|
||||
png_free(png_ptr, png_ptr->zstream);
|
||||
|
||||
/* free our memory. png_free checks NULL for us. */
|
||||
png_large_free(png_ptr, png_ptr->zbuf);
|
||||
png_large_free(png_ptr, png_ptr->row_buf);
|
||||
png_large_free(png_ptr, png_ptr->prev_row);
|
||||
png_large_free(png_ptr, png_ptr->save_row);
|
||||
png_large_free(png_ptr, png_ptr->sub_row);
|
||||
png_large_free(png_ptr, png_ptr->up_row);
|
||||
png_large_free(png_ptr, png_ptr->avg_row);
|
||||
png_large_free(png_ptr, png_ptr->paeth_row);
|
||||
|
||||
/* reset structure */
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
|
||||
error_fn = png_ptr->error_fn;
|
||||
warning_fn = png_ptr->warning_fn;
|
||||
error_ptr = png_ptr->error_ptr;
|
||||
|
||||
png_memset(png_ptr, 0, sizeof (png_struct));
|
||||
|
||||
png_ptr->error_fn = error_fn;
|
||||
png_ptr->warning_fn = warning_fn;
|
||||
png_ptr->error_ptr = error_ptr;
|
||||
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
}
|
||||
|
||||
/* Allow the application to select one or more filters to use */
|
||||
void
|
||||
png_set_filtering(png_struct *png_ptr, int filter)
|
||||
png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
{
|
||||
png_ptr->do_custom_filter = 1;
|
||||
png_ptr->do_filter = filter;
|
||||
/* We allow 'method' only for future expansion of the base filter method */
|
||||
if (method == 0)
|
||||
{
|
||||
switch (filters & (PNG_ALL_FILTERS | 0x07))
|
||||
{
|
||||
case 5:
|
||||
case 6:
|
||||
case 7: png_warning(png_ptr, "Unknown custom row filter for method 0");
|
||||
case 0: png_ptr->do_filter = PNG_FILTER_NONE; break;
|
||||
case 1: png_ptr->do_filter = PNG_FILTER_SUB; break;
|
||||
case 2: png_ptr->do_filter = PNG_FILTER_UP; break;
|
||||
case 3: png_ptr->do_filter = PNG_FILTER_AVG; break;
|
||||
case 4: png_ptr->do_filter = PNG_FILTER_PAETH; break;
|
||||
default: png_ptr->do_filter = (png_byte)filters; break;
|
||||
}
|
||||
|
||||
/* If we have allocated the row_buf, then we should have also allocated
|
||||
* all of the filter buffers that have been selected.
|
||||
*/
|
||||
if (png_ptr->row_buf)
|
||||
{
|
||||
if (png_ptr->do_filter & PNG_FILTER_SUB && !(png_ptr->sub_row))
|
||||
{
|
||||
png_ptr->sub_row = (png_bytep )png_large_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
png_ptr->sub_row[0] = 1; /* Set the row filter type */
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_UP && !(png_ptr->up_row))
|
||||
{
|
||||
if (!(png_ptr->prev_row))
|
||||
{
|
||||
png_warning(png_ptr, "Can't to add up filter after starting");
|
||||
png_ptr->do_filter &= ~PNG_FILTER_UP;
|
||||
}
|
||||
else
|
||||
{
|
||||
png_ptr->up_row = (png_bytep )png_large_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
png_ptr->up_row[0] = 2; /* Set the row filter type */
|
||||
}
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_AVG && !(png_ptr->avg_row))
|
||||
{
|
||||
if (!(png_ptr->prev_row))
|
||||
{
|
||||
png_warning(png_ptr, "Can't add average filter after starting");
|
||||
png_ptr->do_filter &= ~PNG_FILTER_AVG;
|
||||
}
|
||||
else
|
||||
{
|
||||
png_ptr->up_row = (png_bytep )png_large_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
png_ptr->up_row[0] = 3; /* Set the row filter type */
|
||||
}
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_PAETH && !(png_ptr->paeth_row))
|
||||
{
|
||||
if (!(png_ptr->prev_row))
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Paeth filter after starting");
|
||||
png_ptr->do_filter &= ~PNG_FILTER_PAETH;
|
||||
}
|
||||
else
|
||||
{
|
||||
png_ptr->paeth_row = (png_bytep )png_large_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
png_ptr->paeth_row[0] = 4; /* Set the row filter type */
|
||||
}
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter == PNG_NO_FILTERS)
|
||||
png_ptr->do_filter = PNG_FILTER_NONE;
|
||||
}
|
||||
}
|
||||
else
|
||||
png_error(png_ptr, "Unknown custom filter method");
|
||||
}
|
||||
|
||||
void
|
||||
png_set_compression_level(png_struct *png_ptr, int level)
|
||||
png_set_compression_level(png_structp png_ptr, int level)
|
||||
{
|
||||
png_ptr->zlib_custom_level = 1;
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL;
|
||||
png_ptr->zlib_level = level;
|
||||
}
|
||||
|
||||
void
|
||||
png_set_compression_mem_level(png_struct *png_ptr, int mem_level)
|
||||
png_set_compression_mem_level(png_structp png_ptr, int mem_level)
|
||||
{
|
||||
png_ptr->zlib_custom_mem_level = 1;
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL;
|
||||
png_ptr->zlib_mem_level = mem_level;
|
||||
}
|
||||
|
||||
void
|
||||
png_set_compression_strategy(png_struct *png_ptr, int strategy)
|
||||
png_set_compression_strategy(png_structp png_ptr, int strategy)
|
||||
{
|
||||
png_ptr->zlib_custom_strategy = 1;
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;
|
||||
png_ptr->zlib_strategy = strategy;
|
||||
}
|
||||
|
||||
void
|
||||
png_set_compression_window_bits(png_struct *png_ptr, int window_bits)
|
||||
png_set_compression_window_bits(png_structp png_ptr, int window_bits)
|
||||
{
|
||||
png_ptr->zlib_custom_window_bits = 1;
|
||||
if (window_bits > 15)
|
||||
png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS;
|
||||
png_ptr->zlib_window_bits = window_bits;
|
||||
}
|
||||
|
||||
void
|
||||
png_set_compression_method(png_struct *png_ptr, int method)
|
||||
png_set_compression_method(png_structp png_ptr, int method)
|
||||
{
|
||||
png_ptr->zlib_custom_method = 1;
|
||||
if (method != 8)
|
||||
png_warning(png_ptr, "Only compression method 8 is supported by PNG");
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD;
|
||||
png_ptr->zlib_method = method;
|
||||
}
|
||||
|
||||
|
||||
72
pngwtran.c
72
pngwtran.c
@@ -1,10 +1,10 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for png writers
|
||||
|
||||
libpng 1.0 beta 2 - version 0.81
|
||||
libpng 1.0 beta 3 - version 0.89
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 24, 1995
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
May 25, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -13,12 +13,12 @@
|
||||
/* transform the data according to the users wishes. The order of
|
||||
transformations is significant. */
|
||||
void
|
||||
png_do_write_transformations(png_struct *png_ptr)
|
||||
png_do_write_transformations(png_structp png_ptr)
|
||||
{
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_RGBA)
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_do_write_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->filler_loc);
|
||||
png_ptr->flags);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
@@ -49,7 +49,7 @@ png_do_write_transformations(png_struct *png_ptr)
|
||||
row_info bit depth should be 8 (one pixel per byte). The channels
|
||||
should be 1 (this only happens on grayscale and paletted images) */
|
||||
void
|
||||
png_do_pack(png_row_info *row_info, png_bytef *row, png_byte bit_depth)
|
||||
png_do_pack(png_row_infop row_info, png_bytep row, png_byte bit_depth)
|
||||
{
|
||||
if (row_info && row && row_info->bit_depth == 8 &&
|
||||
row_info->channels == 1)
|
||||
@@ -58,8 +58,8 @@ png_do_pack(png_row_info *row_info, png_bytef *row, png_byte bit_depth)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
png_bytef *sp;
|
||||
png_bytef *dp;
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
int mask;
|
||||
png_int_32 i;
|
||||
int v;
|
||||
@@ -78,19 +78,19 @@ png_do_pack(png_row_info *row_info, png_bytef *row, png_byte bit_depth)
|
||||
else
|
||||
{
|
||||
mask = 0x80;
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
}
|
||||
if (mask != 0x80)
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
png_bytef *sp;
|
||||
png_bytef *dp;
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
int shift;
|
||||
png_int_32 i;
|
||||
int v;
|
||||
@@ -102,12 +102,12 @@ png_do_pack(png_row_info *row_info, png_bytef *row, png_byte bit_depth)
|
||||
v = 0;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
value = *sp & 0x3;
|
||||
value = (png_byte)(*sp & 0x3);
|
||||
v |= (value << shift);
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 6;
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
@@ -116,13 +116,13 @@ png_do_pack(png_row_info *row_info, png_bytef *row, png_byte bit_depth)
|
||||
sp++;
|
||||
}
|
||||
if (shift != 6)
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
png_bytef *sp;
|
||||
png_bytef *dp;
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
int shift;
|
||||
png_int_32 i;
|
||||
int v;
|
||||
@@ -134,13 +134,13 @@ png_do_pack(png_row_info *row_info, png_bytef *row, png_byte bit_depth)
|
||||
v = 0;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
value = *sp & 0xf;
|
||||
value = (png_byte)(*sp & 0xf);
|
||||
v |= (value << shift);
|
||||
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 4;
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
@@ -150,12 +150,12 @@ png_do_pack(png_row_info *row_info, png_bytef *row, png_byte bit_depth)
|
||||
sp++;
|
||||
}
|
||||
if (shift != 4)
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
row_info->bit_depth = bit_depth;
|
||||
row_info->pixel_depth = bit_depth * row_info->channels;
|
||||
row_info->pixel_depth = (png_uint_16)(bit_depth * row_info->channels);
|
||||
row_info->rowbytes =
|
||||
((row_info->width * row_info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
@@ -170,7 +170,7 @@ png_do_pack(png_row_info *row_info, png_bytef *row, png_byte bit_depth)
|
||||
would pass 3 as bit_depth, and this routine would translate the
|
||||
data to 0 to 15. */
|
||||
void
|
||||
png_do_shift(png_row_info *row_info, png_bytef *row, png_color_8 *bit_depth)
|
||||
png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
{
|
||||
if (row && row_info &&
|
||||
row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
@@ -207,7 +207,7 @@ png_do_shift(png_row_info *row_info, png_bytef *row, png_color_8 *bit_depth)
|
||||
/* with low row dephts, could only be grayscale, so one channel */
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
png_bytef *bp;
|
||||
png_bytep bp;
|
||||
png_uint_32 i;
|
||||
int j;
|
||||
png_byte mask;
|
||||
@@ -236,7 +236,7 @@ png_do_shift(png_row_info *row_info, png_bytef *row, png_color_8 *bit_depth)
|
||||
}
|
||||
else if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytef *bp;
|
||||
png_bytep bp;
|
||||
png_uint_32 i;
|
||||
int j;
|
||||
|
||||
@@ -262,7 +262,7 @@ png_do_shift(png_row_info *row_info, png_bytef *row, png_color_8 *bit_depth)
|
||||
}
|
||||
else
|
||||
{
|
||||
png_bytef *bp;
|
||||
png_bytep bp;
|
||||
png_uint_32 i;
|
||||
int j;
|
||||
|
||||
@@ -276,7 +276,8 @@ png_do_shift(png_row_info *row_info, png_bytef *row, png_color_8 *bit_depth)
|
||||
{
|
||||
png_uint_16 value, v;
|
||||
|
||||
v = ((png_uint_16)(*bp) << 8) + (png_uint_16)(*(bp + 1));
|
||||
v = (png_uint_16)(((png_uint_16)(*bp) << 8) +
|
||||
(png_uint_16)(*(bp + 1)));
|
||||
value = 0;
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
@@ -285,8 +286,8 @@ png_do_shift(png_row_info *row_info, png_bytef *row, png_color_8 *bit_depth)
|
||||
else
|
||||
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
|
||||
}
|
||||
*bp = value >> 8;
|
||||
*(bp + 1) = value & 0xff;
|
||||
*bp = (png_byte)(value >> 8);
|
||||
*(bp + 1) = (png_byte)(value & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,15 +298,16 @@ png_do_shift(png_row_info *row_info, png_bytef *row, png_color_8 *bit_depth)
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
/* remove filler byte */
|
||||
void
|
||||
png_do_write_filler(png_row_info *row_info, png_bytef *row,
|
||||
png_byte filler_loc)
|
||||
png_do_write_filler(png_row_infop row_info, png_bytep row,
|
||||
png_byte flags)
|
||||
{
|
||||
if (row && row_info && row_info->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
row_info->bit_depth == 8)
|
||||
{
|
||||
if (filler_loc == PNG_FILLER_AFTER)
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
png_bytef *sp, *dp;
|
||||
png_bytep sp, dp;
|
||||
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 1, sp = row + 4, dp = row + 3;
|
||||
@@ -323,10 +325,10 @@ png_do_write_filler(png_row_info *row_info, png_bytef *row,
|
||||
}
|
||||
else
|
||||
{
|
||||
png_bytef *sp, *dp;
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 1, sp = row + 4, dp = row + 3;
|
||||
for (i = 0, sp = row, dp = row;
|
||||
i < row_info->width;
|
||||
i++)
|
||||
{
|
||||
|
||||
833
pngwutil.c
833
pngwutil.c
File diff suppressed because it is too large
Load Diff
80
readme.txt
80
readme.txt
@@ -1,54 +1,61 @@
|
||||
readme.txt - for libpng 0.8
|
||||
readme.txt - for libpng 0.89
|
||||
|
||||
This is the second beta version of libpng 1.0. I've updated most
|
||||
of the stuff I want to before the final 1.0 version. Remaining
|
||||
to do are the medium memory model support (which I'll put in
|
||||
as soon as we test this version), better dithering, and any bug
|
||||
fixes and makefile/include additions. I expect a third (and
|
||||
perhaps final) beta after zlib is officially 1.0.
|
||||
This is a bug fix for the third beta version of libpng 1.0. The
|
||||
changes from libpng-0.88 are bug fixes and some changes to the
|
||||
API itself to increase robustness with shared libraries. This
|
||||
release is based on libpng-0.88, but has been modified from that
|
||||
version by Andreas Dilger <adilger@enel.ucalgary.ca> because the
|
||||
original author, Guy Schalnat, has not been able to keep up with
|
||||
the time demands of maintaining this library.
|
||||
|
||||
I've tried to incorporate all the changes and makefiles everyone
|
||||
sent me. However, I may of lost some in the flood. If you sent
|
||||
me a change and I didn't put it in, send it again. Sorry.
|
||||
The callback functions for the error/warning messages have changed
|
||||
since the last release because their implementation was broken,
|
||||
and it was thought best to change the API itself (which was only
|
||||
introduced in libpng-0.88 itself) to alert the user to the change,
|
||||
rather than mislead the user into thinking their application was
|
||||
OK after re-compiling. This means that calls to png_set_message_fn()
|
||||
no longer exist, because the previously suggested method of calling
|
||||
them before png_read_init() or png_write_init() is now ineffective.
|
||||
|
||||
Updates from libpng 0.71 include a new transformation,
|
||||
png_set_filler(), which replaces png_set_rgbx() and
|
||||
png_set_xrgb(). The old functions will be supported for
|
||||
awhile, but I'd suggest changing to the new function. Also,
|
||||
I've added defines in png.h to remove unwanted code from the
|
||||
compiled library. I've added a new field to png_realloc(), and
|
||||
fixed various bugs. I've also split up pngstub.c into pngmem.c,
|
||||
pngio.c, and pngerror.c, in case you need to just change some of
|
||||
these. I've pulled pngconf.h out of png.h, so you don't have to
|
||||
remake your changes every new release. I've added a function to
|
||||
update the png_info structure after you're done setting up your
|
||||
transformations (png_read_update_info()). The complete list of
|
||||
changes is in pngchang.txt. Most of you won't be much affected
|
||||
by any of this. Some of you will want to use the new features.
|
||||
The preferred method of setting the error and warning callbacks
|
||||
has been incorporated into the allocation of the png_struct and
|
||||
info_struct itself, which allow them to be safely used during the
|
||||
initialization of the structure, as well as to keep the size of
|
||||
the png_struct internal to the library, rather than at compile time
|
||||
of the application. This will hopefully remove any problems with
|
||||
dynamically linked libraries, and should be considered the preferred
|
||||
method of creating these structures, although the previous
|
||||
initialization API is still available for compatibility. See libpng.txt
|
||||
for more information on the new API.
|
||||
|
||||
The changes made to the library, and bugs fixed are based on discussions
|
||||
on the PNG implementation mailing list <png-implement@dworking.wustl.edu>
|
||||
and not on material submitted to Guy.
|
||||
|
||||
For a detailed description on using libpng, read libpng.txt. For
|
||||
usage information and restrictions (what little they are) on libpng,
|
||||
see png.h. For a description on using zlib (the compression library
|
||||
used by libpng) and zlib's restrictions, see zlib.h
|
||||
|
||||
I have included a general makefile, but you may have to modify it
|
||||
for your own needs.
|
||||
I have included a general makefile, as well as several machine and compiler
|
||||
specific ones, but you may have to modify one for your own needs.
|
||||
|
||||
You will need zlib 0.95 or later to run this. zlib is a compression
|
||||
library that is useful for more things then just png files. If
|
||||
you need a compression library, check out zlib.h
|
||||
you need a compression library, check out zlib.h. There was a bug in
|
||||
zlib <= 0.99 which caused it to generate invalid compression streams
|
||||
on some occasions. Later versions of zlib do not have this problem.
|
||||
|
||||
zlib should be available at the same place that libpng is.
|
||||
If not, it should be at ftp.uu.net in /graphics/png
|
||||
Eventually, it will be at ftp.uu.net in /pub/archiving/zip/zlib
|
||||
|
||||
You will also want a copy of the PNG specification. It should
|
||||
You may also want a copy of the PNG specification. It should
|
||||
be available at the same place you picked up libpng. If it is
|
||||
not there, try ftp.uu.net in the /graphics/png directory.
|
||||
|
||||
This code is currently being archived at ftp.uu.net in the
|
||||
/graphics/png directory, and at ftp.group42.com (204.94.158.25)
|
||||
in the /pub/png directory, and on CompuServe, Lib 20 (PNG SUPPORT)
|
||||
/graphics/png directory, and on CompuServe, Lib 20 (PNG SUPPORT)
|
||||
at GO GRAPHSUP. If you can't find it in any of those places,
|
||||
e-mail me, and I'll help you find it.
|
||||
|
||||
@@ -63,12 +70,18 @@ Finally, if you get any warning messages when compiling libpng
|
||||
(note: not zlib), and they are easy to fix, I'd appreciate the
|
||||
fix. Please mention "libpng" somewhere in the subject line. Thanks.
|
||||
|
||||
You can reach me at:
|
||||
This release was created and will be supported by myself, and the
|
||||
PNG group.
|
||||
|
||||
adilger@enel.ucalgary.ca
|
||||
png-implement@dworkin.wustl.edu
|
||||
|
||||
You can reach Guy, the original libpng author, at (internet preferred):
|
||||
|
||||
internet: schalnat@group42.com
|
||||
CompuServe: 75501,1625
|
||||
|
||||
Please do not send me general questions about PNG. Send them to
|
||||
Please do not send general questions about PNG. Send them to
|
||||
the address in the specification. At the same time, please do
|
||||
not send libpng questions to that address, send them to me. I'll
|
||||
get them in the end anyway. If you have a question about something
|
||||
@@ -78,7 +91,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
|
||||
to others, if necessary.
|
||||
|
||||
Please do not send suggestions on how to change PNG. We have
|
||||
been discussing PNG for 9 months now, and it is official and
|
||||
been discussing PNG for over a year now, and it is official and
|
||||
finished. If you have suggestions for libpng, however, I'll
|
||||
gladly listen. Even if your suggestion is not used for version
|
||||
1.0, it may be used later.
|
||||
@@ -90,5 +103,4 @@ Good luck, and happy coding.
|
||||
Internet: schalnat@group42.com
|
||||
CompuServe: 75501,1625
|
||||
Web: www.group42.com
|
||||
FTP: ftp.group42.com (204.94.158.25)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user