Imported from libpng-0.99.tar
This commit is contained in:
parent
c4a2ae6cac
commit
46f61e2398
13
CHANGES
13
CHANGES
@ -200,3 +200,16 @@ version 0.98 [January, 1998]
|
||||
PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED
|
||||
added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent)
|
||||
changed srgb_intent from png_byte to int to avoid compiler bugs
|
||||
version 0.99 [January, 1998]
|
||||
free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler)
|
||||
fixed a longstanding "packswap" bug in pngtrans.c
|
||||
fixed some inconsistencies in pngconf.h that prevented compiling with
|
||||
PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined
|
||||
fixed some typos and made other minor rearrangement of libpng.txt (Andreas)
|
||||
changed recommendation about file_gamma for PC images to .50 from .51 in
|
||||
example.c and libpng.txt, and changed file_gamma for sRGB images to .45
|
||||
added a number of functions to access information from the png structure
|
||||
png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit)
|
||||
added TARGET_MACOS similar to zlib-1.0.8
|
||||
define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined
|
||||
added type casting to all png_malloc() function calls
|
||||
|
6
README
6
README
@ -1,4 +1,4 @@
|
||||
[NOTE: this is still beta version 0.97d; the text below has already
|
||||
[NOTE: this is still beta version 0.99; the text below has already
|
||||
been updated in anticipation of the imminent 1.0 release.]
|
||||
|
||||
|
||||
@ -99,11 +99,11 @@ fix. Please mention "libpng" somewhere in the subject line. Thanks.
|
||||
This release was created and will be supported by myself (of course
|
||||
based in a large way on Guy's and Andreas' earlier work), and the PNG group.
|
||||
|
||||
adilger@enel.ucalgary.ca
|
||||
randeg@alumni.rpi.edu
|
||||
png-implement@dworkin.wustl.edu
|
||||
|
||||
You can't reach Guy, the original libpng author, at the addresses
|
||||
given in previous versions of this document. He will read mail
|
||||
given in previous versions of this document. He and Andreas will read mail
|
||||
addressed to the png-implement list, however.
|
||||
|
||||
Please do not send general questions about PNG. Send them to
|
||||
|
2
TODO
2
TODO
@ -5,7 +5,7 @@ improved dithering
|
||||
multi-lingual error and warning message support
|
||||
sPLT chunk handling
|
||||
cHRM transformation
|
||||
complete sRGB transformation (presently it simply uses gamma=0.51)
|
||||
complete sRGB transformation (presently it simply uses gamma=0.45)
|
||||
man pages for function calls
|
||||
high-level API for reading images
|
||||
final bug fixes
|
||||
|
10
example.c
10
example.c
@ -204,7 +204,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
/* If we don't have another value */
|
||||
else
|
||||
{
|
||||
screen_gamma = 2.2; /* A good guess for a PC monitors in a brightly
|
||||
screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly
|
||||
lit room */
|
||||
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
|
||||
}
|
||||
@ -223,7 +223,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)
|
||||
png_set_gamma(png_ptr, screen_gamma, image_gamma);
|
||||
else
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.51);
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.50);
|
||||
|
||||
/* Dither RGB files down to 8 bit palette or reduce palettes
|
||||
* to the number of colors available on your screen.
|
||||
@ -255,7 +255,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
}
|
||||
|
||||
/* invert monocrome files to have 0 as white and 1 as black */
|
||||
png_set_invert(png_ptr);
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
/* If you want to shift the pixel values from the range [0,255] or
|
||||
* [0,65535] to the original [0,7] or [0,31], or whatever range the
|
||||
@ -549,7 +549,7 @@ void write_png(char *file_name, ... other image information ...)
|
||||
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
/* set the palette if there is one. REQUIRED for indexed-color images */
|
||||
palette = png_malloc(png_ptr, 256 * sizeof (png_color));
|
||||
palette = (png_colorp)png_malloc(png_ptr, 256 * sizeof (png_color));
|
||||
... set palette colors ...
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, 256);
|
||||
|
||||
@ -600,7 +600,7 @@ void write_png(char *file_name, ... other image information ...)
|
||||
*/
|
||||
|
||||
/* invert monocrome pixels */
|
||||
png_set_invert(png_ptr);
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
/* Shift the pixels up to a legal bit depth and fill in
|
||||
* as appropriate to correctly scale the image.
|
||||
|
122
libpng.txt
122
libpng.txt
@ -1,14 +1,14 @@
|
||||
libpng.txt - a description on how to use and modify libpng
|
||||
|
||||
libpng version 0.98
|
||||
libpng version 0.99
|
||||
Updated and distributed by Glenn Randers-Pehrson <randeg@alumni.rpi.edu>
|
||||
Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
January 16, 1998
|
||||
January 30, 1998
|
||||
|
||||
based on:
|
||||
|
||||
libpng 1.0 beta 6 version 0.96
|
||||
Updated and distributed by Andreas Dilger <adilger@enel.ucalgary.ca>,
|
||||
Updated and distributed by Andreas Dilger
|
||||
Copyright (c) 1996, 1997 Andreas Dilger
|
||||
May 28, 1997
|
||||
|
||||
@ -239,9 +239,11 @@ Functions are used to get the information from the info_ptr:
|
||||
PNG_COLOR_MASK_COLOR
|
||||
PNG_COLOR_MASK_ALPHA
|
||||
|
||||
interlace_type - PNG_INTERLACE_TYPE_NONE or PNG_INTERLACE_TYPE_ADAM7
|
||||
compression_type - (must be PNG_COMPRESSION_TYPE_BASE for PNG 1.0)
|
||||
filter_type - (must be PNG_FILTER_TYPE_BASE for PNG 1.0)
|
||||
compression_type - (must be PNG_COMPRESSION_TYPE_BASE for PNG 1.0)
|
||||
interlace_type - (PNG_INTERLACE_TYPE_NONE or PNG_INTERLACE_TYPE_ADAM7)
|
||||
Any or all of interlace_type, compression_type, of filter_type can be
|
||||
NULL if you are not interested in their values.
|
||||
|
||||
channels = png_get_channels(png_ptr, info_ptr);
|
||||
channels - number of channels of info for the color type
|
||||
@ -257,6 +259,17 @@ Functions are used to get the information from the info_ptr:
|
||||
already read in 4 bytes of signature before staring
|
||||
libpng, the remaining 4 bytes would be in signature[4]
|
||||
through signature[7] (see png_set_sig_bytes())).
|
||||
|
||||
Information from each if the IHDR fields can be retrieve separately as well:
|
||||
|
||||
width = png_get_image_width(png_ptr, info_ptr);
|
||||
height = png_get_image_height(png_ptr, info_ptr);
|
||||
bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||
color_type = png_get_color_type(png_ptr, info_ptr);
|
||||
filter_type = png_get_filter_type(png_ptr, info_ptr);
|
||||
compression_type = png_get_compression_type(png_ptr, info_ptr);
|
||||
interlace_type = png_get_interlace_type(png_ptr, info_ptr);
|
||||
|
||||
|
||||
These are also important, but their validity depends on whether the chunk
|
||||
has been read. The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and
|
||||
@ -316,6 +329,15 @@ into the info_ptr is returned for any complex types.
|
||||
res_y - pixels/unit physical resolution in x direction
|
||||
unit_type - PNG_RESOLUTION_UNKOWN, PNG_RESOLUTION_METER
|
||||
|
||||
The data from the pHYs chunk can be retrieved in several convenient
|
||||
forms:
|
||||
|
||||
res_x_and_y = png_get_pixels_per_meter(png_ptr, info_ptr)
|
||||
aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, info_ptr)
|
||||
|
||||
(Each of these returns 0 [signifying "unknown"] if the data is not
|
||||
present or if res_x is 0; res_x_and_y is 0 if res_x != res_y)
|
||||
|
||||
For more information, see the png_info definition in png.h and the
|
||||
PNG specification for chunk contents. Be careful with trusting
|
||||
rowbytes, as some of the transformations could increase the space
|
||||
@ -392,8 +414,21 @@ PNG can have files with 16 bits per channel. If you only can handle
|
||||
if (bit_depth == 16)
|
||||
png_set_strip_16(png_ptr);
|
||||
|
||||
The png_set_background() function tells libpng to composite images
|
||||
with alpha or simple transparency against the supplied background
|
||||
color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
|
||||
you may use this color, or supply another color more suitable for
|
||||
the current display (e.g., the background color from a web page). You
|
||||
need to tell libpng whether the color is in the gamma space of the
|
||||
display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
|
||||
(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
|
||||
that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
|
||||
know why anyone would use this, but it's here).
|
||||
|
||||
If, for some reason, you don't need the alpha channel on an image,
|
||||
and you want to remove it rather than combining it with the background:
|
||||
and you want to remove it rather than combining it with the background
|
||||
(but the image author certainly had in mind that you *would* combine
|
||||
it with the background, so that's what you should probably do):
|
||||
|
||||
if (color_type & PNG_COLOR_MASK_ALPHA)
|
||||
png_set_strip_alpha(png_ptr);
|
||||
@ -449,17 +484,6 @@ RGB. This code will do that conversion:
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
|
||||
The png_set_background() function tells libpng to composite images
|
||||
with alpha or simple transparency against the supplied background
|
||||
color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
|
||||
you may use this color, or supply another color more suitable for
|
||||
the current display (e.g., the background color from a web page). You
|
||||
need to tell libpng whether the color is in the gamma space of the
|
||||
display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
|
||||
(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
|
||||
that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
|
||||
know why anyone would use this, but it's here).
|
||||
|
||||
If you have a grayscale and you are using png_set_expand() to change to
|
||||
a higher bit-depth you must indicate if the supplied background gray
|
||||
is supplied in the original file bit depth (need_expand = 1) or in the
|
||||
@ -507,15 +531,16 @@ is needed (viewing_gamma=1.0).
|
||||
/* If we don't have another value */
|
||||
else
|
||||
{
|
||||
screen_gamma = 2.2; /* A good guess for a PC monitor in a bright office */
|
||||
screen_gamma = 1.956; /* A good guess for a PC monitor in a dim room */
|
||||
screen_gamma = 2.5; /* A good guess for a PC monitor in a bright office */
|
||||
screen_gamma = 2.2; /* A good guess for a PC monitor in a dim room */
|
||||
screen_gamma = 2.0; /* A good guess for a PC monitor in a dark room */
|
||||
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
|
||||
}
|
||||
|
||||
The png_set_gamma() function handles gamma transformations of the data.
|
||||
Pass both the file gamma and the current screen_gamma. If the file does
|
||||
not have a gamma value, you can pass one anyway if you have an idea what
|
||||
it is (usually 0.51 is a good guess for GIF images on PCs). Note
|
||||
it is (usually 0.50 is a good guess for GIF images on PCs). Note
|
||||
that file gammas are inverted from screen gammas. See the discussions
|
||||
on gamma in the PNG specification for an excellent description of what
|
||||
gamma is, and why all applications should support it. It is strongly
|
||||
@ -524,7 +549,7 @@ recommended that PNG viewers support gamma correction.
|
||||
if (png_get_gAMA(png_ptr, info_ptr, &gamma))
|
||||
png_set_gamma(png_ptr, screen_gamma, gamma);
|
||||
else
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.51);
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.50);
|
||||
|
||||
If you need to reduce an RGB file to a paletted file, or if a paletted
|
||||
file has more entries then will fit on your screen, png_set_dither()
|
||||
@ -579,7 +604,8 @@ need to change the order the pixels are packed into bytes, you can use:
|
||||
png_set_packswap(png_ptr);
|
||||
|
||||
The last thing to handle is interlacing; this is covered in detail below,
|
||||
but you must call the function here.
|
||||
but you must call the function here if you want libpng to handle expansion
|
||||
of the interlaced image.
|
||||
|
||||
number_of_passes = png_set_interlace_handling(png_ptr);
|
||||
|
||||
@ -587,7 +613,7 @@ After setting the transformations, libpng can update your png_info
|
||||
structure to reflect any transformations you've requested with this
|
||||
call. This is most useful to update the info structure's rowbytes
|
||||
field so you can use it to allocate your image memory. This function
|
||||
will also update your palette with the correct display gamma and
|
||||
will also update your palette with the correct screen_gamma and
|
||||
background if these have been given with the calls above.
|
||||
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
@ -970,7 +996,7 @@ contain, see the PNG specification.
|
||||
Some of the more important parts of the png_info are:
|
||||
|
||||
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type,
|
||||
interlace_type,
|
||||
interlace_type, compression_type, filter_type)
|
||||
width - holds the width of the image in pixels (up to 2^31).
|
||||
height - holds the height of the image in pixels (up to 2^31).
|
||||
bit_depth - holds the bit depth of one of the image channels.
|
||||
@ -987,11 +1013,9 @@ Some of the more important parts of the png_info are:
|
||||
PNG_COLOR_MASK_COLOR
|
||||
PNG_COLOR_MASK_ALPHA
|
||||
|
||||
interlace_type - PNG_INTERLACE_TYPE_NONE or PNG_INTER_LACE_TYPE_ADAM7
|
||||
interlace_type - PNG_INTERLACE_TYPE_NONE or PNG_INTERLACE_TYPE_ADAM7
|
||||
compression_type - (must be PNG_COMPRESSION_TYPE_DEFAULT for PNG 1.0)
|
||||
filter_type - (must be PNG_FILTER_TYPE_DEFAULT for PNG 1.0)
|
||||
Any or all of interlace_type, compression_type, of filter_type can be
|
||||
NULL if you are not interested in their values.
|
||||
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, num_palette);
|
||||
palette - the palette for the file (array of png_color)
|
||||
@ -1005,6 +1029,12 @@ Some of the more important parts of the png_info are:
|
||||
The presence of the sRGB chunk means that the pixel
|
||||
data is in the sRGB color space. This chunk also
|
||||
implies specific values of gAMA and cHRM.
|
||||
Rendering intent is the CSS-1 property that has been
|
||||
defined by the International Color Consortium
|
||||
(http://www.color.org). It can be one of
|
||||
PNG_SRGB_INTENT_SATURATION, PNG_SRGB_INTENT_PERCEPTUAL,
|
||||
PNG_SRGB_INTENT_ABSOLUTE, or PNG_SRGB_INTENT_RELATIVE.
|
||||
|
||||
|
||||
png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, srgb_intent);
|
||||
srgb_intent - the rendering intent (PNG_INFO_sRGB)
|
||||
@ -1222,7 +1252,7 @@ PNG files describe monochrome as black being zero and white being
|
||||
one. This code would be used if the pixels are supplied with this reversed
|
||||
(black being one and white being zero):
|
||||
|
||||
png_set_invert(png_ptr);
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
It is possible to have libpng flush any pending output, either manually,
|
||||
or automatically after a certain number of lines have been written. To
|
||||
@ -1308,8 +1338,8 @@ and only update the rows that are actually used.
|
||||
|
||||
After you are finished writing the image, you should finish writing
|
||||
the file. If you are interested in writing comments or time, you should
|
||||
pass the an appropriately filled png_info pointer. If you
|
||||
are not interested, you can pass NULL.
|
||||
pass an appropriately filled png_info pointer. If you are not interested,
|
||||
you can pass NULL.
|
||||
|
||||
png_write_end(png_ptr, info_ptr);
|
||||
|
||||
@ -1501,14 +1531,19 @@ Controlling row filtering:
|
||||
|
||||
If you want to control whether libpng uses filtering or not, which
|
||||
filters are used, and how it goes about picking row filters, you
|
||||
can call one of these functions. Filtering is enabled by default for
|
||||
RGB and grayscale images (with and without alpha), and for 8-bit
|
||||
paletted images, but not for paletted images with bit depths less
|
||||
than 8 bits/pixel. The 'method' parameter sets the main filtering
|
||||
method, which is currently only '0' in the PNG 1.0 specification.
|
||||
The 'filters' parameter sets which filter(s), if any, should be
|
||||
used for each scanline. Possible values are PNG_ALL_FILTERS and
|
||||
PNG_NO_FILTERS to turn filtering on and off, respectively.
|
||||
can call one of these functions. The selection and configuration
|
||||
of row filters can have a significant impact on the size and
|
||||
encoding speed and a somewhat lesser impact on the decoding speed
|
||||
of an image. Filtering is enabled by default for RGB and grayscale
|
||||
images (with and without alpha), and for 8-bit paletted images, but
|
||||
not for paletted images with bit depths less than 8 bits/pixel.
|
||||
|
||||
The 'method' parameter sets the main filtering method, which is
|
||||
currently only '0' in the PNG 1.0 specification. The 'filters'
|
||||
parameter sets which filter(s), if any, should be used for each
|
||||
scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
|
||||
to turn filtering on and off, respectively.
|
||||
|
||||
Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
|
||||
PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
|
||||
ORed together '|' to specify one or more filters to use. These
|
||||
@ -1560,10 +1595,15 @@ There are a bunch of #define's in pngconf.h that control what parts of
|
||||
libpng are compiled. All the defines end in _SUPPORTED. If you are
|
||||
never going to use an ability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space.
|
||||
You can also turn them off en masse with a compiler directive to
|
||||
define PNG_READ_NOT_FULLY_SUPPORTED or PNG_WRITE_NOT_FULLY_SUPPORTED,
|
||||
You can also turn them off en masse with a compiler directive that
|
||||
defines PNG_READ[or WRITE]_NOT_FULLY_SUPPORTED, or
|
||||
PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four,
|
||||
along with directives to turn on any of the capabilities that you do
|
||||
want.
|
||||
want. The NOT_FULLY_SUPPORTED directives disable the extra
|
||||
transformations but still leave the library fully capable of reading
|
||||
and writing PNG files with all known public chunks [except for sPLT].
|
||||
Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive
|
||||
produces a library that is incapable of reading or writing ancillary chunks.
|
||||
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
linker should only grab the files it needs. However, if you want to
|
||||
|
@ -22,7 +22,7 @@ RANLIB=ranlib
|
||||
#RANLIB=echo
|
||||
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 0.98
|
||||
PNGMIN = 0.99
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.h
|
||||
|
80
makefile.min
Normal file
80
makefile.min
Normal file
@ -0,0 +1,80 @@
|
||||
# makefile for libpng
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
# For conditions of distribution and use, see copyright notice in png.h
|
||||
|
||||
# Where the zlib library and include files are located
|
||||
#ZLIBLIB=/usr/local/lib
|
||||
#ZLIBINC=/usr/local/include
|
||||
ZLIBLIB=../zlib
|
||||
ZLIBINC=../zlib
|
||||
|
||||
CC=cc
|
||||
|
||||
# CFLAGS=-I$(ZLIBINC) -O -fullwarn \
|
||||
# -DPNG_NO_EASY_ACCESS
|
||||
|
||||
CFLAGS=-I$(ZLIBINC) -O -fullwarn \
|
||||
-DPNG_READ_NOT_FULLY_SUPPORTED -DPNG_WRITE_NOT_FULLY_SUPPORTED
|
||||
|
||||
#CFLAGS=-I$(ZLIBINC) -O -fullwarn -DPNGTEST_MEMORY_DEBUG \
|
||||
# -DPNG_READ_NOT_FULLY_SUPPORTED -DPNG_WRITE_NOT_FULLY_SUPPORTED \
|
||||
# -DPNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED \
|
||||
# -DPNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED \
|
||||
# -DPNG_NO_STDIO
|
||||
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||
|
||||
RANLIB=echo
|
||||
#RANLIB=ranlib
|
||||
|
||||
# where make install puts libpng.a and png.h
|
||||
prefix=/usr/local
|
||||
|
||||
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
||||
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||
pngwtran.o pngmem.o pngerror.o pngpread.o
|
||||
|
||||
all: libpng.a pngtest
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
ar rc $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
pngtest: pngtest.o libpng.a
|
||||
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
|
||||
|
||||
test: pngtest
|
||||
./pngtest
|
||||
|
||||
install: libpng.a
|
||||
-@mkdir $(prefix)/include
|
||||
-@mkdir $(prefix)/lib
|
||||
cp png.h $(prefix)/include
|
||||
cp pngconf.h $(prefix)/include
|
||||
chmod 644 $(prefix)/include/png.h
|
||||
chmod 644 $(prefix)/include/pngconf.h
|
||||
cp libpng.a $(prefix)/lib
|
||||
chmod 644 $(prefix)/lib/libpng.a
|
||||
|
||||
clean:
|
||||
rm -f *.o libpng.a pngtest pngout.png
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o: png.h pngconf.h
|
||||
pngerror.o: png.h pngconf.h
|
||||
pngrio.o: png.h pngconf.h
|
||||
pngwio.o: png.h pngconf.h
|
||||
pngmem.o: png.h pngconf.h
|
||||
pngset.o: png.h pngconf.h
|
||||
pngget.o: png.h pngconf.h
|
||||
pngread.o: png.h pngconf.h
|
||||
pngrtran.o: png.h pngconf.h
|
||||
pngrutil.o: png.h pngconf.h
|
||||
pngtest.o: png.h pngconf.h
|
||||
pngtrans.o: png.h pngconf.h
|
||||
pngwrite.o: png.h pngconf.h
|
||||
pngwtran.o: png.h pngconf.h
|
||||
pngwutil.o: png.h pngconf.h
|
||||
pngpread.o: png.h pngconf.h
|
||||
|
10
png.c
10
png.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -16,9 +16,9 @@
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h.
|
||||
*/
|
||||
char png_libpng_ver[] = "0.98";
|
||||
char png_libpng_ver[5] = "0.99";
|
||||
|
||||
/* Place to hold the signiture string for a PNG file. */
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
||||
/* Constant strings for known chunk types. If you need to add a chunk,
|
||||
@ -132,7 +132,7 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
png_uint_32 num_bytes;
|
||||
|
||||
num_bytes = (png_uint_32)items * size;
|
||||
ptr = png_malloc((png_structp)png_ptr, num_bytes);
|
||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
|
||||
if (num_bytes > (png_uint_32)0x8000)
|
||||
{
|
||||
png_memset(ptr, 0, (png_size_t)0x8000L);
|
||||
|
152
png.h
152
png.h
@ -1,12 +1,12 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng 0.98 beta
|
||||
* libpng 0.99 beta
|
||||
* 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
|
||||
* Copyright (c) 1998 Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
*
|
||||
@ -119,30 +119,30 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "0.98"
|
||||
#define PNG_LIBPNG_VER_STRING "0.99"
|
||||
|
||||
/* careful here. At one time, I wanted to use 082, but that would be octal.
|
||||
* Version 1.0 will be 100 here, etc.
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 98
|
||||
#define PNG_LIBPNG_VER 99
|
||||
|
||||
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
|
||||
#ifndef PNG_NO_EXTERN
|
||||
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
|
||||
/* Version information for C files, stored in png.c. This had better match
|
||||
* the version above.
|
||||
*/
|
||||
extern char png_libpng_ver[];
|
||||
extern char png_libpng_ver[5];
|
||||
|
||||
/* Structures to facilitate easy interlacing. See png.c for more details */
|
||||
extern int FARDATA png_pass_start[];
|
||||
extern int FARDATA png_pass_inc[];
|
||||
extern int FARDATA png_pass_ystart[];
|
||||
extern int FARDATA png_pass_yinc[];
|
||||
extern int FARDATA png_pass_mask[];
|
||||
extern int FARDATA png_pass_dsp_mask[];
|
||||
extern int FARDATA png_pass_start[7];
|
||||
extern int FARDATA png_pass_inc[7];
|
||||
extern int FARDATA png_pass_ystart[7];
|
||||
extern int FARDATA png_pass_yinc[7];
|
||||
extern int FARDATA png_pass_mask[7];
|
||||
extern int FARDATA png_pass_dsp_mask[7];
|
||||
/* These aren't currently used. If you need them, see png.c for more details
|
||||
extern int FARDATA png_pass_width[];
|
||||
extern int FARDATA png_pass_height[];
|
||||
extern int FARDATA png_pass_width[7];
|
||||
extern int FARDATA png_pass_height[7];
|
||||
*/
|
||||
#endif /* PNG_NO_EXTERN */
|
||||
|
||||
@ -268,7 +268,8 @@ typedef struct png_info_struct
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED) || \
|
||||
defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
/* The gAMA chunk describes the gamma characteristics of the system
|
||||
* on which the image was created, normally in the range [1.0, 2.5].
|
||||
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
|
||||
@ -323,7 +324,8 @@ typedef struct png_info_struct
|
||||
png_bytep trans; /* transparent values for paletted image */
|
||||
png_color_16 trans_values; /* transparent color for non-palette image */
|
||||
#endif /* PNG_READ_tRNS_SUPPORTED || PNG_WRITE_tRNS_SUPPORTED */
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED) || \
|
||||
defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* The bKGD chunk gives the suggested image background color if the
|
||||
* display program does not have its own background color and the image
|
||||
* is needs to composited onto a background before display. The colors
|
||||
@ -444,6 +446,15 @@ typedef png_info FAR * FAR * png_infopp;
|
||||
#define PNG_RESOLUTION_METER 1 /* pixels/meter */
|
||||
#define PNG_RESOLUTION_LAST 2 /* Not a valid value */
|
||||
|
||||
/* These are for the sRGB chunk. These values should NOT be changed. */
|
||||
#define PNG_sRGB_INTENT_SATURATION 0
|
||||
#define PNG_sRGB_INTENT_PERCEPTUAL 1
|
||||
#define PNG_sRGB_INTENT_ABSOLUTE 2
|
||||
#define PNG_sRGB_INTENT_RELATIVE 3
|
||||
#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */
|
||||
|
||||
|
||||
|
||||
/* These determine if an ancillary chunk's data has been successfully read
|
||||
* from the PNG header, or if the application has filled in the corresponding
|
||||
* data in the info_struct to be written into the output file. The values
|
||||
@ -636,8 +647,10 @@ struct png_struct_def
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
png_bytep palette_lookup; /* lookup table for dithering */
|
||||
png_bytep dither_index; /* index translation for palette files */
|
||||
png_uint_16p hist; /* histogram */
|
||||
#endif /* PNG_READ_DITHER_SUPPORTED */
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_READ_hIST_SUPPORTED)
|
||||
png_uint_16p hist; /* histogram */
|
||||
#endif
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
||||
@ -1091,6 +1104,13 @@ extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
|
||||
/* frees a pointer allocated by png_malloc() */
|
||||
extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
|
||||
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
/* debugging versions of png_malloc() and png_free() */
|
||||
extern PNG_EXPORT(png_voidp,png_debug_malloc) PNGARG((png_structp png_ptr,
|
||||
png_uint_32 size));
|
||||
extern PNG_EXPORT(void,png_debug_free) PNGARG((png_structp png_ptr,
|
||||
png_voidp ptr));
|
||||
#endif
|
||||
#if defined(USE_FAR_KEYWORD) /* memory model conversion function */
|
||||
extern void *far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,int check));
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
@ -1123,18 +1143,67 @@ extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
|
||||
* to avoid problems with future changes in the size and internal layout of
|
||||
* png_info_struct.
|
||||
*/
|
||||
/* Returns "flag" if chunk data is valid in info_ptr */
|
||||
/* Returns "flag" if chunk data is valid in info_ptr. */
|
||||
extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_uint_32 flag));
|
||||
|
||||
/* Returns number of bytes needed to hold a transformed row */
|
||||
/* Returns number of bytes needed to hold a transformed row. */
|
||||
extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr));
|
||||
|
||||
/* Returns number of color channels in image */
|
||||
/* Returns number of color channels in image. */
|
||||
extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr));
|
||||
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
/* Returns image width in pixels. */
|
||||
extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image height in pixels. */
|
||||
extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image bit_depth. */
|
||||
extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image color_type. */
|
||||
extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image filter_type. */
|
||||
extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image interlace_type. */
|
||||
extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image compression_type. */
|
||||
extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image resolution in pixels per meter, from pHYs chunk data. */
|
||||
extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns pixel aspect ratio, computed from pHYs chunk data. */
|
||||
extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
|
||||
extern PNG_EXPORT(png_uint_32, png_get_x_offset_pixels) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
extern PNG_EXPORT(png_uint_32, png_get_y_offset_pixels) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
extern PNG_EXPORT(png_uint_32, png_get_x_offset_microns) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
extern PNG_EXPORT(png_uint_32, png_get_y_offset_microns) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
/* Returns pointer to signature string read from PNG header */
|
||||
extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr));
|
||||
@ -1294,6 +1363,9 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
* libpng yet, but more support will be added as needed.
|
||||
*/
|
||||
#if (PNG_DEBUG > 0)
|
||||
#ifdef PNG_NO_STDIO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#ifndef PNG_DEBUG_FILE
|
||||
#define PNG_DEBUG_FILE stderr
|
||||
#endif /* PNG_DEBUG_FILE */
|
||||
@ -1411,31 +1483,31 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
|
||||
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
|
||||
#ifndef PNG_NO_EXTERN
|
||||
/* place to hold the signiture string for a PNG file. */
|
||||
extern png_byte FARDATA png_sig[];
|
||||
/* place to hold the signature string for a PNG file. */
|
||||
extern png_byte FARDATA png_sig[8];
|
||||
|
||||
/* Constant strings for known chunk types. If you need to add a chunk,
|
||||
* add a string holding the name here. See png.c for more details. We
|
||||
* can't selectively include these, since we still check for chunk in the
|
||||
* wrong locations with these labels.
|
||||
*/
|
||||
extern png_byte FARDATA png_IHDR[];
|
||||
extern png_byte FARDATA png_IDAT[];
|
||||
extern png_byte FARDATA png_IEND[];
|
||||
extern png_byte FARDATA png_PLTE[];
|
||||
extern png_byte FARDATA png_bKGD[];
|
||||
extern png_byte FARDATA png_cHRM[];
|
||||
extern png_byte FARDATA png_gAMA[];
|
||||
extern png_byte FARDATA png_hIST[];
|
||||
extern png_byte FARDATA png_oFFs[];
|
||||
extern png_byte FARDATA png_pCAL[];
|
||||
extern png_byte FARDATA png_pHYs[];
|
||||
extern png_byte FARDATA png_sBIT[];
|
||||
extern png_byte FARDATA png_sRGB[];
|
||||
extern png_byte FARDATA png_tEXt[];
|
||||
extern png_byte FARDATA png_tIME[];
|
||||
extern png_byte FARDATA png_tRNS[];
|
||||
extern png_byte FARDATA png_zTXt[];
|
||||
extern png_byte FARDATA png_IHDR[5];
|
||||
extern png_byte FARDATA png_IDAT[5];
|
||||
extern png_byte FARDATA png_IEND[5];
|
||||
extern png_byte FARDATA png_PLTE[5];
|
||||
extern png_byte FARDATA png_bKGD[5];
|
||||
extern png_byte FARDATA png_cHRM[5];
|
||||
extern png_byte FARDATA png_gAMA[5];
|
||||
extern png_byte FARDATA png_hIST[5];
|
||||
extern png_byte FARDATA png_oFFs[5];
|
||||
extern png_byte FARDATA png_pCAL[5];
|
||||
extern png_byte FARDATA png_pHYs[5];
|
||||
extern png_byte FARDATA png_sBIT[5];
|
||||
extern png_byte FARDATA png_sRGB[5];
|
||||
extern png_byte FARDATA png_tEXt[5];
|
||||
extern png_byte FARDATA png_tIME[5];
|
||||
extern png_byte FARDATA png_tRNS[5];
|
||||
extern png_byte FARDATA png_zTXt[5];
|
||||
|
||||
#endif /* PNG_NO_EXTERN */
|
||||
|
||||
@ -1550,7 +1622,7 @@ PNG_EXTERN void png_write_chunk_data PNGARG((png_structp png_ptr,
|
||||
/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
|
||||
PNG_EXTERN void png_write_chunk_end PNGARG((png_structp png_ptr));
|
||||
|
||||
/* simple function to write the signiture */
|
||||
/* simple function to write the signature */
|
||||
PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
|
||||
|
||||
/* write various chunks */
|
||||
|
73
pngconf.h
73
pngconf.h
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngconf.c - machine configurable file for libpng
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
@ -27,7 +27,7 @@
|
||||
* where it becomes significant, if you are concerned with memory
|
||||
* usage. Note that zlib allocates at least 32Kb also. For readers,
|
||||
* this describes the size of the buffer available to read the data in.
|
||||
* Unless this gets smaller then the size of a row (compressed),
|
||||
* Unless this gets smaller than the size of a row (compressed),
|
||||
* it should not make much difference how big this is.
|
||||
*/
|
||||
|
||||
@ -55,8 +55,6 @@
|
||||
* #define PNG_NO_STDIO
|
||||
*/
|
||||
|
||||
/* We still need stdio.h for FILE even when PNG_NO_STDIO is defined.
|
||||
*/
|
||||
#ifndef PNG_NO_STDIO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
@ -88,10 +86,12 @@
|
||||
* just __MWERKS__ is not good enough, because the Codewarrior is now used
|
||||
* on non-Mac platforms.
|
||||
*/
|
||||
#ifndef MACOS
|
||||
#if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
|
||||
defined(THINK_C) || defined(__SC__)
|
||||
defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
|
||||
#define MACOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* enough people need this for various reasons to include it here */
|
||||
#if !defined(MACOS) && !defined(RISCOS)
|
||||
@ -157,6 +157,11 @@ __dont__ include it again
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
/* Codewarrior on NT has linking problems without this. */
|
||||
#if defined(__MWERKS__) && defined(WIN32)
|
||||
#define PNG_ALWAYS_EXTERN
|
||||
#endif
|
||||
|
||||
/* For some reason, Borland C++ defines memcmp, etc. in mem.h, not
|
||||
* stdlib.h like it should (I think). Or perhaps this is a C++
|
||||
* "feature"?
|
||||
@ -234,7 +239,8 @@ __dont__ include it again
|
||||
/* GR-P, 0.96a: Set "*FULLY_SUPPORTED as default but allow user
|
||||
to turn it off with "*NOT_FULLY_SUPPORTED" on the compile line,
|
||||
then pick and choose which ones to define without having to edit
|
||||
this file */
|
||||
this file.
|
||||
*/
|
||||
|
||||
#ifndef PNG_READ_NOT_FULLY_SUPPORTED
|
||||
#define PNG_READ_FULLY_SUPPORTED
|
||||
@ -245,7 +251,6 @@ __dont__ include it again
|
||||
|
||||
#ifdef PNG_READ_FULLY_SUPPORTED
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#define PNG_READ_OPT_PLTE_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_SHIFT_SUPPORTED
|
||||
#define PNG_READ_PACK_SUPPORTED
|
||||
@ -264,10 +269,10 @@ __dont__ include it again
|
||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel */
|
||||
#endif /* PNG_READ_FULLY_SUPPORTED */
|
||||
#define PNG_READ_INTERLACING_SUPPORTED
|
||||
|
||||
#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
|
||||
|
||||
#ifdef PNG_WRITE_FULLY_SUPPORTED
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED
|
||||
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||
#define PNG_WRITE_PACK_SUPPORTED
|
||||
#define PNG_WRITE_BGR_SUPPORTED
|
||||
@ -281,10 +286,34 @@ __dont__ include it again
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#endif /* PNG_WRITE_FULLY_SUPPORTED */
|
||||
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant */
|
||||
/* encoders, but can cause trouble
|
||||
if left undefined */
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
#define PNG_TIME_RFC1123_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* This adds extra functions in pngget.c for accessing data from the
|
||||
* info pointer (added in version 0.99)
|
||||
* png_get_image_width()
|
||||
* png_get_image_height()
|
||||
* png_get_bit_depth()
|
||||
* png_get_color_type()
|
||||
* png_get_compression_type()
|
||||
* png_get_filter_type()
|
||||
* png_get_interlace_type()
|
||||
* png_get_pixel_aspect_ratio()
|
||||
* png_get_pixels_per_meter()
|
||||
* png_get_x_offset_pixels()
|
||||
* png_get_y_offset_pixels()
|
||||
* png_get_x_offset_microns()
|
||||
* png_get_y_offset_microns()
|
||||
*/
|
||||
#if !defined(PNG_NO_EASY_ACCESS)
|
||||
#define PNG_EASY_ACCESS_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* These are currently experimental features, define them if you want */
|
||||
|
||||
/* very little testing */
|
||||
@ -307,11 +336,17 @@ __dont__ include it again
|
||||
/* Any chunks you are not interested in, you can undef here. The
|
||||
* ones that allocate memory may be expecially important (hIST,
|
||||
* tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
|
||||
* a bit smaller. OPT_PLTE only disables the optional palette in RGB
|
||||
* and RGBA images.
|
||||
* a bit smaller.
|
||||
*/
|
||||
|
||||
#ifdef PNG_READ_FULLY_SUPPORTED
|
||||
#ifndef PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED
|
||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED
|
||||
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_bKGD_SUPPORTED
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#define PNG_READ_gAMA_SUPPORTED
|
||||
@ -325,9 +360,11 @@ __dont__ include it again
|
||||
#define PNG_READ_tIME_SUPPORTED
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
#endif /* PNG_READ_FULLY_SUPPORTED */
|
||||
#define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the optional */
|
||||
/* PLTE chunk in RGB and RGBA images */
|
||||
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_FULLY_SUPPORTED
|
||||
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_WRITE_bKGD_SUPPORTED
|
||||
#define PNG_WRITE_cHRM_SUPPORTED
|
||||
#define PNG_WRITE_gAMA_SUPPORTED
|
||||
@ -341,7 +378,7 @@ __dont__ include it again
|
||||
#define PNG_WRITE_tIME_SUPPORTED
|
||||
#define PNG_WRITE_tRNS_SUPPORTED
|
||||
#define PNG_WRITE_zTXt_SUPPORTED
|
||||
#endif /* PNG_WRITE_FULLY_SUPPORTED */
|
||||
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
|
||||
|
||||
/* need the time information for reading tIME chunks */
|
||||
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
@ -467,7 +504,7 @@ typedef z_stream FAR * png_zstreamp;
|
||||
|
||||
/* allow for compilation as dll with BORLAND C++ 5.0 */
|
||||
#if defined(__BORLANDC__) && defined(_Windows) && defined(__DLL__)
|
||||
# define PNG_EXPORT(t,s) t _export s
|
||||
# define PNG_EXPORT(type,symbol) type _export symbol
|
||||
#endif
|
||||
|
||||
/* allow for compilation as shared lib under BeOS */
|
||||
@ -476,7 +513,7 @@ typedef z_stream FAR * png_zstreamp;
|
||||
#endif
|
||||
|
||||
#ifndef PNG_EXPORT
|
||||
#define PNG_EXPORT(t,s) t s
|
||||
#define PNG_EXPORT(type,symbol) type symbol
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*
|
||||
* This file provides a location for all error handling. Users which
|
||||
* need special error handling are expected to write replacement functions
|
||||
|
177
pngget.c
177
pngget.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -30,6 +30,179 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
/* easy access to info, added in libpng-0.99 */
|
||||
png_uint_32
|
||||
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->width;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->height;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->bit_depth;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->color_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->filter_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->interlace_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->compression_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||
return (0);
|
||||
else return (info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
float
|
||||
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
|
||||
if (info_ptr->x_pixels_per_unit == 0)
|
||||
return NULL;
|
||||
else
|
||||
return (float)info_ptr->y_pixels_per_unit
|
||||
/(float)info_ptr->x_pixels_per_unit;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
return (0);
|
||||
else return (info_ptr->x_offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
return (0);
|
||||
else return (info_ptr->y_offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
return (0);
|
||||
else return (info_ptr->x_offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
return (0);
|
||||
else return (info_ptr->y_offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* png_get_channels really belongs in here, too, but it's been around longer */
|
||||
#endif
|
||||
|
||||
png_byte
|
||||
png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
|
30
pngmem.c
30
pngmem.c
@ -1,11 +1,11 @@
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*
|
||||
* This file provides a location for all memory allocation. Users which
|
||||
* need special memory handling are expected to modify the code in this file
|
||||
@ -58,7 +58,10 @@ void
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
farfree (struct_ptr);
|
||||
struct_ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
@ -107,8 +110,10 @@ PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
|
||||
png_byte huge * hptr;
|
||||
|
||||
if (ret != NULL)
|
||||
{
|
||||
farfree(ret);
|
||||
ret = NULL;
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
|
||||
if (num_blocks < 1)
|
||||
@ -124,7 +129,7 @@ PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
|
||||
|
||||
if (table == NULL)
|
||||
{
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */
|
||||
}
|
||||
|
||||
if ((png_size_t)table & 0xfff0)
|
||||
@ -138,7 +143,7 @@ PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
|
||||
|
||||
if (png_ptr->offset_table_ptr == NULL)
|
||||
{
|
||||
png_error(png_ptr, "Out of memory");
|
||||
png_error(png_ptr, "Out Of memory.");
|
||||
}
|
||||
|
||||
hptr = (png_byte huge *)table;
|
||||
@ -160,7 +165,7 @@ PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
|
||||
}
|
||||
|
||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
png_error(png_ptr, "Out of Memory.");
|
||||
|
||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
||||
}
|
||||
@ -169,7 +174,7 @@ PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -207,7 +212,10 @@ PNG_FREE(png_structp png_ptr, png_voidp ptr)
|
||||
}
|
||||
|
||||
if (ptr != NULL)
|
||||
{
|
||||
farfree(ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* Not the Borland DOS special memory handler */
|
||||
@ -250,15 +258,20 @@ void
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(struct_ptr);
|
||||
struct_ptr = NULL;
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(struct_ptr);
|
||||
struct_ptr = NULL;
|
||||
# else
|
||||
free(struct_ptr);
|
||||
struct_ptr = NULL;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -309,11 +322,14 @@ PNG_FREE(png_structp png_ptr, png_voidp ptr)
|
||||
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(ptr);
|
||||
ptr = NULL;
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(ptr);
|
||||
ptr = NULL;
|
||||
# else
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -992,7 +992,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
png_charp tmp;
|
||||
|
||||
tmp = text;
|
||||
text = png_malloc(png_ptr, text_size +
|
||||
text = (png_charp)png_malloc(png_ptr, text_size +
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1);
|
||||
png_memcpy(text, tmp, text_size);
|
||||
png_free(png_ptr, tmp);
|
||||
|
12
pngread.c
12
pngread.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*
|
||||
* This file contains routines that an application calls directly to
|
||||
* read a PNG file or stream.
|
||||
@ -58,7 +58,7 @@ png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_ptr->zstream.zalloc = png_zalloc;
|
||||
png_ptr->zstream.zfree = png_zfree;
|
||||
png_ptr->zstream.opaque = (voidpf)png_ptr;
|
||||
@ -100,7 +100,7 @@ png_read_init(png_structp png_ptr)
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_ptr->zstream.zalloc = png_zalloc;
|
||||
png_ptr->zstream.zfree = png_zfree;
|
||||
png_ptr->zstream.opaque = (voidpf)png_ptr;
|
||||
@ -665,7 +665,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
if (end_info_ptr != NULL)
|
||||
{
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
png_free(png_ptr, end_info_ptr->text);
|
||||
#endif
|
||||
png_destroy_struct((png_voidp)end_info_ptr);
|
||||
*end_info_ptr_ptr = (png_infop)NULL;
|
||||
@ -710,7 +710,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
png_free(png_ptr, png_ptr->gamma_to_1);
|
||||
#endif
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_PALETTE)
|
||||
png_free(png_ptr, png_ptr->palette);
|
||||
png_zfree(png_ptr, png_ptr->palette);
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_bKGD_SUPPORTED)
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_TRANS)
|
||||
png_free(png_ptr, png_ptr->trans);
|
||||
|
4
pngrio.c
4
pngrio.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*
|
||||
* This file provides a location for all input. Users which need
|
||||
* special handling are expected to write a function which has the same
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*
|
||||
* This file contains functions optionally called by an application
|
||||
* in order to tell libpng how to handle data when reading a PNG.
|
||||
@ -372,7 +372,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
{
|
||||
png_dsortp t;
|
||||
|
||||
t = png_malloc(png_ptr, sizeof (png_dsort));
|
||||
t = (png_dsortp)png_malloc(png_ptr, sizeof (png_dsort));
|
||||
t->next = hash[d];
|
||||
t->left = (png_byte)i;
|
||||
t->right = (png_byte)j;
|
||||
|
21
pngrutil.c
21
pngrutil.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*
|
||||
* This file contains routines which are only called from within
|
||||
* libpng itself during the course of reading an image.
|
||||
@ -298,10 +298,13 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
whatever the normal CRC configuration tells us. However, if we
|
||||
have an RGB image, the PLTE can be considered ancillary, so
|
||||
we will act as though it is. */
|
||||
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
#endif
|
||||
{
|
||||
png_crc_finish(png_ptr, 0);
|
||||
}
|
||||
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
|
||||
else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */
|
||||
{
|
||||
/* If we don't want to use the data from an ancillary chunk,
|
||||
@ -328,7 +331,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_chunk_warning(png_ptr, "CRC error");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
png_ptr->palette = palette;
|
||||
png_ptr->num_palette = (png_uint_16)num;
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, num);
|
||||
@ -404,7 +407,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_sRGB)
|
||||
if(igamma != (png_uint_32)51000L)
|
||||
if(igamma != (png_uint_32)45000L)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring incorrect gAMA value when sRGB is also present");
|
||||
@ -416,7 +419,9 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED */
|
||||
|
||||
file_gamma = (float)igamma / (float)100000.0;
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_ptr->gamma = file_gamma;
|
||||
#endif
|
||||
png_set_gAMA(png_ptr, info_ptr, file_gamma);
|
||||
}
|
||||
#endif
|
||||
@ -663,15 +668,15 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
intent = buf[0];
|
||||
/* check for bad intent */
|
||||
if (intent > 3)
|
||||
if (intent >= PNG_sRGB_INTENT_LAST)
|
||||
{
|
||||
png_warning(png_ptr, "Unknown sRGB intent");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
if ((info_ptr->valid & PNG_INFO_gAMA))
|
||||
if((png_uint_32)(png_ptr->gamma*(float)100000.+.5) != (png_uint_32)51000L)
|
||||
if((png_uint_32)(png_ptr->gamma*(float)100000.+.5) != (png_uint_32)45000L)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring incorrect gAMA value when sRGB is also present");
|
||||
@ -1329,7 +1334,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_charp tmp;
|
||||
|
||||
tmp = text;
|
||||
text = png_malloc(png_ptr, text_size +
|
||||
text = (png_charp)png_malloc(png_ptr, text_size +
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1);
|
||||
png_memcpy(text, tmp, text_size);
|
||||
png_free(png_ptr, tmp);
|
||||
|
6
pngset.c
6
pngset.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*
|
||||
* The functions here are used during reads to store data from the file
|
||||
* into the info struct, and during writes to store application data
|
||||
@ -239,7 +239,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_sRGB(png_ptr, info_ptr, intent);
|
||||
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
file_gamma = (float).51;
|
||||
file_gamma = (float).45;
|
||||
png_set_gAMA(png_ptr, info_ptr, file_gamma);
|
||||
#endif
|
||||
|
||||
|
240
pngtest.c
240
pngtest.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*
|
||||
* This program reads in a PNG image, writes it out again, and then
|
||||
* compares the two files. If the files are identical, this shows that
|
||||
@ -37,6 +37,11 @@
|
||||
|
||||
#include "png.h"
|
||||
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
#include <unistd.h>
|
||||
void *sbrk (ssize_t incr);
|
||||
#endif
|
||||
|
||||
int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname);
|
||||
|
||||
#ifdef __TURBOC__
|
||||
@ -47,6 +52,8 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname);
|
||||
/* #define STDERR stderr */
|
||||
#define STDERR stdout /* for DOS */
|
||||
|
||||
static int verbose = 0;
|
||||
|
||||
#if defined(PNG_NO_STDIO)
|
||||
/* START of code to validate stdio-free compilation */
|
||||
/* These copies of the default read/write functions come from pngrio.c and */
|
||||
@ -57,6 +64,8 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname);
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
@ -81,6 +90,8 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@ -124,6 +135,8 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
static void
|
||||
png_default_flush(png_structp png_ptr);
|
||||
static void
|
||||
png_default_flush(png_structp png_ptr)
|
||||
{
|
||||
FILE *io_ptr;
|
||||
@ -139,6 +152,8 @@ png_default_flush(png_structp png_ptr)
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
@ -158,6 +173,8 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@ -229,6 +246,107 @@ png_default_error(png_structp png_ptr, png_const_charp message)
|
||||
#endif /* PNG_NO_STDIO */
|
||||
/* END of code to validate stdio-free compilation */
|
||||
|
||||
/* START of code to validate memory allocation and deallocation */
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
/* Borland DOS special memory handler */
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
ERROR - memory debugging is not supported on this platform
|
||||
#else
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
64K. However, zlib may allocate more then 64K if you don't tell
|
||||
it not to. See zconf.h and png.h for more information. zlib does
|
||||
need to allocate exactly 64K, so whatever you call here must
|
||||
have the ability to do that.
|
||||
|
||||
This piece of code can be compiled to validate max 64K allocations
|
||||
by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */
|
||||
typedef struct memory_information {
|
||||
png_uint_32 size;
|
||||
png_voidp pointer;
|
||||
struct memory_information FAR *next;
|
||||
} memory_information;
|
||||
typedef memory_information FAR *memory_infop;
|
||||
|
||||
static memory_infop pinformation = NULL;
|
||||
static int current_allocation = 0;
|
||||
static int maximum_allocation = 0;
|
||||
|
||||
extern PNG_EXPORT(png_voidp,png_debug_malloc) PNGARG((png_structp png_ptr,
|
||||
png_uint_32 size));
|
||||
extern PNG_EXPORT(void,png_debug_free) PNGARG((png_structp png_ptr,
|
||||
png_voidp ptr));
|
||||
|
||||
png_voidp
|
||||
png_malloc(png_structp png_ptr, png_uint_32 size) {
|
||||
if (png_ptr == NULL) {
|
||||
fprintf(STDERR, "NULL pointer to memory allocator\n");
|
||||
return NULL;
|
||||
}
|
||||
if (size == 0)
|
||||
return NULL;
|
||||
|
||||
/* This calls the library allocator twice, once to get the requested
|
||||
buffer and once to get a new free list entry. */
|
||||
{
|
||||
memory_infop pinfo = png_debug_malloc(png_ptr, sizeof *pinfo);
|
||||
pinfo->size = size;
|
||||
current_allocation += size;
|
||||
if (current_allocation > maximum_allocation)
|
||||
maximum_allocation = current_allocation;
|
||||
pinfo->pointer = png_debug_malloc(png_ptr, size);
|
||||
pinfo->next = pinformation;
|
||||
pinformation = pinfo;
|
||||
/* Make sure the caller isn't assuming zeroed memory. */
|
||||
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
||||
return pinfo->pointer;
|
||||
}
|
||||
}
|
||||
|
||||
/* Free a pointer. It is removed from the list at the same time. */
|
||||
void
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
fprintf(STDERR, "NULL pointer to memory allocator\n");
|
||||
if (ptr == 0) {
|
||||
#if 0 /* This happens all the time. */
|
||||
fprintf(STDERR, "WARNING: freeing NULL pointer\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/* Unlink the element from the list. */
|
||||
{
|
||||
memory_infop FAR *ppinfo = &pinformation;
|
||||
for (;;) {
|
||||
memory_infop pinfo = *ppinfo;
|
||||
if (pinfo->pointer == ptr) {
|
||||
*ppinfo = pinfo->next;
|
||||
current_allocation -= pinfo->size;
|
||||
if (current_allocation < 0)
|
||||
fprintf(STDERR, "Duplicate free of memory\n");
|
||||
/* We must free the list element too, but first kill
|
||||
the memory which is to be freed. */
|
||||
memset(ptr, 0x55, pinfo->size);
|
||||
png_debug_free(png_ptr, pinfo);
|
||||
break;
|
||||
}
|
||||
if (pinfo->next == NULL) {
|
||||
fprintf(STDERR, "Pointer %x not found\n", ptr);
|
||||
break;
|
||||
}
|
||||
ppinfo = &pinfo->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally free the data. */
|
||||
png_debug_free(png_ptr, ptr);
|
||||
}
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
#endif
|
||||
/* END of code to test memory allocation/deallocation */
|
||||
|
||||
/* Test one file */
|
||||
int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
@ -338,7 +456,11 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
&color_type, &interlace_type, &compression_type, &filter_type))
|
||||
{
|
||||
png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
|
||||
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
color_type, interlace_type, compression_type, filter_type);
|
||||
#else
|
||||
color_type, PNG_INTERLACE_NONE, compression_type, filter_type);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED) && defined(PNG_WRITE_bKGD_SUPPORTED)
|
||||
@ -517,6 +639,17 @@ int 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);
|
||||
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
if(verbose)
|
||||
{
|
||||
png_uint_32 iwidth, iheight;
|
||||
iwidth = png_get_image_width(write_ptr, write_info_ptr);
|
||||
iheight = png_get_image_height(write_ptr, write_info_ptr);
|
||||
fprintf(STDERR, "Image width = %lu, height = %lu\n",
|
||||
iwidth, iheight);
|
||||
}
|
||||
#endif
|
||||
|
||||
png_debug(0, "Destroying data structs\n");
|
||||
png_free(read_ptr, row_buf);
|
||||
@ -590,6 +723,19 @@ main(int argc, char *argv[])
|
||||
int ierror = 0;
|
||||
|
||||
fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
|
||||
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
|
||||
|
||||
/* Do some consistency checking on the memory allocation settings, I'm
|
||||
not sure this matters, but it is nice to know, the first of these
|
||||
tests should be impossible because of the way the macros are set
|
||||
in pngconf.h */
|
||||
#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
|
||||
fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n");
|
||||
#endif
|
||||
/* I think the following can happen. */
|
||||
#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K)
|
||||
fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n");
|
||||
#endif
|
||||
|
||||
if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))
|
||||
{
|
||||
@ -602,16 +748,27 @@ main(int argc, char *argv[])
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (strcmp(argv[1], "-m") == 0)
|
||||
multiple = 1;
|
||||
else
|
||||
inname = argv[1];
|
||||
if (strcmp(argv[1], "-m") == 0)
|
||||
multiple = 1;
|
||||
else if (strcmp(argv[1], "-mv") == 0 ||
|
||||
strcmp(argv[1], "-vm") == 0 )
|
||||
{
|
||||
multiple = 1;
|
||||
verbose = 1;
|
||||
}
|
||||
else if (strcmp(argv[1], "-v") == 0)
|
||||
{
|
||||
verbose = 1;
|
||||
inname = argv[2];
|
||||
}
|
||||
else
|
||||
inname = argv[1];
|
||||
}
|
||||
|
||||
if (!multiple && argc == 3)
|
||||
outname = argv[2];
|
||||
if (!multiple && argc == 3+verbose)
|
||||
outname = argv[2+verbose];
|
||||
|
||||
if ((!multiple && argc > 3) || (multiple && argc < 2))
|
||||
if ((!multiple && argc > 3+verbose) || (multiple && argc < 2))
|
||||
{
|
||||
fprintf(STDERR,
|
||||
"usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
|
||||
@ -626,31 +783,84 @@ main(int argc, char *argv[])
|
||||
if (multiple)
|
||||
{
|
||||
int i;
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
int allocation_now = current_allocation;
|
||||
#endif
|
||||
for (i=2; i<argc; ++i)
|
||||
{
|
||||
{
|
||||
int kerror;
|
||||
fprintf(STDERR, "Testing %s:",argv[i]);
|
||||
kerror = test_one_file(argv[i], outname);
|
||||
if (kerror == 0) fprintf(STDERR, " PASS\n");
|
||||
if (kerror == 0)
|
||||
fprintf(STDERR, " PASS\n");
|
||||
else {
|
||||
fprintf(STDERR, " FAIL\n");
|
||||
ierror += kerror;
|
||||
}
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
if (allocation_now != current_allocation)
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
|
||||
current_allocation-allocation_now);
|
||||
if (current_allocation != 0) {
|
||||
memory_infop pinfo = pinformation;
|
||||
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
|
||||
current_allocation);
|
||||
while (pinfo != NULL) {
|
||||
fprintf(STDERR, " %d bytes at %x\n", pinfo->size, pinfo->pointer);
|
||||
pinfo = pinfo->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
fprintf(STDERR, "Maximum memory allocation: %d bytes\n",
|
||||
maximum_allocation);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<3; ++i) {
|
||||
int kerror;
|
||||
fprintf(STDERR, "Testing %s:",inname);
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
int allocation_now = current_allocation;
|
||||
#endif
|
||||
if (i == 0 || verbose == 1 || ierror != 0)
|
||||
fprintf(STDERR, "Testing %s:",inname);
|
||||
kerror = test_one_file(inname, outname);
|
||||
if (kerror == 0) fprintf(STDERR, " PASS\n");
|
||||
else {
|
||||
if(kerror == 0)
|
||||
{
|
||||
if(verbose == 1 || i == 2) fprintf(STDERR, " PASS\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(verbose == 0 && i != 2)
|
||||
fprintf(STDERR, "Testing %s:",inname);
|
||||
fprintf(STDERR, " FAIL\n");
|
||||
ierror += kerror;
|
||||
}
|
||||
}
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
if (allocation_now != current_allocation)
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
|
||||
current_allocation-allocation_now);
|
||||
if (current_allocation != 0) {
|
||||
memory_infop pinfo = pinformation;
|
||||
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
|
||||
current_allocation);
|
||||
while (pinfo != NULL) {
|
||||
fprintf(STDERR, " %d bytes at %x\n", pinfo->size, pinfo->pointer);
|
||||
pinfo = pinfo->next;
|
||||
}
|
||||
}
|
||||
fprintf(STDERR, "sbrk(0)=%d\n",sbrk(0));
|
||||
#endif
|
||||
}
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
fprintf(STDERR, "Maximum memory allocation: %d bytes\n",
|
||||
maximum_allocation);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ierror == 0)
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -68,7 +68,8 @@ png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
int
|
||||
png_set_interlace_handling(png_structp png_ptr)
|
||||
{
|
||||
@ -299,7 +300,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
png_debug(1, "in png_do_packswap\n");
|
||||
if (
|
||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||
row != NULL && row_info != NULL
|
||||
row != NULL && row_info != NULL &&
|
||||
#endif
|
||||
row_info->bit_depth < 8)
|
||||
{
|
||||
|
4
pngwio.c
4
pngwio.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*
|
||||
* This file provides a location for all output. Users which need
|
||||
* special handling are expected to write functions which have the same
|
||||
|
27
pngwrite.c
27
pngwrite.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*/
|
||||
|
||||
/* get internal access to png.h */
|
||||
@ -34,7 +34,12 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
/* write IHDR information. */
|
||||
png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
|
||||
info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
|
||||
info_ptr->filter_type, info_ptr->interlace_type);
|
||||
info_ptr->filter_type,
|
||||
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
info_ptr->interlace_type);
|
||||
#else
|
||||
0);
|
||||
#endif
|
||||
/* the rest of these check to see if the valid field has the appropriate
|
||||
flag set, and if it does, writes the chunk. */
|
||||
#if defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
@ -71,9 +76,9 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA &&
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<info_ptr->num_trans; i++)
|
||||
info_ptr->trans[i] = 255 - info_ptr->trans[i];
|
||||
int j;
|
||||
for (j=0; j<info_ptr->num_trans; j++)
|
||||
info_ptr->trans[j] = 255 - info_ptr->trans[j];
|
||||
}
|
||||
#endif
|
||||
png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values),
|
||||
@ -315,7 +320,7 @@ png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
|
||||
png_set_write_fn(png_ptr, NULL, NULL, NULL);
|
||||
|
||||
@ -346,7 +351,7 @@ png_write_init(png_structp png_ptr)
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_set_write_fn(png_ptr, NULL, NULL, NULL);
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
@ -386,9 +391,13 @@ png_write_image(png_structp png_ptr, png_bytepp image)
|
||||
png_bytepp rp; /* points to current row */
|
||||
|
||||
png_debug(1, "in png_write_image\n");
|
||||
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
/* intialize interlace handling. If image is not interlaced,
|
||||
this will set pass to 1 */
|
||||
num_pass = png_set_interlace_handling(png_ptr);
|
||||
#else
|
||||
num_pass = 1;
|
||||
#endif
|
||||
/* loop through passes */
|
||||
for (pass = 0; pass < num_pass; pass++)
|
||||
{
|
||||
@ -749,7 +758,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
}
|
||||
else
|
||||
{
|
||||
png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr,
|
||||
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -24,6 +24,10 @@ png_do_write_transformations(png_structp png_ptr)
|
||||
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->flags);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
|
19
pngwutil.c
19
pngwutil.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* libpng 0.98
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* January 16, 1998
|
||||
* January 30, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -200,12 +200,16 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
filter_type = PNG_FILTER_TYPE_BASE;
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
if (interlace_type != PNG_INTERLACE_NONE &&
|
||||
interlace_type != PNG_INTERLACE_ADAM7)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid interlace type specified");
|
||||
interlace_type = PNG_INTERLACE_ADAM7;
|
||||
}
|
||||
#else
|
||||
interlace_type=PNG_INTERLACE_NONE;
|
||||
#endif
|
||||
|
||||
/* save off the relevent information */
|
||||
png_ptr->bit_depth = (png_byte)bit_depth;
|
||||
@ -351,7 +355,7 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
|
||||
png_byte buf[1];
|
||||
|
||||
png_debug(1, "in png_write_sRGB\n");
|
||||
if(srgb_intent > 3)
|
||||
if(srgb_intent >= PNG_sRGB_INTENT_LAST)
|
||||
png_warning(png_ptr,
|
||||
"Invalid sRGB rendering intent specified");
|
||||
buf[0]=(png_byte)srgb_intent;
|
||||
@ -821,7 +825,8 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
}
|
||||
|
||||
/* save the data */
|
||||
output_ptr[num_output_ptr] = png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
output_ptr[num_output_ptr] = (png_charp)png_malloc(png_ptr,
|
||||
png_ptr->zbuf_size);
|
||||
png_memcpy(output_ptr[num_output_ptr], png_ptr->zbuf,
|
||||
png_ptr->zbuf_size);
|
||||
num_output_ptr++;
|
||||
@ -874,7 +879,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
}
|
||||
|
||||
/* save off the data */
|
||||
output_ptr[num_output_ptr] = png_malloc(png_ptr,
|
||||
output_ptr[num_output_ptr] = (png_charp)png_malloc(png_ptr,
|
||||
png_ptr->zbuf_size);
|
||||
png_memcpy(output_ptr[num_output_ptr], png_ptr->zbuf,
|
||||
png_ptr->zbuf_size);
|
||||
@ -1098,6 +1103,7 @@ png_write_start_row(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* if interlaced, we need to set up width and height of pass */
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
@ -1115,6 +1121,7 @@ png_write_start_row(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_ptr->num_rows = png_ptr->height;
|
||||
png_ptr->usr_width = png_ptr->width;
|
||||
@ -1137,6 +1144,7 @@ png_write_finish_row(png_structp png_ptr)
|
||||
if (png_ptr->row_number < png_ptr->num_rows)
|
||||
return;
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* if interlaced, go to next pass */
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
@ -1178,6 +1186,7 @@ png_write_finish_row(png_structp png_ptr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* if we get here, we've just written the last row, so we need
|
||||
to flush the compressor */
|
||||
|
Loading…
Reference in New Issue
Block a user