Imported from libpng-1.0.5a.tar
75
ANNOUNCE
@ -1,70 +1,19 @@
|
||||
|
||||
Libpng 1.0.5 - October 15, 1999
|
||||
Libpng 1.0.5a - October 23, 1999
|
||||
|
||||
This is a public release of libpng, intended for use in production codes.
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
|
||||
Changes since the last public release (1.0.3):
|
||||
Changes since the last public release (1.0.5):
|
||||
|
||||
Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning
|
||||
if an attempt is made to read an interlaced image when it's not supported.
|
||||
Added check if png_ptr->trans is defined before free'ing it in pngread.c
|
||||
Modified the Y2K statement to include versions back to version 0.71
|
||||
Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c
|
||||
Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments)
|
||||
Replaced leading blanks with tab characters in makefile.hux
|
||||
Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents.
|
||||
Changed (float)red and (float)green to (double)red, (double)green
|
||||
in png_set_rgb_to_gray() to avoid "promotion" problems in AIX.
|
||||
Fixed a bug in pngconf.h that omitted <stdio.h> when PNG_DEBUG==0 (K Bracey).
|
||||
Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt).
|
||||
Updated documentation to refer to the PNG-1.2 specification.
|
||||
Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c
|
||||
in makefile.knr, INSTALL, and README (L. Peter Deutsch)
|
||||
Fixed bugs in calculation of the length of rowbytes when adding alpha
|
||||
channels to 16-bit images, in pngrtran.c (Chris Nokleberg)
|
||||
Added function png_set_user_transform_info() to store user_transform_ptr,
|
||||
user_depth, and user_channels into the png_struct, and a function
|
||||
png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg)
|
||||
Added function png_set_empty_plte_permitted() to make libpng useable
|
||||
in MNG applications.
|
||||
Corrected the typedef for png_free_ptr in png.h (Jesse Jones).
|
||||
Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c and
|
||||
pngset.c, to be consistent with PNG-1.2, and allow variance of 500
|
||||
before complaining.
|
||||
Added assembler code contributed by Intel in file pngvcrd.c and modified
|
||||
makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant)
|
||||
Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy.
|
||||
Added makefile.beo for BEOS on X86, contributed by Sander Stok.
|
||||
Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h
|
||||
Changed leading blanks to tabs in all makefiles.
|
||||
Made alternate versions of png_set_expand() in pngrtran.c, namely
|
||||
png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha
|
||||
(Greg Roelofs, in "PNG: The Definitive Guide").
|
||||
Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h
|
||||
Revised calculation of num_blocks in pngmem.c to avoid a potentially
|
||||
negative shift distance, whose results are undefined in the C language.
|
||||
Added a check in pngset.c to prevent writing multiple tIME chunks.
|
||||
Added a check in pngwrite.c to detect invalid small window_bits sizes.
|
||||
Added a demo read_user_transform_fn that examines the row filters in pngtest.c
|
||||
Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined
|
||||
Made several minor corrections to pngtest.c
|
||||
Changed "hptr += 16L" to "hptr = hptr + 16L" in pngmem.c for Turbo 3.0
|
||||
Renamed the makefiles with longer but more user friendly extensions.
|
||||
Define PNG_USE_PNGVCRD in makefile.vcawin32, to get MMX assembler code.
|
||||
Copied the PNG copyright and license to a separate LICENSE file.
|
||||
Revised documentation, png.h, and example.c to remove reference to
|
||||
"viewing_gamma" which no longer appears in the PNG specification.
|
||||
Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING)
|
||||
Increase max_pixel_depth in pngrutil.c if a user transform needs it.
|
||||
Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1
|
||||
Added a "png_check_version" function in png.c and pngtest.c that will generate
|
||||
a helpful compiler error if an old png.h is found in the search path.
|
||||
Added a copy of pngnow.png to the distribution.
|
||||
Surrounded example.c code with #if 0 .. #endif to prevent people from
|
||||
inadvertently trying to compile it.
|
||||
Added type casting mostly in pngrtran.c and pngwtran.c
|
||||
Removed some pointless "ptr = NULL" in pngmem.c
|
||||
Added a "contrib" directory containing the source code from Greg's book.
|
||||
version 1.0.5a [October 23, 1999]
|
||||
Added contrib/pngsuite and contrib/pngminus (Willem van Schaik)
|
||||
Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans)
|
||||
Further optimization and bugfix of pngvcrd.c
|
||||
Revised pngset.c so that it does not allocate or free memory in the user's
|
||||
text_ptr structure. Instead, it makes its own copy.
|
||||
Created separate write_end_info_struct in pngtest.c for a more severe test.
|
||||
Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak.
|
||||
|
||||
Send comments/corrections/commendations to
|
||||
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
|
||||
|
12
CHANGES
@ -467,10 +467,20 @@ version 1.0.4d [October 6, 1999]
|
||||
version 1.0.4e [October 10, 1999]
|
||||
Fixed sign error in pngvcrd.c (Greg Roelofs)
|
||||
Replaced some instances of memcpy with simple assignments in pngvcrd (GR-P)
|
||||
version 1.0.5 [October 15, 1999]
|
||||
version 1.0.4f [October 15, 1999]
|
||||
Surrounded example.c code with #if 0 .. #endif to prevent people from
|
||||
inadvertently trying to compile it.
|
||||
Changed png_get_header_version() from a function to a macro in png.h
|
||||
Added type casting mostly in pngrtran.c and pngwtran.c
|
||||
Removed some pointless "ptr = NULL" in pngmem.c
|
||||
Added a "contrib" directory containing the source code from Greg's book.
|
||||
version 1.0.5 [October 15, 1999]
|
||||
Minor editing of the INSTALL and README files.
|
||||
version 1.0.5a [October 23, 1999]
|
||||
Added contrib/pngsuite and contrib/pngminus (Willem van Schaik)
|
||||
Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans)
|
||||
Further optimization and bugfix of pngvcrd.c
|
||||
Revised pngset.c so that it does not allocate or free memory in the user's
|
||||
text_ptr structure. Instead, it makes its own copy.
|
||||
Created separate write_end_info_struct in pngtest.c for a more severe test.
|
||||
Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak.
|
||||
|
18
INSTALL
@ -1,5 +1,5 @@
|
||||
|
||||
Installing libpng version 1.0.5 - October 15, 1999
|
||||
Installing libpng version 1.0.5a - October 23, 1999
|
||||
|
||||
Before installing libpng, you must first install zlib. zlib
|
||||
can usually be found wherever you got libpng. zlib can be
|
||||
@ -10,7 +10,7 @@ zlib.h and zconf.h include files that correspond to the
|
||||
version of zlib that's installed.
|
||||
|
||||
You can rename the directories that you downloaded (they
|
||||
might be called "libpng-1.0.5" or "lpng103" and "zlib-1.1.3"
|
||||
might be called "libpng-1.0.5a" or "lpng103" and "zlib-1.1.3"
|
||||
or "zlib113") so that you have directories called "zlib" and "libpng".
|
||||
|
||||
Your directory structure should look like this:
|
||||
@ -23,6 +23,8 @@ Your directory structure should look like this:
|
||||
*.c
|
||||
contrib
|
||||
gregbook
|
||||
pngminus
|
||||
pngsuite
|
||||
scripts
|
||||
makefile.*
|
||||
pngtest.png
|
||||
@ -49,8 +51,8 @@ include
|
||||
makefile.hpux => HPUX (10.20 and 11.00) makefile
|
||||
makefile.sgi => Silicon Graphics IRIX makefile
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.5)
|
||||
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.5a)
|
||||
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5a)
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.mips => MIPS makefile
|
||||
makefile.acorn => Acorn makefile
|
||||
@ -93,12 +95,14 @@ this directory and run a quick test that reads the "pngtest.png"
|
||||
file and writes a "pngout.png" file that should be identical to it.
|
||||
Look for "9782 zero samples" in the output of the test. For more
|
||||
confidence, you can run another test by typing "pngtest pngnow.png"
|
||||
and looking for "289 zero samples" in the output.
|
||||
and looking for "289 zero samples" in the output. Also, you can
|
||||
run "pngtest -m *.png" in the "contrib/pngsuite" directory and compare
|
||||
your output with the result shown in contrib/pngsuite/README.
|
||||
|
||||
Most of the makefiles will allow you to run "make install" to
|
||||
put the library in its final resting place (if you want to
|
||||
do that, run "make install" in the zlib directory first if necessary).
|
||||
|
||||
Further information can be found in the README and libpng.txt
|
||||
files, in the individual makefiles, and in png.h, and the manual
|
||||
pages libpng.3 and png.5.
|
||||
files, in the individual makefiles, in png.h, and the manual pages
|
||||
libpng.3 and png.5.
|
||||
|
31
KNOWNBUG
@ -1,5 +1,5 @@
|
||||
|
||||
Known bugs and suggested enhancements in libpng-1.0.4
|
||||
Known bugs and suggested enhancements in libpng-1.0.5
|
||||
|
||||
|
||||
1. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
|
||||
@ -38,21 +38,22 @@ Known bugs and suggested enhancements in libpng-1.0.4
|
||||
for the png_set_gAMA(), png_set_cHRM(), and corresponding png_get_()
|
||||
functions will be needed.
|
||||
|
||||
4. September 1999 -- BUG [FIXED] --
|
||||
4. October 1999 -- BUG
|
||||
|
||||
Portions of the new MMX code in pngvcrd.c were ifdef'd out because they
|
||||
didn't work properly, but the bug appears to have been found and fixed.
|
||||
As a result, all parts of the code are once again enabled. If you think
|
||||
there's still a problem, you can recompile with one of the following two
|
||||
macros defined and see if the problem goes away:
|
||||
pngvcrd.c is failing for interlaced PNGs that have empty passes.
|
||||
|
||||
DISABLE_PNGVCRD_COMBINE
|
||||
DISABLE_PNGVCRD_INTERLACE
|
||||
STATUS: A check for "width != 0" is required in several places.
|
||||
Fixed in libpng-1.0.5a/1.0.6
|
||||
|
||||
The second one is in the function where the bug was; as far as we are
|
||||
aware, there was never any bug in the other function. Please notify us
|
||||
if you find any problems in libpng, regardless of whether the two macros
|
||||
make any difference: png-implement@ccrc.wustl.edu
|
||||
5. October 1999 -- BUG
|
||||
|
||||
Again, we believe the MMX code in pngvcrd.c is 100% correct, but it has
|
||||
not yet been tested extensively.
|
||||
Under MSVC++6.0 with debugging enabled, heap corruption was detected
|
||||
while destroying the png_write_ptr.
|
||||
|
||||
STATUS: This was fixed by modifying png_set_text (in pngset.c) to
|
||||
refrain from writing into the user's text_ptr. With this fix, however,
|
||||
pngwrite.c, while destroying the info_ptr, was failing to free the
|
||||
text->key strings. Fix for the latter problem is to duplicate code
|
||||
from png.c.
|
||||
|
||||
Fixed in libpng-1.0.5a/1.0.6
|
||||
|
4
LICENSE
@ -5,7 +5,7 @@ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
Copyright (c) 1996, 1997 Andreas Dilger
|
||||
(libpng versions 0.90, December 1996, through 0.96, May 1997)
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
(libpng versions 0.97, January 1998, through 1.0.5, October 15, 1999)
|
||||
(libpng versions 0.97, January 1998, through 1.0.5a, October 23, 1999)
|
||||
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
@ -67,4 +67,4 @@ certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
randeg@alum.rpi.edu
|
||||
October 15, 1999
|
||||
October 23, 1999
|
||||
|
8
README
@ -1,4 +1,4 @@
|
||||
README for libpng 1.0.5 - October 15, 1999 (shared library 2.1)
|
||||
README for libpng 1.0.5a - October 23, 1999 (shared library 2.1)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
@ -158,6 +158,8 @@ Files in this distribution:
|
||||
gregbook => source code for PNG reading and writing, from
|
||||
Greg Roelofs' "PNG: The Definitive Guide",
|
||||
O'Reilly, 1999
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
descrip.mms => VMS makefile for MMS or MMK
|
||||
makefile.std => Generic UNIX makefile
|
||||
@ -169,9 +171,9 @@ Files in this distribution:
|
||||
makefile.sgi => Silicon Graphics IRIX makefile
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.solaris => Solaris 2.X makefile
|
||||
(gcc, creates libpng.so.2.1.0.5)
|
||||
(gcc, creates libpng.so.2.1.0.5a)
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng.so.2.1.0.5)
|
||||
(gcc, creates libpng.so.2.1.0.5a)
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.mips => MIPS makefile
|
||||
makefile.acorn => Acorn makefile
|
||||
|
4
Y2KINFO
@ -1,13 +1,13 @@
|
||||
Y2K compliance in libpng:
|
||||
=========================
|
||||
|
||||
October 15, 1999
|
||||
October 23, 1999
|
||||
|
||||
Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
|
||||
This is your unofficial assurance that libpng from version 0.71 and
|
||||
upward through 1.0.5 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.0.5a are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has three year fields. One is a 2-byte unsigned integer
|
||||
|
153
contrib/pngminus/README
Normal file
@ -0,0 +1,153 @@
|
||||
PngMinus
|
||||
--------
|
||||
(copyright Willem van Schaik, 1999)
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and
|
||||
its documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and
|
||||
that both that copyright notice and this permission notice appear in
|
||||
supporting documentation. This software is provided "as is" without
|
||||
express or implied warranty.
|
||||
|
||||
|
||||
Some history
|
||||
------------
|
||||
Soon after the creation of PNG in 1995, the need was felt for a set of
|
||||
pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I
|
||||
(Willem van Schaik) started such a project. Luckily we discovered this
|
||||
and merged the two together into pnmtopng.tar.gz, which is available
|
||||
from a/o ftp://swrinde.nde.swri.edu/pub/png/.
|
||||
|
||||
These two utilities have many, many options and make use of most of the
|
||||
features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes
|
||||
the utilities quite complex and by now not anymore very maintainable.
|
||||
When we wrote these programs, libpng was still in an early stage.
|
||||
Therefore, lots of the functionality that we put in our software can now
|
||||
be done using transform-functions in libpng.
|
||||
|
||||
Finally, to compile these programs, you need to have installed and
|
||||
compiled three libraries: libpng, zlib and netpbm. Especially the latter
|
||||
makes the whole setup a bit bulky. But that's unavoidable given the many
|
||||
features of pnmtopng.
|
||||
|
||||
|
||||
What now
|
||||
--------
|
||||
At this moment libpng is in a very stable state and can do much of the
|
||||
work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new
|
||||
interface of libpng. Hence, it is time for a rewrite from the ground up
|
||||
of pnmtopng and pngtopnm. This will happen in the near future (stay
|
||||
tuned). The new package will get a different name to distinguish it from
|
||||
the old one: PngPlus.
|
||||
|
||||
To experiment a bit with the new interface of libpng, I started off with
|
||||
a small prototype that contains only the basic functionality. It doesn't
|
||||
have any of the options to read or write special chunks and it will do
|
||||
no gamma correction. But this makes it also a simple program that is
|
||||
quite easy to understand and can serve well as a template for other
|
||||
software developments. (By now there are of course a couple of programs,
|
||||
like Greg Roelofs' rpng/wpng, that can be used just as good.)
|
||||
|
||||
|
||||
Can and can not
|
||||
---------------
|
||||
As this is the small brother of the future PngPlus, I called this fellow
|
||||
PngMinus. Because I started this development in good-old Turbo-C, I
|
||||
avoided the use the netpbm library, which requires DOS extenders. Again,
|
||||
another reason to call it PngMinus (minus netpbm :-). So, part of the
|
||||
program are some elementary routines to read / write pgm- and ppm-files.
|
||||
It does not read b&w pbm-files.
|
||||
|
||||
The downside of this approach is that you can not use them on images
|
||||
that require blocks of memory bigger than 64k (the DOS version). For
|
||||
larger images you will get an out-of-memory error.
|
||||
|
||||
As said before, PngMinus doesn't correct for gamma. When reading
|
||||
png-files you can do this just as well by piping the output of png2pnm
|
||||
to pnmgamma, one of the standard PbmPlus tools. This same scenario will
|
||||
most probably also be followed in the full-blown future PngPlus, with
|
||||
the addition of course of the possibility to create gamma-chunks when
|
||||
writing png-files.
|
||||
|
||||
On the other hand it supports alpha-channels. When reading a png-image
|
||||
you can write the alpha-channel into a pgm-file. And when creating an
|
||||
RGB+A png-image, you just combine a ppm-file with a corresponding
|
||||
pgm-file containing the alpha-channel. When reading, transparency chunks
|
||||
are converted into an alpha-channel and from there on treated the same
|
||||
way.
|
||||
|
||||
Finally you can opt for writing ascii or binary pgm- and ppm-files. When
|
||||
the bit-depth is 16, the format will always be ascii.
|
||||
|
||||
|
||||
Using it
|
||||
--------
|
||||
To distinguish them from pnmtopng and PngPlus, the utilities are named
|
||||
png2pnm and pnm2png (2 instead of to). The input- and output-files can
|
||||
be given as parameters or through redirection. Therefore the programs
|
||||
can be part of a pipe.
|
||||
|
||||
To list the options type "png2pnm -h" or "pnm2png -h".
|
||||
|
||||
|
||||
Just like IKEA
|
||||
--------------
|
||||
You have to put it together yourself. I did test the software under
|
||||
MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both
|
||||
cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK,
|
||||
however some older libpng versions have a bug in pngmem.c when using
|
||||
Turbo-C 3.0 (see below).
|
||||
|
||||
You can build it using one of the two makefiles (make -f makefile.###)
|
||||
or use the batch/script files pngminus.bat / pngminus.sh. This assumes
|
||||
that you have built the libraries in ../libpng and ../zlib. Using Linux,
|
||||
make sure that you have built libpng with makefile.std and not
|
||||
makefile.linux (also called .lnx in earlier versions of libpng). The
|
||||
latter creates a .so shared-library, while the PngMinus makefile assumes
|
||||
a normal .a static library.
|
||||
|
||||
If you create a ../pngsuite directory and then store the basn####.png
|
||||
files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can
|
||||
test in one go the proper functioning of PngMinus, see png2pnm.bat and
|
||||
pnm2png.bat (or the .sh versions).
|
||||
|
||||
|
||||
Warranty
|
||||
-------
|
||||
Please, remember that this was just a small experiment to learn a few
|
||||
things. It will have many unforeseen features <vbg>. Who said bugs? Use
|
||||
it when you are in need for something simple or when you want to start
|
||||
developing your own stuff.
|
||||
|
||||
|
||||
The Turbo bug
|
||||
-------------
|
||||
** pngmem.old
|
||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
||||
hptr += 16L;
|
||||
** pngmem.c
|
||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
||||
hptr = hptr + 16L;
|
||||
**
|
||||
|
||||
** pngmem.old
|
||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||
hptr += (png_uint_32)65536L;
|
||||
** pngmem.c
|
||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||
hptr = hptr + 65536L;
|
||||
**
|
||||
|
||||
|
||||
The end
|
||||
-------
|
||||
Willem van Schaik
|
||||
mailto:willem@schaik.com
|
||||
http://www.schaik.com/png/
|
||||
-------
|
||||
Oct 1999
|
||||
|
52
contrib/pngminus/makefile.std
Normal file
@ -0,0 +1,52 @@
|
||||
# Makefile for PngMinus (png2pnm and pnm2png)
|
||||
# Linux / Unix
|
||||
|
||||
CC=cc -O
|
||||
LD=cc -O
|
||||
#CC=gcc -O
|
||||
#LD=gcc -O
|
||||
LB=ar
|
||||
RM=rm
|
||||
CP=cp
|
||||
|
||||
PNGPATH = /usr/local
|
||||
PNGINC = -I$(PNGPATH)/include
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng
|
||||
PNGLIB = $(PNGPATH)/lib/libpng.a
|
||||
|
||||
ZPATH = /usr/local
|
||||
ZINC = -I$(ZPATH)/include
|
||||
#ZLIB = -L$(ZPATH)/lib -lz
|
||||
ZLIB = $(ZPATH)/lib/libz.a
|
||||
|
||||
CCFLAGS=-I$(PNGINC) -I$(ZINC)
|
||||
LDFLAGS=-L$(PNGLIB) -L$(ZLIB)
|
||||
C=.c
|
||||
O=.o
|
||||
L=.a
|
||||
E=
|
||||
|
||||
# dependencies
|
||||
|
||||
all: png2pnm$(E) pnm2png$(E)
|
||||
|
||||
png2pnm$(O): png2pnm$(C)
|
||||
$(CC) -c $(CCFLAGS) png2pnm$(C)
|
||||
|
||||
png2pnm$(E): png2pnm$(O)
|
||||
$(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS) -lpng -lz -lm
|
||||
|
||||
pnm2png$(O): pnm2png$(C)
|
||||
$(CC) -c $(CCFLAGS) pnm2png$(C)
|
||||
|
||||
pnm2png$(E): pnm2png$(O)
|
||||
$(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS) -lpng -lz -lm
|
||||
|
||||
clean:
|
||||
$(RM) png2pnm$(O)
|
||||
$(RM) pnm2png$(O)
|
||||
$(RM) png2pnm$(E)
|
||||
$(RM) pnm2png$(E)
|
||||
|
||||
# End of makefile for png2pnm / pnm2png
|
||||
|
38
contrib/pngminus/makefile.tc3
Normal file
@ -0,0 +1,38 @@
|
||||
# Makefile for PngMinus (png2pnm and pnm2png)
|
||||
# TurboC++ 3.0
|
||||
|
||||
CC=tcc -Ic:\tc3\inc
|
||||
LD=tcc -Lc:\tc3\lib
|
||||
LB=tlib
|
||||
RM=del
|
||||
CP=copy
|
||||
MODEL=l
|
||||
CCFLAGS=-O -m$(MODEL) -I..\libpng -I..\zlib
|
||||
LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib
|
||||
C=.c
|
||||
O=.obj
|
||||
L=.lib
|
||||
E=.exe
|
||||
|
||||
# dependencies
|
||||
|
||||
all: png2pnm$(E) pnm2png$(E)
|
||||
|
||||
png2pnm$(O): png2pnm$(C)
|
||||
$(CC) -c $(CCFLAGS) png2pnm$(C)
|
||||
|
||||
png2pnm$(E): png2pnm$(O)
|
||||
$(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L)
|
||||
|
||||
pnm2png$(O): pnm2png$(C)
|
||||
$(CC) -c $(CCFLAGS) pnm2png$(C)
|
||||
|
||||
pnm2png$(E): pnm2png$(O)
|
||||
$(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L)
|
||||
|
||||
clean:
|
||||
$(RM) *$(O)
|
||||
$(RM) *$(E)
|
||||
|
||||
# End of makefile for png2pnm / pnm2png
|
||||
|
41
contrib/pngminus/png2pnm.bat
Normal file
@ -0,0 +1,41 @@
|
||||
REM -- grayscale
|
||||
png2pnm.exe -noraw ..\pngsuite\basn0g01.png basn0g01.pgm
|
||||
png2pnm.exe -noraw ..\pngsuite\basn0g02.png basn0g02.pgm
|
||||
png2pnm.exe -noraw ..\pngsuite\basn0g04.png basn0g04.pgm
|
||||
png2pnm.exe -noraw ..\pngsuite\basn0g08.png basn0g08.pgm
|
||||
png2pnm.exe -noraw ..\pngsuite\basn0g16.png basn0g16.pgm
|
||||
REM -- full-color
|
||||
png2pnm.exe -noraw ..\pngsuite\basn2c08.png basn2c08.ppm
|
||||
png2pnm.exe -noraw ..\pngsuite\basn2c16.png basn2c16.ppm
|
||||
REM -- palletted
|
||||
png2pnm.exe -noraw ..\pngsuite\basn3p01.png basn3p01.ppm
|
||||
png2pnm.exe -noraw ..\pngsuite\basn3p02.png basn3p02.ppm
|
||||
png2pnm.exe -noraw ..\pngsuite\basn3p04.png basn3p04.ppm
|
||||
png2pnm.exe -noraw ..\pngsuite\basn3p08.png basn3p08.ppm
|
||||
REM -- gray with alpha-channel
|
||||
png2pnm.exe -noraw ..\pngsuite\basn4a08.png basn4a08.pgm
|
||||
png2pnm.exe -noraw ..\pngsuite\basn4a16.png basn4a16.pgm
|
||||
REM -- color with alpha-channel
|
||||
png2pnm.exe -noraw -alpha basn6a08.pgm ..\pngsuite\basn6a08.png basn6a08.ppm
|
||||
png2pnm.exe -noraw -alpha basn6a16.pgm ..\pngsuite\basn6a16.png basn6a16.ppm
|
||||
REM -- grayscale
|
||||
png2pnm.exe -raw ..\pngsuite\basn0g01.png rawn0g01.pgm
|
||||
png2pnm.exe -raw ..\pngsuite\basn0g02.png rawn0g02.pgm
|
||||
png2pnm.exe -raw ..\pngsuite\basn0g04.png rawn0g04.pgm
|
||||
png2pnm.exe -raw ..\pngsuite\basn0g08.png rawn0g08.pgm
|
||||
png2pnm.exe -raw ..\pngsuite\basn0g16.png rawn0g16.pgm
|
||||
REM -- full-color
|
||||
png2pnm.exe -raw ..\pngsuite\basn2c08.png rawn2c08.ppm
|
||||
png2pnm.exe -raw ..\pngsuite\basn2c16.png rawn2c16.ppm
|
||||
REM -- palletted
|
||||
png2pnm.exe -raw ..\pngsuite\basn3p01.png rawn3p01.ppm
|
||||
png2pnm.exe -raw ..\pngsuite\basn3p02.png rawn3p02.ppm
|
||||
png2pnm.exe -raw ..\pngsuite\basn3p04.png rawn3p04.ppm
|
||||
png2pnm.exe -raw ..\pngsuite\basn3p08.png rawn3p08.ppm
|
||||
REM -- gray with alpha-channel
|
||||
png2pnm.exe -raw ..\pngsuite\basn4a08.png rawn4a08.pgm
|
||||
png2pnm.exe -raw ..\pngsuite\basn4a16.png rawn4a16.pgm
|
||||
REM -- color with alpha-channel
|
||||
png2pnm.exe -noraw -alpha rawn6a08.pgm ..\pngsuite\basn6a08.png rawn6a08.ppm
|
||||
png2pnm.exe -noraw -alpha rawn6a16.pgm ..\pngsuite\basn6a16.png rawn6a16.ppm
|
||||
|
420
contrib/pngminus/png2pnm.c
Normal file
@ -0,0 +1,420 @@
|
||||
/*
|
||||
* png2pnm.c --- conversion from PNG-file to PGM/PPM-file
|
||||
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
|
||||
*
|
||||
* version 1.0 - 1999.10.15 - First version.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear in
|
||||
* supporting documentation. This software is provided "as is" without
|
||||
* express or implied warranty.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL unsigned char
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE (BOOL) 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE (BOOL) 0
|
||||
#endif
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#define STDIN 0
|
||||
#define STDOUT 1
|
||||
#define STDERR 2
|
||||
#endif
|
||||
|
||||
/* to make png2pnm verbose so we can find problems (needs to be before png.h) */
|
||||
#ifndef PNG_DEBUG
|
||||
#define PNG_DEBUG 0
|
||||
#endif
|
||||
|
||||
#include "png.h"
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
void usage ();
|
||||
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha);
|
||||
|
||||
/*
|
||||
* main
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fp_rd = stdin;
|
||||
FILE *fp_wr = stdout;
|
||||
FILE *fp_al = NULL;
|
||||
BOOL raw = TRUE;
|
||||
BOOL alpha = FALSE;
|
||||
int argi;
|
||||
|
||||
for (argi = 1; argi < argc; argi++)
|
||||
{
|
||||
if (argv[argi][0] == '-')
|
||||
{
|
||||
switch (argv[argi][1])
|
||||
{
|
||||
case 'n':
|
||||
raw = FALSE;
|
||||
break;
|
||||
case 'r':
|
||||
raw = TRUE;
|
||||
break;
|
||||
case 'a':
|
||||
alpha = TRUE;
|
||||
argi++;
|
||||
if ((fp_al = fopen (argv[argi], "wb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: unknown option %s\n", argv[argi]);
|
||||
usage();
|
||||
exit(1);
|
||||
break;
|
||||
} /* end switch */
|
||||
}
|
||||
else if (fp_rd == stdin)
|
||||
{
|
||||
if ((fp_rd = fopen (argv[argi], "rb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: file %s does not exist\n", argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
else if (fp_wr == stdout)
|
||||
{
|
||||
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: can not create file %s\n", argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: too many parameters\n");
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
} /* end for */
|
||||
|
||||
#ifdef __TURBOC__
|
||||
/* set stdin/stdout if required to binary */
|
||||
if (fp_rd == stdin)
|
||||
{
|
||||
setmode (STDIN, O_BINARY);
|
||||
}
|
||||
if ((raw) && (fp_wr == stdout))
|
||||
{
|
||||
setmode (STDOUT, O_BINARY);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* call the conversion program itself */
|
||||
if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE)
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: unsuccessful convertion of PNG-image\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* close input file */
|
||||
fclose (fp_rd);
|
||||
/* close output file */
|
||||
fclose (fp_wr);
|
||||
/* close alpha file */
|
||||
if (alpha)
|
||||
fclose (fp_al);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* usage
|
||||
*/
|
||||
|
||||
void usage()
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, " by Willem van Schaik, 1999\n");
|
||||
#ifdef __TURBOC__
|
||||
fprintf (stderr, " for Turbo-C and Borland-C compilers\n");
|
||||
#else
|
||||
fprintf (stderr, " for Linux (and Unix) compilers\n");
|
||||
#endif
|
||||
fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n");
|
||||
fprintf (stderr, " or: ... | png2pnm [options]\n");
|
||||
fprintf (stderr, "Options:\n");
|
||||
fprintf (stderr, " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
|
||||
fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n");
|
||||
fprintf (stderr, " -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
|
||||
fprintf (stderr, " -h | -? print this help-information\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* png2pnm
|
||||
*/
|
||||
|
||||
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha)
|
||||
{
|
||||
png_struct *png_ptr = NULL;
|
||||
png_info *info_ptr = NULL;
|
||||
png_byte buf[8];
|
||||
png_byte *png_pixels = NULL;
|
||||
png_byte **row_pointers = NULL;
|
||||
png_byte *pix_ptr = NULL;
|
||||
png_uint_32 row_bytes;
|
||||
|
||||
png_uint_32 width;
|
||||
png_uint_32 height;
|
||||
int bit_depth;
|
||||
int channels;
|
||||
int color_type;
|
||||
int alpha_present;
|
||||
int row, col;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* read and check signature in PNG file */
|
||||
ret = fread (buf, 1, 8, png_file);
|
||||
if (ret != 8)
|
||||
return FALSE;
|
||||
|
||||
ret = png_check_sig (buf, 8);
|
||||
if (!ret)
|
||||
return FALSE;
|
||||
|
||||
/* create png and info structures */
|
||||
|
||||
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL);
|
||||
if (!png_ptr)
|
||||
return FALSE; /* out of memory */
|
||||
|
||||
info_ptr = png_create_info_struct (png_ptr);
|
||||
if (!info_ptr)
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, NULL, NULL);
|
||||
return FALSE; /* out of memory */
|
||||
}
|
||||
|
||||
if (setjmp (png_ptr->jmpbuf))
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* set up the input control for C streams */
|
||||
png_init_io (png_ptr, png_file);
|
||||
png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */
|
||||
|
||||
/* read the file information */
|
||||
png_read_info (png_ptr, info_ptr);
|
||||
|
||||
/* get size and bit-depth of the PNG-image */
|
||||
png_get_IHDR (png_ptr, info_ptr,
|
||||
&width, &height, &bit_depth, &color_type,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
/* set-up the transformations */
|
||||
|
||||
/* transform paletted images into full-color rgb */
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_expand (png_ptr);
|
||||
/* expand images to bit-depth 8 (only applicable for grayscale images) */
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
|
||||
png_set_expand (png_ptr);
|
||||
/* transform transparency maps into full alpha-channel */
|
||||
if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||
png_set_expand (png_ptr);
|
||||
|
||||
#ifdef NJET
|
||||
/* downgrade 16-bit images to 8 bit */
|
||||
if (bit_depth == 16)
|
||||
png_set_strip_16 (png_ptr);
|
||||
/* transform grayscale images into full-color */
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb (png_ptr);
|
||||
/* only if file has a file gamma, we do a correction */
|
||||
if (png_get_gAMA (png_ptr, info_ptr, &file_gamma))
|
||||
png_set_gamma (png_ptr, (double) 2.2, file_gamma);
|
||||
#endif
|
||||
|
||||
/* all transformations have been registered; now update info_ptr data,
|
||||
* get rowbytes and channels, and allocate image memory */
|
||||
|
||||
png_read_update_info (png_ptr, info_ptr);
|
||||
|
||||
/* get the new color-type and bit-depth (after expansion/stripping) */
|
||||
png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
/* check for 16-bit files */
|
||||
if (bit_depth == 16)
|
||||
{
|
||||
raw = FALSE;
|
||||
#ifdef __TURBOC__
|
||||
pnm_file->flags &= ~((unsigned) _F_BIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* calculate new number of channels and store alpha-presence */
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY)
|
||||
channels = 1;
|
||||
else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
channels = 2;
|
||||
else if (color_type == PNG_COLOR_TYPE_RGB)
|
||||
channels = 3;
|
||||
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
channels = 4;
|
||||
else
|
||||
channels = 0; /* should never happen */
|
||||
alpha_present = (channels - 1) % 2;
|
||||
|
||||
/* check if alpha is expected to be present in file */
|
||||
if (alpha && !alpha_present)
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: PNG-file doesn't contain alpha channel\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = png_get_rowbytes (png_ptr, info_ptr);
|
||||
|
||||
if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) {
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* set the individual row_pointers to point at the correct offsets */
|
||||
for (i = 0; i < (height); i++)
|
||||
row_pointers[i] = png_pixels + i * row_bytes;
|
||||
|
||||
/* now we can go ahead and just read the whole image */
|
||||
png_read_image (png_ptr, row_pointers);
|
||||
|
||||
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
||||
png_read_end (png_ptr, info_ptr);
|
||||
|
||||
/* clean up after the read, and free any memory allocated - REQUIRED */
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp) NULL);
|
||||
|
||||
/* write header of PNM file */
|
||||
|
||||
if ((color_type == PNG_COLOR_TYPE_GRAY) ||
|
||||
(color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
||||
{
|
||||
fprintf (pnm_file, "%s\n", (raw) ? "P5" : "P2");
|
||||
fprintf (pnm_file, "%d %d\n", (int) width, (int) height);
|
||||
fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L));
|
||||
}
|
||||
else if ((color_type == PNG_COLOR_TYPE_RGB) ||
|
||||
(color_type == PNG_COLOR_TYPE_RGB_ALPHA))
|
||||
{
|
||||
fprintf (pnm_file, "%s\n", (raw) ? "P6" : "P3");
|
||||
fprintf (pnm_file, "%d %d\n", (int) width, (int) height);
|
||||
fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L));
|
||||
}
|
||||
|
||||
/* write header of PGM file with alpha channel */
|
||||
|
||||
if ((alpha) &&
|
||||
((color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ||
|
||||
(color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
|
||||
{
|
||||
fprintf (alpha_file, "%s\n", (raw) ? "P5" : "P2");
|
||||
fprintf (alpha_file, "%d %d\n", (int) width, (int) height);
|
||||
fprintf (alpha_file, "%ld\n", ((1L << (int) bit_depth) - 1L));
|
||||
}
|
||||
|
||||
/* write data to PNM file */
|
||||
pix_ptr = png_pixels;
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
for (col = 0; col < width; col++)
|
||||
{
|
||||
for (i = 0; i < (channels - alpha_present); i++)
|
||||
{
|
||||
if (raw)
|
||||
fputc ((int) *pix_ptr++ , pnm_file);
|
||||
else
|
||||
if (bit_depth == 16)
|
||||
fprintf (pnm_file, "%ld ", ((long) *pix_ptr++ << 8) + (long) *pix_ptr++);
|
||||
else
|
||||
fprintf (pnm_file, "%ld ", (long) *pix_ptr++);
|
||||
}
|
||||
if (alpha_present)
|
||||
{
|
||||
if (!alpha)
|
||||
{
|
||||
pix_ptr++; /* alpha */
|
||||
if (bit_depth == 16)
|
||||
pix_ptr++;
|
||||
}
|
||||
else /* output alpha-channel as pgm file */
|
||||
{
|
||||
if (raw)
|
||||
fputc ((int) *pix_ptr++ , alpha_file);
|
||||
else
|
||||
if (bit_depth == 16)
|
||||
fprintf (alpha_file, "%ld ", ((long) *pix_ptr++ << 8) + (long) *pix_ptr++);
|
||||
else
|
||||
fprintf (alpha_file, "%ld ", (long) *pix_ptr++);
|
||||
}
|
||||
} /* if alpha_present */
|
||||
|
||||
if (!raw)
|
||||
if (col % 4 == 3)
|
||||
fprintf (pnm_file, "\n");
|
||||
} /* end for col */
|
||||
|
||||
if (!raw)
|
||||
if (col % 4 != 0)
|
||||
fprintf (pnm_file, "\n");
|
||||
} /* end for row */
|
||||
|
||||
if (row_pointers != (unsigned char**) NULL)
|
||||
free (row_pointers);
|
||||
if (png_pixels != (unsigned char*) NULL)
|
||||
free (png_pixels);
|
||||
|
||||
return TRUE;
|
||||
|
||||
} /* end of source */
|
||||
|
41
contrib/pngminus/png2pnm.sh
Executable file
@ -0,0 +1,41 @@
|
||||
# -- grayscale
|
||||
./png2pnm -noraw ../pngsuite/basn0g01.png basn0g01.pgm
|
||||
./png2pnm -noraw ../pngsuite/basn0g02.png basn0g02.pgm
|
||||
./png2pnm -noraw ../pngsuite/basn0g04.png basn0g04.pgm
|
||||
./png2pnm -noraw ../pngsuite/basn0g08.png basn0g08.pgm
|
||||
./png2pnm -noraw ../pngsuite/basn0g16.png basn0g16.pgm
|
||||
# -- full-color
|
||||
./png2pnm -noraw ../pngsuite/basn2c08.png basn2c08.ppm
|
||||
./png2pnm -noraw ../pngsuite/basn2c16.png basn2c16.ppm
|
||||
# -- palletted
|
||||
./png2pnm -noraw ../pngsuite/basn3p01.png basn3p01.ppm
|
||||
./png2pnm -noraw ../pngsuite/basn3p02.png basn3p02.ppm
|
||||
./png2pnm -noraw ../pngsuite/basn3p04.png basn3p04.ppm
|
||||
./png2pnm -noraw ../pngsuite/basn3p08.png basn3p08.ppm
|
||||
# -- gray with alpha-channel
|
||||
./png2pnm -noraw ../pngsuite/basn4a08.png basn4a08.pgm
|
||||
./png2pnm -noraw ../pngsuite/basn4a16.png basn4a16.pgm
|
||||
# -- color with alpha-channel
|
||||
./png2pnm -noraw -alpha basn6a08.pgm ../pngsuite/basn6a08.png basn6a08.ppm
|
||||
./png2pnm -noraw -alpha basn6a16.pgm ../pngsuite/basn6a16.png basn6a16.ppm
|
||||
# -- grayscale
|
||||
./png2pnm -raw ../pngsuite/basn0g01.png rawn0g01.pgm
|
||||
./png2pnm -raw ../pngsuite/basn0g02.png rawn0g02.pgm
|
||||
./png2pnm -raw ../pngsuite/basn0g04.png rawn0g04.pgm
|
||||
./png2pnm -raw ../pngsuite/basn0g08.png rawn0g08.pgm
|
||||
./png2pnm -raw ../pngsuite/basn0g16.png rawn0g16.pgm
|
||||
# -- full-color
|
||||
./png2pnm -raw ../pngsuite/basn2c08.png rawn2c08.ppm
|
||||
./png2pnm -raw ../pngsuite/basn2c16.png rawn2c16.ppm
|
||||
# -- palletted
|
||||
./png2pnm -raw ../pngsuite/basn3p01.png rawn3p01.ppm
|
||||
./png2pnm -raw ../pngsuite/basn3p02.png rawn3p02.ppm
|
||||
./png2pnm -raw ../pngsuite/basn3p04.png rawn3p04.ppm
|
||||
./png2pnm -raw ../pngsuite/basn3p08.png rawn3p08.ppm
|
||||
# -- gray with alpha-channel
|
||||
./png2pnm -raw ../pngsuite/basn4a08.png rawn4a08.pgm
|
||||
./png2pnm -raw ../pngsuite/basn4a16.png rawn4a16.pgm
|
||||
# -- color with alpha-channel
|
||||
./png2pnm -noraw -alpha rawn6a08.pgm ../pngsuite/basn6a08.png rawn6a08.ppm
|
||||
./png2pnm -noraw -alpha rawn6a16.pgm ../pngsuite/basn6a16.png rawn6a16.ppm
|
||||
|
4
contrib/pngminus/pngminus.bat
Normal file
@ -0,0 +1,4 @@
|
||||
make -f makefile.tc3
|
||||
call png2pnm.bat
|
||||
call pnm2png.bat
|
||||
|
4
contrib/pngminus/pngminus.sh
Executable file
@ -0,0 +1,4 @@
|
||||
make -f makefile.std
|
||||
sh png2pnm.sh
|
||||
sh pnm2png.sh
|
||||
|
41
contrib/pngminus/pnm2png.bat
Normal file
@ -0,0 +1,41 @@
|
||||
REM -- grayscale
|
||||
pnm2png.exe basn0g01.pgm basn0g01.png
|
||||
pnm2png.exe basn0g02.pgm basn0g02.png
|
||||
pnm2png.exe basn0g04.pgm basn0g04.png
|
||||
pnm2png.exe basn0g08.pgm basn0g08.png
|
||||
pnm2png.exe basn0g16.pgm basn0g16.png
|
||||
REM -- full-color
|
||||
pnm2png.exe basn2c08.ppm basn2c08.png
|
||||
pnm2png.exe basn2c16.ppm basn2c16.png
|
||||
REM -- palletted
|
||||
pnm2png.exe basn3p01.ppm basn3p01.png
|
||||
pnm2png.exe basn3p02.ppm basn3p02.png
|
||||
pnm2png.exe basn3p04.ppm basn3p04.png
|
||||
pnm2png.exe basn3p08.ppm basn3p08.png
|
||||
REM -- gray with alpha-channel
|
||||
pnm2png.exe -alpha basn6a08.pgm basn4a08.pgm basn4a08.png
|
||||
pnm2png.exe -alpha basn6a16.pgm basn4a16.pgm basn4a16.png
|
||||
REM -- color with alpha-channel
|
||||
pnm2png.exe -alpha basn6a08.pgm basn6a08.ppm basn6a08.png
|
||||
pnm2png.exe -alpha basn6a16.pgm basn6a16.ppm basn6a16.png
|
||||
REM -- grayscale
|
||||
pnm2png.exe rawn0g01.pgm rawn0g01.png
|
||||
pnm2png.exe rawn0g02.pgm rawn0g02.png
|
||||
pnm2png.exe rawn0g04.pgm rawn0g04.png
|
||||
pnm2png.exe rawn0g08.pgm rawn0g08.png
|
||||
pnm2png.exe rawn0g16.pgm rawn0g16.png
|
||||
REM -- full-color
|
||||
pnm2png.exe rawn2c08.ppm rawn2c08.png
|
||||
pnm2png.exe rawn2c16.ppm rawn2c16.png
|
||||
REM -- palletted
|
||||
pnm2png.exe rawn3p01.ppm rawn3p01.png
|
||||
pnm2png.exe rawn3p02.ppm rawn3p02.png
|
||||
pnm2png.exe rawn3p04.ppm rawn3p04.png
|
||||
pnm2png.exe rawn3p08.ppm rawn3p08.png
|
||||
REM -- gray with alpha-channel
|
||||
pnm2png.exe -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png
|
||||
pnm2png.exe -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png
|
||||
REM -- color with alpha-channel
|
||||
pnm2png.exe -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png
|
||||
pnm2png.exe -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png
|
||||
|
527
contrib/pngminus/pnm2png.c
Normal file
@ -0,0 +1,527 @@
|
||||
/*
|
||||
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
|
||||
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
|
||||
*
|
||||
* version 1.0 - 1999.10.15 - First version.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear in
|
||||
* supporting documentation. This software is provided "as is" without
|
||||
* express or implied warranty.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL unsigned char
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE (BOOL) 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE (BOOL) 0
|
||||
#endif
|
||||
|
||||
#define STDIN 0
|
||||
#define STDOUT 1
|
||||
#define STDERR 2
|
||||
|
||||
/* to make pnm2png verbose so we can find problems (needs to be before png.h) */
|
||||
#ifndef PNG_DEBUG
|
||||
#define PNG_DEBUG 0
|
||||
#endif
|
||||
|
||||
#include "png.h"
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
void usage ();
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha);
|
||||
void get_token(FILE *pnm_file, char *token);
|
||||
png_uint_32 get_data (FILE *pnm_file, int depth);
|
||||
png_uint_32 get_value (FILE *pnm_file, int depth);
|
||||
|
||||
/*
|
||||
* main
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fp_rd = stdin;
|
||||
FILE *fp_al = NULL;
|
||||
FILE *fp_wr = stdout;
|
||||
BOOL interlace = FALSE;
|
||||
BOOL alpha = FALSE;
|
||||
int argi;
|
||||
|
||||
for (argi = 1; argi < argc; argi++)
|
||||
{
|
||||
if (argv[argi][0] == '-')
|
||||
{
|
||||
switch (argv[argi][1])
|
||||
{
|
||||
case 'i':
|
||||
interlace = TRUE;
|
||||
break;
|
||||
case 'a':
|
||||
alpha = TRUE;
|
||||
argi++;
|
||||
if ((fp_al = fopen (argv[argi], "rb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: alpha-channel file %s does not exist\n", argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: unknown option %s\n", argv[argi]);
|
||||
usage();
|
||||
exit(1);
|
||||
break;
|
||||
} /* end switch */
|
||||
}
|
||||
else if (fp_rd == stdin)
|
||||
{
|
||||
if ((fp_rd = fopen (argv[argi], "rb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: file %s does not exist\n", argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
else if (fp_wr == stdout)
|
||||
{
|
||||
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: can not create PNG-file %s\n", argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: too many parameters\n");
|
||||
usage();
|
||||
exit (1);
|
||||
}
|
||||
} /* end for */
|
||||
|
||||
#ifdef __TURBOC__
|
||||
/* set stdin/stdout to binary, we're reading the PNM always! in binary format */
|
||||
if (fp_rd == stdin)
|
||||
{
|
||||
setmode (STDIN, O_BINARY);
|
||||
}
|
||||
if (fp_wr == stdout)
|
||||
{
|
||||
setmode (STDOUT, O_BINARY);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* call the conversion program itself */
|
||||
if (pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha) == FALSE)
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: unsuccessful converting to PNG-image\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* close input file */
|
||||
fclose (fp_rd);
|
||||
/* close output file */
|
||||
fclose (fp_wr);
|
||||
/* close alpha file */
|
||||
if (alpha)
|
||||
fclose (fp_al);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* usage
|
||||
*/
|
||||
|
||||
void usage()
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, " by Willem van Schaik, 1999\n");
|
||||
#ifdef __TURBOC__
|
||||
fprintf (stderr, " for Turbo-C and Borland-C compilers\n");
|
||||
#else
|
||||
fprintf (stderr, " for Linux (and Unix) compilers\n");
|
||||
#endif
|
||||
fprintf (stderr, "Usage: pnm2png [options] <file>.<pnm> [<file>.png]\n");
|
||||
fprintf (stderr, " or: ... | pnm2png [options]\n");
|
||||
fprintf (stderr, "Options:\n");
|
||||
fprintf (stderr, " -i[nterlace] write png-file with interlacing on\n");
|
||||
fprintf (stderr, " -a[lpha] <file>.pgm read PNG alpha channel as pgm-file\n");
|
||||
fprintf (stderr, " -h | -? print this help-information\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* pnm2png
|
||||
*/
|
||||
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha)
|
||||
{
|
||||
png_struct *png_ptr = NULL;
|
||||
png_info *info_ptr = NULL;
|
||||
png_byte *png_pixels = NULL;
|
||||
png_byte **row_pointers = NULL;
|
||||
png_byte *pix_ptr = NULL;
|
||||
png_uint_32 row_bytes;
|
||||
|
||||
char type_token[16];
|
||||
char width_token[16];
|
||||
char height_token[16];
|
||||
char maxval_token[16];
|
||||
int color_type;
|
||||
png_uint_32 width, alpha_width;
|
||||
png_uint_32 height, alpha_height;
|
||||
png_uint_32 maxval;
|
||||
int bit_depth = 0;
|
||||
int channels;
|
||||
int alpha_depth = 0;
|
||||
int alpha_present;
|
||||
int row, col;
|
||||
BOOL raw, alpha_raw = FALSE;
|
||||
png_uint_32 tmp16;
|
||||
int i;
|
||||
|
||||
/* read header of PNM file */
|
||||
|
||||
get_token(pnm_file, type_token);
|
||||
if (type_token[0] != 'P')
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else if ((type_token[1] == '1') || (type_token[1] == '4'))
|
||||
{
|
||||
raw = (type_token[1] == '4');
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
bit_depth = 1;
|
||||
}
|
||||
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
||||
{
|
||||
raw = (type_token[1] == '5');
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
get_token(pnm_file, width_token);
|
||||
sscanf (width_token, "%lu", &width);
|
||||
get_token(pnm_file, height_token);
|
||||
sscanf (height_token, "%lu", &height);
|
||||
get_token(pnm_file, maxval_token);
|
||||
sscanf (maxval_token, "%lu", &maxval);
|
||||
if (maxval <= 1)
|
||||
bit_depth = 1;
|
||||
else if (maxval <= 3)
|
||||
bit_depth = 2;
|
||||
else if (maxval <= 15)
|
||||
bit_depth = 4;
|
||||
else if (maxval <= 255)
|
||||
bit_depth = 8;
|
||||
else /* if (maxval <= 65535) */
|
||||
bit_depth = 16;
|
||||
}
|
||||
else if ((type_token[1] == '3') || (type_token[1] == '6'))
|
||||
{
|
||||
raw = (type_token[1] == '6');
|
||||
color_type = PNG_COLOR_TYPE_RGB;
|
||||
get_token(pnm_file, width_token);
|
||||
sscanf (width_token, "%lu", &width);
|
||||
get_token(pnm_file, height_token);
|
||||
sscanf (height_token, "%lu", &height);
|
||||
get_token(pnm_file, maxval_token);
|
||||
sscanf (maxval_token, "%lu", &maxval);
|
||||
if (maxval <= 1)
|
||||
bit_depth = 1;
|
||||
else if (maxval <= 3)
|
||||
bit_depth = 2;
|
||||
else if (maxval <= 15)
|
||||
bit_depth = 4;
|
||||
else if (maxval <= 255)
|
||||
bit_depth = 8;
|
||||
else /* if (maxval <= 65535) */
|
||||
bit_depth = 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* read header of PGM file with alpha channel */
|
||||
|
||||
if (alpha)
|
||||
{
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY)
|
||||
color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
|
||||
if (color_type == PNG_COLOR_TYPE_RGB)
|
||||
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||
|
||||
get_token(alpha_file, type_token);
|
||||
if (type_token[0] != 'P')
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
||||
{
|
||||
alpha_raw = (type_token[1] == '5');
|
||||
get_token(alpha_file, width_token);
|
||||
sscanf (width_token, "%lu", &alpha_width);
|
||||
if (alpha_width != width)
|
||||
return FALSE;
|
||||
get_token(alpha_file, height_token);
|
||||
sscanf (height_token, "%lu", &alpha_height);
|
||||
if (alpha_height != height)
|
||||
return FALSE;
|
||||
get_token(alpha_file, maxval_token);
|
||||
sscanf (maxval_token, "%lu", &maxval);
|
||||
if (maxval <= 1)
|
||||
alpha_depth = 1;
|
||||
else if (maxval <= 3)
|
||||
alpha_depth = 2;
|
||||
else if (maxval <= 15)
|
||||
alpha_depth = 4;
|
||||
else if (maxval <= 255)
|
||||
alpha_depth = 8;
|
||||
else /* if (maxval <= 65535) */
|
||||
alpha_depth = 16;
|
||||
if (alpha_depth != bit_depth)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
} /* end if alpha */
|
||||
|
||||
/* calculate the number of channels and store alpha-presence */
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY)
|
||||
channels = 1;
|
||||
else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
channels = 2;
|
||||
else if (color_type == PNG_COLOR_TYPE_RGB)
|
||||
channels = 3;
|
||||
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
channels = 4;
|
||||
else
|
||||
channels = 0; /* should not happen */
|
||||
|
||||
alpha_present = (channels - 1) % 2;
|
||||
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||
|
||||
if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* read data from PNM file */
|
||||
pix_ptr = png_pixels;
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
for (col = 0; col < width; col++)
|
||||
{
|
||||
for (i = 0; i < (channels - alpha_present); i++)
|
||||
{
|
||||
if (raw)
|
||||
*pix_ptr++ = get_data (pnm_file, bit_depth);
|
||||
else
|
||||
if (bit_depth <= 8)
|
||||
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (pnm_file, bit_depth);
|
||||
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
pix_ptr++;
|
||||
*pix_ptr = (png_byte) (tmp16 & 0xFF);
|
||||
pix_ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
if (alpha) /* read alpha-channel from pgm file */
|
||||
{
|
||||
if (alpha_raw)
|
||||
*pix_ptr++ = get_data (alpha_file, alpha_depth);
|
||||
else
|
||||
if (alpha_depth <= 8)
|
||||
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (alpha_file, bit_depth);
|
||||
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
||||
}
|
||||
} /* if alpha */
|
||||
|
||||
} /* end for col */
|
||||
} /* end for row */
|
||||
|
||||
/* prepare the standard PNG structures */
|
||||
png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (!png_ptr)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
info_ptr = png_create_info_struct (png_ptr);
|
||||
if (!info_ptr)
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
||||
if (setjmp (png_ptr->jmpbuf))
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* initialize the png structure */
|
||||
png_init_io (png_ptr, png_file);
|
||||
|
||||
/* we're going to write more or less the same PNG as the input file */
|
||||
png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type,
|
||||
(!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
/* write the file header information */
|
||||
png_write_info (png_ptr, info_ptr);
|
||||
|
||||
/* if needed we will allocate memory for an new array of row-pointers */
|
||||
if (row_pointers == (unsigned char**) NULL)
|
||||
{
|
||||
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* set the individual row_pointers to point at the correct offsets */
|
||||
for (i = 0; i < (height); i++)
|
||||
row_pointers[i] = png_pixels + i * row_bytes;
|
||||
|
||||
/* write out the entire image data in one call */
|
||||
png_write_image (png_ptr, row_pointers);
|
||||
|
||||
/* write the additional chuncks to the PNG file (not really needed) */
|
||||
png_write_end (png_ptr, info_ptr);
|
||||
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
|
||||
if (row_pointers != (unsigned char**) NULL)
|
||||
free (row_pointers);
|
||||
if (png_pixels != (unsigned char*) NULL)
|
||||
free (png_pixels);
|
||||
|
||||
return TRUE;
|
||||
} /* end of pnm2png */
|
||||
|
||||
/*
|
||||
* get_token() - gets the first string after whitespace
|
||||
*/
|
||||
|
||||
void get_token(FILE *pnm_file, char *token)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
/* remove white-space */
|
||||
do
|
||||
{
|
||||
token[i] = (unsigned char) fgetc (pnm_file);
|
||||
}
|
||||
while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
|
||||
|
||||
/* read string */
|
||||
do
|
||||
{
|
||||
i++;
|
||||
token[i] = (unsigned char) fgetc (pnm_file);
|
||||
}
|
||||
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
|
||||
|
||||
token[i] = '\0';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_data() - takes first byte and converts into next pixel value,
|
||||
* taking as much bits as defined by bit-depth and
|
||||
* using the bit-depth to fill up a byte (0Ah -> AAh)
|
||||
*/
|
||||
|
||||
png_uint_32 get_data (FILE *pnm_file, int depth)
|
||||
{
|
||||
static int bits_left = 0;
|
||||
static int old_value = 0;
|
||||
static int mask = 0;
|
||||
int i;
|
||||
png_uint_32 ret_value;
|
||||
|
||||
if (mask == 0)
|
||||
for (i = 0; i < depth; i++)
|
||||
mask = (mask >> 1) | 0x80;
|
||||
|
||||
if (bits_left <= 0)
|
||||
{
|
||||
old_value = fgetc (pnm_file);
|
||||
bits_left = 8;
|
||||
}
|
||||
|
||||
ret_value = old_value & mask;
|
||||
for (i = 1; i < (8 / depth); i++)
|
||||
ret_value = ret_value || (ret_value >> depth);
|
||||
|
||||
old_value = (old_value << depth) & 0xFF;
|
||||
bits_left -= depth;
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_value() - takes first (numeric) string and converts into number,
|
||||
* using the bit-depth to fill up a byte (0Ah -> AAh)
|
||||
*/
|
||||
|
||||
png_uint_32 get_value (FILE *pnm_file, int depth)
|
||||
{
|
||||
static png_uint_32 mask = 0;
|
||||
png_byte token[16];
|
||||
png_uint_32 ret_value;
|
||||
int i = 0;
|
||||
|
||||
if (mask == 0)
|
||||
for (i = 0; i < depth; i++)
|
||||
mask = (mask << 1) | 0x01;
|
||||
|
||||
get_token (pnm_file, token);
|
||||
sscanf (token, "%lu", &ret_value);
|
||||
|
||||
ret_value &= mask;
|
||||
|
||||
if (depth < 8)
|
||||
for (i = 0; i < (8 / depth); i++)
|
||||
ret_value = (ret_value << depth) || ret_value;
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/* end of source */
|
||||
|
41
contrib/pngminus/pnm2png.sh
Executable file
@ -0,0 +1,41 @@
|
||||
# -- grayscale
|
||||
./pnm2png basn0g01.pgm basn0g01.png
|
||||
./pnm2png basn0g02.pgm basn0g02.png
|
||||
./pnm2png basn0g04.pgm basn0g04.png
|
||||
./pnm2png basn0g08.pgm basn0g08.png
|
||||
./pnm2png basn0g16.pgm basn0g16.png
|
||||
# -- full-color
|
||||
./pnm2png basn2c08.ppm basn2c08.png
|
||||
./pnm2png basn2c16.ppm basn2c16.png
|
||||
# -- palletted
|
||||
./pnm2png basn3p01.ppm basn3p01.png
|
||||
./pnm2png basn3p02.ppm basn3p02.png
|
||||
./pnm2png basn3p04.ppm basn3p04.png
|
||||
./pnm2png basn3p08.ppm basn3p08.png
|
||||
# -- gray with alpha-channel
|
||||
./pnm2png -alpha basn6a08.pgm basn4a08.pgm basn4a08.png
|
||||
./pnm2png -alpha basn6a16.pgm basn4a16.pgm basn4a16.png
|
||||
# -- color with alpha-channel
|
||||
./pnm2png -alpha basn6a08.pgm basn6a08.ppm basn6a08.png
|
||||
./pnm2png -alpha basn6a16.pgm basn6a16.ppm basn6a16.png
|
||||
# -- grayscale
|
||||
./pnm2png rawn0g01.pgm rawn0g01.png
|
||||
./pnm2png rawn0g02.pgm rawn0g02.png
|
||||
./pnm2png rawn0g04.pgm rawn0g04.png
|
||||
./pnm2png rawn0g08.pgm rawn0g08.png
|
||||
./pnm2png rawn0g16.pgm rawn0g16.png
|
||||
# -- full-color
|
||||
./pnm2png rawn2c08.ppm rawn2c08.png
|
||||
./pnm2png rawn2c16.ppm rawn2c16.png
|
||||
# -- palletted
|
||||
./pnm2png rawn3p01.ppm rawn3p01.png
|
||||
./pnm2png rawn3p02.ppm rawn3p02.png
|
||||
./pnm2png rawn3p04.ppm rawn3p04.png
|
||||
./pnm2png rawn3p08.ppm rawn3p08.png
|
||||
# -- gray with alpha-channel
|
||||
./pnm2png -alpha rawn6a08.pgm rawn4a08.pgm rawn4a08.png
|
||||
./pnm2png -alpha rawn6a16.pgm rawn4a16.pgm rawn4a16.png
|
||||
# -- color with alpha-channel
|
||||
./pnm2png -alpha rawn6a08.pgm rawn6a08.ppm rawn6a08.png
|
||||
./pnm2png -alpha rawn6a16.pgm rawn6a16.ppm rawn6a16.png
|
||||
|
85
contrib/pngsuite/README
Normal file
@ -0,0 +1,85 @@
|
||||
|
||||
pngsuite
|
||||
--------
|
||||
(c) Willem van Schaik, 1999
|
||||
|
||||
Permission to use, copy, and distribute these images for any purpose and
|
||||
without fee is hereby granted.
|
||||
|
||||
These 15 images are part of the much larger PngSuite test-set of
|
||||
images, available for developers of PNG supporting software. The
|
||||
complete set, available at http:/www.schaik.com/pngsuite/, contains
|
||||
a variety of images to test interlacing, gamma settings, ancillary
|
||||
chunks, etc.
|
||||
|
||||
The images in this directory represent the basic PNG color-types:
|
||||
grayscale (1-16 bit deep), full color (8 or 16 bit), paletted
|
||||
(1-8 bit) and grayscale or color images with alpha channel. You
|
||||
can use them to test the proper functioning of PNG software.
|
||||
|
||||
filename depth type
|
||||
------------ ------ --------------
|
||||
basn0g01.png 1-bit grayscale
|
||||
basn0g02.png 2-bit grayscale
|
||||
basn0g04.png 4-bit grayscale
|
||||
basn0g08.png 8-bit grayscale
|
||||
basn0g16.png 16-bit grayscale
|
||||
basn2c08.png 8-bit truecolor
|
||||
basn2c16.png 16-bit truecolor
|
||||
basn3p01.png 1-bit paletted
|
||||
basn3p02.png 2-bit paletted
|
||||
basn3p04.png 4-bit paletted
|
||||
basn3p08.png 8-bit paletted
|
||||
basn4a08.png 8-bit gray with alpha
|
||||
basn4a16.png 16-bit gray with alpha
|
||||
basn6a08.png 8-bit RGBA
|
||||
basn6a16.png 16-bit RGBA
|
||||
|
||||
Here is the correct result of typing "pngtest -m *.png" in
|
||||
this directory:
|
||||
|
||||
Testing basn0g01.png: PASS (524 zero samples)
|
||||
Filter 0 was used 32 times
|
||||
Testing basn0g02.png: PASS (448 zero samples)
|
||||
Filter 0 was used 32 times
|
||||
Testing basn0g04.png: PASS (520 zero samples)
|
||||
Filter 0 was used 32 times
|
||||
Testing basn0g08.png: PASS (3 zero samples)
|
||||
Filter 1 was used 9 times
|
||||
Filter 4 was used 23 times
|
||||
Testing basn0g16.png: PASS (1 zero samples)
|
||||
Filter 1 was used 1 times
|
||||
Filter 2 was used 31 times
|
||||
Testing basn2c08.png: PASS (6 zero samples)
|
||||
Filter 1 was used 5 times
|
||||
Filter 4 was used 27 times
|
||||
Testing basn2c16.png: PASS (592 zero samples)
|
||||
Filter 1 was used 1 times
|
||||
Filter 4 was used 31 times
|
||||
Testing basn3p01.png: PASS (512 zero samples)
|
||||
Filter 0 was used 32 times
|
||||
Testing basn3p02.png: PASS (448 zero samples)
|
||||
Filter 0 was used 32 times
|
||||
Testing basn3p04.png: PASS (544 zero samples)
|
||||
Filter 0 was used 32 times
|
||||
Testing basn3p08.png: PASS (4 zero samples)
|
||||
Filter 0 was used 32 times
|
||||
Testing basn4a08.png: PASS (32 zero samples)
|
||||
Filter 1 was used 1 times
|
||||
Filter 4 was used 31 times
|
||||
Testing basn4a16.png: PASS (64 zero samples)
|
||||
Filter 0 was used 1 times
|
||||
Filter 1 was used 2 times
|
||||
Filter 2 was used 1 times
|
||||
Filter 4 was used 28 times
|
||||
Testing basn6a08.png: PASS (160 zero samples)
|
||||
Filter 1 was used 1 times
|
||||
Filter 4 was used 31 times
|
||||
Testing basn6a16.png: PASS (1072 zero samples)
|
||||
Filter 1 was used 4 times
|
||||
Filter 4 was used 28 times
|
||||
libpng passes test
|
||||
|
||||
Willem van Schaik
|
||||
<willem@schaik.com>
|
||||
October 1999
|
BIN
contrib/pngsuite/basn0g01.png
Normal file
After Width: | Height: | Size: 164 B |
BIN
contrib/pngsuite/basn0g02.png
Normal file
After Width: | Height: | Size: 104 B |
BIN
contrib/pngsuite/basn0g04.png
Normal file
After Width: | Height: | Size: 145 B |
BIN
contrib/pngsuite/basn0g08.png
Normal file
After Width: | Height: | Size: 138 B |
BIN
contrib/pngsuite/basn0g16.png
Normal file
After Width: | Height: | Size: 167 B |
BIN
contrib/pngsuite/basn2c08.png
Normal file
After Width: | Height: | Size: 145 B |
BIN
contrib/pngsuite/basn2c16.png
Normal file
After Width: | Height: | Size: 302 B |
BIN
contrib/pngsuite/basn3p01.png
Normal file
After Width: | Height: | Size: 112 B |
BIN
contrib/pngsuite/basn3p02.png
Normal file
After Width: | Height: | Size: 146 B |
BIN
contrib/pngsuite/basn3p04.png
Normal file
After Width: | Height: | Size: 216 B |
BIN
contrib/pngsuite/basn3p08.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
contrib/pngsuite/basn4a08.png
Normal file
After Width: | Height: | Size: 126 B |
BIN
contrib/pngsuite/basn4a16.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
contrib/pngsuite/basn6a08.png
Normal file
After Width: | Height: | Size: 184 B |
BIN
contrib/pngsuite/basn6a16.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
@ -227,7 +227,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
int intent;
|
||||
|
||||
if (png_get_sRGB(png_ptr, info_ptr, &intent))
|
||||
png_set_sRGB(png_ptr, intent, 0);
|
||||
png_set_sRGB(png_ptr, info_ptr, intent);
|
||||
else
|
||||
{
|
||||
double image_gamma;
|
||||
|
14
libpng.3
@ -1,6 +1,6 @@
|
||||
.TH LIBPNG 3 "October 15, 1999"
|
||||
.TH LIBPNG 3 "October 23, 1999"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5 - October 15, 1999
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5a - October 23, 1999
|
||||
.SH SYNOPSIS
|
||||
\fI\fB
|
||||
|
||||
@ -617,7 +617,7 @@ Following is a copy of the libpng.txt file that accompanies libpng.
|
||||
.SH LIBPNG.TXT
|
||||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.0.5 - October 15, 1999
|
||||
libpng version 1.0.5a - October 23, 1999
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<randeg@alum.rpi.edu>
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
@ -2675,13 +2675,13 @@ the old method.
|
||||
|
||||
.SH VII. Y2K Compliance in libpng
|
||||
|
||||
October 15, 1999
|
||||
October 23, 1999
|
||||
|
||||
Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
|
||||
This is your unofficial assurance that libpng from version 0.71 and
|
||||
upward through 1.0.5 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.0.5a are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has three year fields. One is a 2-byte unsigned integer that
|
||||
@ -2807,7 +2807,7 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 1.0.5 - October 15, 1999:
|
||||
Libpng version 1.0.5a - October 23, 1999:
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
|
||||
|
||||
@ -2822,7 +2822,7 @@ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
Copyright (c) 1996, 1997 Andreas Dilger
|
||||
(libpng versions 0.90, December 1996, through 0.96, May 1997)
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
(libpng versions 0.97, January 1998, through 1.0.5, October 15, 1999)
|
||||
(libpng versions 0.97, January 1998, through 1.0.5a, October 23, 1999)
|
||||
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
|
@ -1,6 +1,6 @@
|
||||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.0.5 - October 15, 1999
|
||||
libpng version 1.0.5a - October 23, 1999
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<randeg@alum.rpi.edu>
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
@ -2058,13 +2058,13 @@ the old method.
|
||||
|
||||
VII. Y2K Compliance in libpng
|
||||
|
||||
October 15, 1999
|
||||
October 23, 1999
|
||||
|
||||
Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
|
||||
This is your unofficial assurance that libpng from version 0.71 and
|
||||
upward through 1.0.5 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.0.5a are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has three year fields. One is a 2-byte unsigned integer that
|
||||
|
@ -1,6 +1,6 @@
|
||||
.TH LIBPNGPF 3 October 15, 1999
|
||||
.TH LIBPNGPF 3 October 23, 1999
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5 - October 15, 1999
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5a - October 23, 1999
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include <png.h>\fP
|
||||
|
2
png.5
@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "October 15, 1999"
|
||||
.TH PNG 5 "October 23, 1999"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
17
png.c
@ -1,7 +1,7 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng version 1.0.5 - October 15, 1999
|
||||
* libpng version 1.0.5a - October 23, 1999
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
@ -18,7 +18,7 @@ PNG_GET_HEADER
|
||||
* string defined in png.h.
|
||||
*/
|
||||
|
||||
char png_libpng_ver[12] = "1.0.5";
|
||||
char png_libpng_ver[12] = "1.0.5a";
|
||||
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
@ -266,10 +266,15 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < info_ptr->num_text; i++)
|
||||
{
|
||||
if(info_ptr->text[i].key != NULL)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->text[i].key);
|
||||
info_ptr->text[i].key = NULL;
|
||||
}
|
||||
}
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
info_ptr->text = NULL;
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
@ -281,8 +286,10 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->pcal_params[i]);
|
||||
info_ptr->pcal_params[i]=NULL;
|
||||
}
|
||||
png_free(png_ptr, info_ptr->pcal_params);
|
||||
info_ptr->pcal_params = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -353,7 +360,7 @@ png_charp
|
||||
png_get_copyright(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
|
||||
return ("\n libpng version 1.0.5 - October 15, 1999\n\
|
||||
return ("\n libpng version 1.0.5a - October 23, 1999\n\
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
|
||||
Copyright (c) 1996, 1997 Andreas Dilger\n\
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
|
||||
@ -363,8 +370,8 @@ png_get_copyright(png_structp png_ptr)
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
void
|
||||
png_check_version
|
||||
(version_1_0_5 png_h_is_not_version_1_0_5)
|
||||
(version_1_0_5a png_h_is_not_version_1_0_5a)
|
||||
{
|
||||
if(png_h_is_not_version_1_0_5 == NULL)
|
||||
if(png_h_is_not_version_1_0_5a == NULL)
|
||||
return;
|
||||
}
|
||||
|
27
png.h
@ -1,7 +1,7 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.0.5 - October 15, 1999
|
||||
* libpng version 1.0.5a - October 23, 1999
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
@ -9,19 +9,19 @@
|
||||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
|
||||
* libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.0.5 - October 15, 1999: Glenn
|
||||
* libpng versions 0.97, January 1998, through 1.0.5a - October 23, 1999: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* October 15, 1999
|
||||
* October 23, 1999
|
||||
*
|
||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||
* an official declaration.
|
||||
*
|
||||
* This is your unofficial assurance that libpng from version 0.71 and
|
||||
* upward through 1.0.5 are Y2K compliant. It is my belief that earlier
|
||||
* upward through 1.0.5a are Y2K compliant. It is my belief that earlier
|
||||
* versions were also Y2K compliant.
|
||||
*
|
||||
* Libpng only has three year fields. One is a 2-byte unsigned integer
|
||||
@ -97,6 +97,8 @@
|
||||
* 1.0.4 1.0.4 10004 2.1.0.4
|
||||
* 1.0.4a-f 1.0.4a-f 10005 2.1.0.4a-f
|
||||
* 1.0.5 1.0.5 10005 2.1.0.5
|
||||
* 1.0.5a 1.0.5a 10006 2.1.0.5a
|
||||
* 1.0.6 1.0.6 10006 2.1.0.6
|
||||
*
|
||||
* Henceforth the source version will match the shared-library minor
|
||||
* and patch numbers; the shared-library major version number will be
|
||||
@ -104,7 +106,8 @@
|
||||
* PNG_PNGLIB_VER macro, which is not used within libpng but is available
|
||||
* for applications, is an unsigned integer of the form xyyzz corresponding
|
||||
* to the source version x.y.z (leading zeros in y and z). Internal
|
||||
* png-group versions (x.y.z[a-z]) will be given the next higher number.
|
||||
* png-group beta versions (x.y.z[a-z]) will be given the next higher
|
||||
* number.
|
||||
*
|
||||
* See libpng.txt or libpng.3 for more information. The PNG specification
|
||||
* is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
|
||||
@ -119,7 +122,7 @@
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* (libpng versions 0.90, December 1996, through 0.96, May 1997)
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
* (libpng versions 0.97, January 1998, through 1.0.5, October 15, 1999)
|
||||
* (libpng versions 0.97, January 1998, through 1.0.5a, October 23, 1999)
|
||||
*
|
||||
* For the purposes of this copyright and license, "Contributing Authors"
|
||||
* is defined as the following set of individuals:
|
||||
@ -219,14 +222,14 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.0.5"
|
||||
#define PNG_LIBPNG_VER_STRING "1.0.5a"
|
||||
|
||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||
* We must not include leading zeros.
|
||||
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
|
||||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=bugfix */
|
||||
#define PNG_LIBPNG_VER 10005 /* 1.0.5 */
|
||||
#define PNG_LIBPNG_VER 10006 /* 1.0.6 */
|
||||
|
||||
/* Note to maintainer: update this number in scripts/pngdef.pas as well */
|
||||
|
||||
@ -817,9 +820,9 @@ struct png_struct_def
|
||||
};
|
||||
|
||||
/* This prevents a compiler error in png_get_copyright() in png.c if png.c
|
||||
and png.h are both at * version 1.0.5
|
||||
and png.h are both at * version 1.0.5a
|
||||
*/
|
||||
typedef png_structp version_1_0_5;
|
||||
typedef png_structp version_1_0_5a;
|
||||
|
||||
typedef png_struct FAR * FAR * png_structpp;
|
||||
|
||||
@ -1641,8 +1644,8 @@ png_charp \
|
||||
png_get_header_version(png_structp png_ptr) \
|
||||
{ \
|
||||
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ \
|
||||
return("\n libpng version 1.0.5 - October 15, 1999 (header)\n"); \
|
||||
return("\n libpng version 1.0.5 - October 15, 1999 (header)\n"); \
|
||||
return("\n libpng version 1.0.5a - October 23, 1999 (header)\n"); \
|
||||
return("\n libpng version 1.0.5a - October 23, 1999 (header)\n"); \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* pngasmrd.h - assembler version of utilities to read a PNG file
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1999 Glenn Randers-Pehrson
|
||||
*
|
||||
@ -21,7 +21,7 @@
|
||||
/* Set this in the makefile for gcc on Pentium, not in pngconf.h */
|
||||
#ifdef PNG_USE_PNGGCCRD
|
||||
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c
|
||||
* (not available in libpng 1.0.5).
|
||||
* (not available in libpng 1.0.5a).
|
||||
* MMX will be detected at run time and used if present.
|
||||
*/
|
||||
#define PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
2
pngget.c
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
5
pngmem.c
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@ -433,6 +433,9 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
||||
void
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@ -529,7 +529,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
* not called png_set_interlace_handling(), the display_row buffer will
|
||||
* be ignored, so pass NULL to it.
|
||||
*
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5a.
|
||||
*/
|
||||
|
||||
void
|
||||
@ -578,7 +578,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||
* only call this function once. If you desire to have an image for
|
||||
* each pass of a interlaced image, use png_read_rows() instead.
|
||||
*
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5a.
|
||||
*/
|
||||
void
|
||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||
|
2
pngrio.c
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@ -1263,6 +1263,7 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 1);
|
||||
|
||||
png_free(png_ptr, key);
|
||||
png_free(png_ptr, text_ptr);
|
||||
}
|
||||
#endif
|
||||
@ -1280,7 +1281,6 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_size_t slength;
|
||||
|
||||
png_debug(1, "in png_handle_zTXt\n");
|
||||
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before zTXt");
|
||||
|
||||
@ -1432,6 +1432,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 1);
|
||||
|
||||
png_free(png_ptr, text_ptr->key);
|
||||
png_free(png_ptr, text_ptr);
|
||||
}
|
||||
#endif
|
||||
|
33
pngset.c
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@ -317,9 +317,10 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
for (i = 0; i < num_text; i++)
|
||||
{
|
||||
png_textp textp = &(info_ptr->text[info_ptr->num_text]);
|
||||
png_charp key,text;
|
||||
|
||||
if (text_ptr[i].text == NULL)
|
||||
text_ptr[i].text = (png_charp)"";
|
||||
if (text_ptr[i].key == (png_charp)NULL)
|
||||
continue;
|
||||
|
||||
if (text_ptr[i].text[0] == '\0')
|
||||
{
|
||||
@ -331,8 +332,30 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
textp->text_length = png_strlen(text_ptr[i].text);
|
||||
textp->compression = text_ptr[i].compression;
|
||||
}
|
||||
textp->text = text_ptr[i].text;
|
||||
textp->key = text_ptr[i].key;
|
||||
key=text_ptr[i].key;
|
||||
for (text = key; *text++;)
|
||||
/* empty loop to find the byte after the zero byte after the
|
||||
end of key */ ;
|
||||
|
||||
textp->key = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)(text+textp->text_length - key)+1);
|
||||
/* Caution: the calling program, not libpng, is responsible for
|
||||
freeing this, if libpng wasn't the caller. */
|
||||
png_debug2(2, "Allocated %d bytes at %x in png_set_text\n",
|
||||
text+textp->text_length-key+1, textp->key);
|
||||
|
||||
png_memcpy(textp->key, text_ptr[i].key,
|
||||
(png_size_t)(text - key)); /* includes the zero-byte separator */
|
||||
textp->text = textp->key + (text-key);
|
||||
if(textp->text_length)
|
||||
{
|
||||
png_memcpy(textp->text, text_ptr[i].text,
|
||||
(png_size_t)(textp->text_length));
|
||||
*(textp->text+textp->text_length) = '\0';
|
||||
}
|
||||
else
|
||||
textp->text--;
|
||||
info_ptr->text[info_ptr->num_text]= *textp;
|
||||
info_ptr->num_text++;
|
||||
png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
|
||||
}
|
||||
|
59
pngtest.c
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@ -443,6 +443,10 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size) {
|
||||
pinformation = pinfo;
|
||||
/* Make sure the caller isn't assuming zeroed memory. */
|
||||
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
||||
#if PNG_DEBUG
|
||||
if(verbose)
|
||||
printf("png_malloc %d bytes at %x\n",size,pinfo->pointer);
|
||||
#endif
|
||||
return (png_voidp)(pinfo->pointer);
|
||||
}
|
||||
}
|
||||
@ -485,6 +489,10 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||
}
|
||||
|
||||
/* Finally free the data. */
|
||||
#if PNG_DEBUG
|
||||
if(verbose)
|
||||
printf("Freeing %x\n",ptr);
|
||||
#endif
|
||||
png_free_default(png_ptr, ptr);
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
@ -496,7 +504,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
static FILE *fpin, *fpout; /* "static" prevents setjmp corruption */
|
||||
png_structp read_ptr, write_ptr;
|
||||
png_infop read_info_ptr, write_info_ptr, end_info_ptr;
|
||||
png_infop read_info_ptr, write_info_ptr, end_info_ptr, write_end_info_ptr;
|
||||
png_bytep row_buf;
|
||||
png_uint_32 y;
|
||||
png_uint_32 width, height;
|
||||
@ -552,6 +560,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
read_info_ptr = png_create_info_struct(read_ptr);
|
||||
write_info_ptr = png_create_info_struct(write_ptr);
|
||||
end_info_ptr = png_create_info_struct(read_ptr);
|
||||
write_end_info_ptr = png_create_info_struct(write_ptr);
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
#endif
|
||||
|
||||
@ -564,6 +573,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
|
||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
@ -582,6 +592,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname);
|
||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
@ -762,6 +773,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)
|
||||
{
|
||||
int i;
|
||||
png_debug1(0, "Handling %d tEXt/zTXt chunks\n", num_text);
|
||||
png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
|
||||
}
|
||||
@ -809,6 +821,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
fprintf(STDERR, "No memory to allocate row buffer\n");
|
||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, (png_infopp)NULL);
|
||||
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
@ -851,7 +864,38 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
png_debug(0, "Reading and writing end_info data\n");
|
||||
png_read_end(read_ptr, end_info_ptr);
|
||||
png_write_end(write_ptr, end_info_ptr);
|
||||
#if (defined(PNG_READ_tEXt_SUPPORTED) && defined(PNG_WRITE_tEXt_SUPPORTED)) || \
|
||||
(defined(PNG_READ_zTXt_SUPPORTED) && defined(PNG_WRITE_zTXt_SUPPORTED))
|
||||
{
|
||||
png_textp text_ptr;
|
||||
int num_text;
|
||||
|
||||
if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
|
||||
{
|
||||
int i;
|
||||
png_debug1(0, "Handling %d tEXt/zTXt chunks\n", num_text);
|
||||
png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_tIME_SUPPORTED) && defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
{
|
||||
png_timep mod_time;
|
||||
|
||||
if (png_get_tIME(read_ptr, end_info_ptr, &mod_time))
|
||||
{
|
||||
png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
|
||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||
/* we have to use png_strcpy instead of "=" because the string
|
||||
pointed to by png_convert_to_rfc1123() gets free'ed before
|
||||
we use it */
|
||||
png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time));
|
||||
tIME_chunk_present++;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
png_write_end(write_ptr, write_end_info_ptr);
|
||||
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
if(verbose)
|
||||
@ -867,6 +911,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_debug(0, "Destroying data structs\n");
|
||||
png_free(read_ptr, row_buf);
|
||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||
|
||||
fclose(fpin);
|
||||
@ -1038,7 +1083,7 @@ main(int argc, char *argv[])
|
||||
if (kerror == 0)
|
||||
{
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
fprintf(STDERR, " PASS (%lu zero samples)\n",zero_samples);
|
||||
fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples);
|
||||
#else
|
||||
fprintf(STDERR, " PASS\n");
|
||||
#endif
|
||||
@ -1101,7 +1146,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
int k;
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
fprintf(STDERR, " PASS (%lu zero samples)\n",zero_samples);
|
||||
fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples);
|
||||
#else
|
||||
fprintf(STDERR, " PASS\n");
|
||||
#endif
|
||||
@ -1172,7 +1217,7 @@ main(int argc, char *argv[])
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
void
|
||||
png_check_pngtest_version
|
||||
(version_1_0_5 png_h_is_not_version_1_0_5)
|
||||
(version_1_0_5a png_h_is_not_version_1_0_5a)
|
||||
{
|
||||
if(png_h_is_not_version_1_0_5 == NULL) return;
|
||||
if(png_h_is_not_version_1_0_5a == NULL) return;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
104
pngvcrd.c
@ -2,7 +2,7 @@
|
||||
*
|
||||
* For Intel x86 CPU and Microsoft Visual C++ compiler
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998, Intel Corporation
|
||||
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
|
||||
@ -17,6 +17,12 @@
|
||||
|
||||
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)
|
||||
|
||||
/*
|
||||
One of these might need to be defined.
|
||||
#define DISABLE_PNGVCRD_COMBINE
|
||||
#define DISABLE_PNGVCRD_INTERLACE
|
||||
*/
|
||||
|
||||
static int mmx_supported=2;
|
||||
|
||||
void
|
||||
@ -1182,7 +1188,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
{
|
||||
if (pixel_bytes == 3)
|
||||
{
|
||||
if ((pass == 0) || (pass == 1))
|
||||
if (((pass == 0) || (pass == 1)) && width)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
@ -1217,7 +1223,7 @@ loop_pass0:
|
||||
EMMS
|
||||
}
|
||||
}
|
||||
else if ((pass == 2) || (pass == 3))
|
||||
else if (((pass == 2) || (pass == 3)) && width)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
@ -1245,10 +1251,12 @@ loop_pass2:
|
||||
EMMS
|
||||
}
|
||||
}
|
||||
else /* if ((pass == 4) || (pass == 5)) */
|
||||
else if (width) /* && ((pass == 4) || (pass == 5)) */
|
||||
{
|
||||
int width_mmx = ((width >> 1) << 1) - 8;
|
||||
width -= width_mmx;
|
||||
if (width_mmx < 0)
|
||||
width_mmx = 0;
|
||||
width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes
|
||||
if (width_mmx)
|
||||
{
|
||||
_asm
|
||||
@ -1288,20 +1296,20 @@ loop_pass4:
|
||||
png_byte v[8];
|
||||
int j;
|
||||
|
||||
png_memcpy(v, sptr, pixel_bytes);
|
||||
png_memcpy(v, sptr, 3);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
{
|
||||
png_memcpy(dp, v, pixel_bytes);
|
||||
dp -= pixel_bytes;
|
||||
png_memcpy(dp, v, 3);
|
||||
dp -= 3;
|
||||
}
|
||||
sptr -= pixel_bytes;
|
||||
sptr -= 3;
|
||||
}
|
||||
}
|
||||
} /* end of pixel_bytes == 3 */
|
||||
|
||||
else if (pixel_bytes == 1)
|
||||
{
|
||||
if ((pass == 0) || (pass == 1))
|
||||
if (((pass == 0) || (pass == 1)) && width)
|
||||
{
|
||||
int width_mmx = ((width >> 2) << 2);
|
||||
width -= width_mmx;
|
||||
@ -1368,7 +1376,7 @@ loop1_pass0:
|
||||
sptr--;
|
||||
}
|
||||
}
|
||||
else if ((pass == 2) || (pass == 3))
|
||||
else if (((pass == 2) || (pass == 3)) && width)
|
||||
{
|
||||
int width_mmx = ((width >> 2) << 2);
|
||||
width -= width_mmx;
|
||||
@ -1410,7 +1418,7 @@ loop1_pass2:
|
||||
sptr --;
|
||||
}
|
||||
}
|
||||
else //if ((pass == 4) || (pass == 5))
|
||||
else if (width) /* && ((pass == 4) || (pass == 5))) */
|
||||
{
|
||||
int width_mmx = ((width >> 3) << 3);
|
||||
width -= width_mmx;
|
||||
@ -1457,7 +1465,7 @@ loop1_pass4:
|
||||
|
||||
else if (pixel_bytes == 2)
|
||||
{
|
||||
if ((pass == 0) || (pass == 1))
|
||||
if (((pass == 0) || (pass == 1)) && width)
|
||||
{
|
||||
int width_mmx = ((width >> 1) << 1);
|
||||
width -= width_mmx;
|
||||
@ -1494,17 +1502,16 @@ loop2_pass0:
|
||||
{
|
||||
png_byte v[8];
|
||||
int j;
|
||||
sptr -= pixel_bytes;
|
||||
png_memcpy(v, sptr, pixel_bytes);
|
||||
sptr -= 2;
|
||||
png_memcpy(v, sptr, 2);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
{
|
||||
dp -= pixel_bytes;
|
||||
png_memcpy(dp, v, pixel_bytes);
|
||||
dp -= 2;
|
||||
png_memcpy(dp, v, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if ((pass == 2) || (pass == 3))
|
||||
else if (((pass == 2) || (pass == 3)) && width)
|
||||
{
|
||||
int width_mmx = ((width >> 1) << 1) ;
|
||||
width -= width_mmx;
|
||||
@ -1540,17 +1547,16 @@ loop2_pass2:
|
||||
{
|
||||
png_byte v[8];
|
||||
int j;
|
||||
sptr -= pixel_bytes;
|
||||
png_memcpy(v, sptr, pixel_bytes);
|
||||
sptr -= 2;
|
||||
png_memcpy(v, sptr, 2);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
{
|
||||
dp -= pixel_bytes;
|
||||
png_memcpy(dp, v, pixel_bytes);
|
||||
dp -= 2;
|
||||
png_memcpy(dp, v, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else // pass == 4 or 5
|
||||
else if (width) // pass == 4 or 5
|
||||
{
|
||||
int width_mmx = ((width >> 1) << 1) ;
|
||||
width -= width_mmx;
|
||||
@ -1581,12 +1587,12 @@ loop2_pass4:
|
||||
{
|
||||
png_byte v[8];
|
||||
int j;
|
||||
sptr -= pixel_bytes;
|
||||
png_memcpy(v, sptr, pixel_bytes);
|
||||
sptr -= 2;
|
||||
png_memcpy(v, sptr, 2);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
{
|
||||
dp -= pixel_bytes;
|
||||
png_memcpy(dp, v, pixel_bytes);
|
||||
dp -= 2;
|
||||
png_memcpy(dp, v, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1594,7 +1600,7 @@ loop2_pass4:
|
||||
|
||||
else if (pixel_bytes == 4)
|
||||
{
|
||||
if ((pass == 0) || (pass == 1))
|
||||
if (((pass == 0) || (pass == 1)) && width)
|
||||
{
|
||||
int width_mmx = ((width >> 1) << 1) ;
|
||||
width -= width_mmx;
|
||||
@ -1634,17 +1640,16 @@ loop4_pass0:
|
||||
{
|
||||
png_byte v[8];
|
||||
int j;
|
||||
sptr -= pixel_bytes;
|
||||
png_memcpy(v, sptr, pixel_bytes);
|
||||
sptr -= 4;
|
||||
png_memcpy(v, sptr, 4);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
{
|
||||
dp -= pixel_bytes;
|
||||
png_memcpy(dp, v, pixel_bytes);
|
||||
dp -= 4;
|
||||
png_memcpy(dp, v, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if ((pass == 2) || (pass == 3))
|
||||
else if (((pass == 2) || (pass == 3)) && width)
|
||||
{
|
||||
int width_mmx = ((width >> 1) << 1) ;
|
||||
width -= width_mmx;
|
||||
@ -1680,17 +1685,16 @@ loop4_pass2:
|
||||
{
|
||||
png_byte v[8];
|
||||
int j;
|
||||
sptr -= pixel_bytes;
|
||||
png_memcpy(v, sptr, pixel_bytes);
|
||||
sptr -= 4;
|
||||
png_memcpy(v, sptr, 4);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
{
|
||||
dp -= pixel_bytes;
|
||||
png_memcpy(dp, v, pixel_bytes);
|
||||
dp -= 4;
|
||||
png_memcpy(dp, v, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else // pass == 4 or 5
|
||||
else if (width) // pass == 4 or 5
|
||||
{
|
||||
int width_mmx = ((width >> 1) << 1) ;
|
||||
width -= width_mmx;
|
||||
@ -1724,12 +1728,12 @@ loop4_pass4:
|
||||
{
|
||||
png_byte v[8];
|
||||
int j;
|
||||
sptr -= pixel_bytes;
|
||||
png_memcpy(v, sptr, pixel_bytes);
|
||||
sptr -= 4;
|
||||
png_memcpy(v, sptr, 4);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
{
|
||||
dp -= pixel_bytes;
|
||||
png_memcpy(dp, v, pixel_bytes);
|
||||
dp -= 4;
|
||||
png_memcpy(dp, v, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1742,13 +1746,13 @@ loop4_pass4:
|
||||
{
|
||||
png_byte v[8];
|
||||
int j;
|
||||
png_memcpy(v, sptr, pixel_bytes);
|
||||
png_memcpy(v, sptr, 6);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
{
|
||||
png_memcpy(dp, v, pixel_bytes);
|
||||
dp -= pixel_bytes;
|
||||
png_memcpy(dp, v, 6);
|
||||
dp -= 6;
|
||||
}
|
||||
sptr -= pixel_bytes;
|
||||
sptr -= 6;
|
||||
}
|
||||
} /* end of pixel_bytes == 6 */
|
||||
|
||||
|
2
pngwio.c
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
18
pngwrite.c
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@ -630,8 +630,22 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
|
||||
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_WRITE_tEXt_SUPPORTED
|
||||
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
png_debug(1, "in png_info_destroy\n");
|
||||
if (info_ptr->text != NULL)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < info_ptr->num_text; i++)
|
||||
{
|
||||
if(info_ptr->text[i].key != NULL)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->text[i].key);
|
||||
info_ptr->text[i].key = NULL;
|
||||
}
|
||||
}
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
info_ptr->text = NULL;
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->pcal_purpose);
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* libpng 1.0.5 - October 15, 1999
|
||||
* libpng 1.0.5a - October 23, 1999
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@ -688,6 +688,8 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
|
||||
if (key_len == 0)
|
||||
{
|
||||
png_free(png_ptr, *new_key);
|
||||
*new_key=NULL;
|
||||
png_chunk_warning(png_ptr, "zero length keyword");
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ RANLIB=ranlib
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0.5
|
||||
PNGMIN = 1.0.5a
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.h
|
||||
|
@ -14,7 +14,7 @@ ZLIBINC=../zlib
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0.5
|
||||
PNGMIN = 1.0.5a
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
CC=cc
|
||||
|
@ -22,7 +22,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
||||
|
||||
# for pgcc version 2.95.1, -O3 is buggy; don't us it.
|
||||
# for pgcc version 2.95.1, -O3 is buggy; don't use it.
|
||||
|
||||
CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \
|
||||
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
|
||||
@ -34,7 +34,7 @@ RANLIB=ranlib
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0.5
|
||||
PNGMIN = 1.0.5a
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
|
@ -25,7 +25,7 @@ RANLIB=echo
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0.5
|
||||
PNGMIN = 1.0.5a
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
|
@ -36,7 +36,7 @@ RANLIB=echo
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.0.5
|
||||
PNGMIN = 1.0.5a
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
|
@ -3,7 +3,7 @@ unit pngdef;
|
||||
interface
|
||||
|
||||
const
|
||||
PNG_LIBPNG_VER_STRING = '1.0.5';
|
||||
PNG_LIBPNG_VER_STRING = '1.0.5a';
|
||||
PNG_LIBPNG_VER = 10005;
|
||||
|
||||
type
|
||||
|