Imported from libpng-0.87.tar
This commit is contained in:
parent
69b1448f19
commit
4ee97b0891
74
libpng.txt
74
libpng.txt
@ -1,9 +1,9 @@
|
||||
libpng.txt - a description on how to use and modify libpng
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
Updated/rewritten per request in the libpng FAQ
|
||||
Copyright (c) 1995 Frank J. T. Wojcik
|
||||
December 18, 1995
|
||||
@ -13,7 +13,7 @@ I. Introduction
|
||||
This file describes how to use and modify the PNG reference library
|
||||
(known as libpng) for your own use. There are five sections to this
|
||||
file: introduction, structures, reading, writing, and modification and
|
||||
configuration notes for various special platforms. Other then this
|
||||
configuration notes for various special platforms. In addition to this
|
||||
file, example.c is a good starting point for using the library, as
|
||||
it is heavily commented and should include everything most people
|
||||
will need.
|
||||
@ -22,7 +22,7 @@ Libpng was written as a companion to the PNG specification, as a
|
||||
way to reduce the amount of time and effort it takes to support
|
||||
the PNG file format in application programs. Most users will not
|
||||
have to modify the library significantly; advanced users may want
|
||||
to modify it more. The library was coded for both kind of users.
|
||||
to modify it more. The library was coded for both kinds of users.
|
||||
All attempts were made to make it as complete as possible, while
|
||||
keeping the code easy to understand. Currently, this library
|
||||
only supports C. Support for other languages is being considered.
|
||||
@ -37,9 +37,15 @@ majority of the needs of it's users.
|
||||
|
||||
Libpng uses zlib for its compression and decompression of PNG files.
|
||||
The zlib compression utility is a general purpose utility that is
|
||||
useful for more then PNG files, and can be used without libpng.
|
||||
useful for more than PNG files, and can be used without libpng.
|
||||
See the documentation delivered with zlib for more details.
|
||||
|
||||
Libpng is thread safe provided the threads are using different
|
||||
instances of the structures. Each thread should have its own
|
||||
png_struct and png_info instances, and thus its own image.
|
||||
Libpng does not protect itself against two threads using the
|
||||
same instance of a structure.
|
||||
|
||||
|
||||
|
||||
II. Structures
|
||||
@ -287,8 +293,8 @@ PNG can have files with 16 bits per channel. If you only can handle
|
||||
if (info_ptr->bit_depth == 16)
|
||||
png_set_strip_16(png_ptr);
|
||||
|
||||
If you need to reduce an rgb file to a paletted file (perhaps because
|
||||
a paletted file has more entries then will fit on your screen)
|
||||
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() will do that. Note that this is a simple match
|
||||
dither, that merely finds the closest color available. This should
|
||||
work fairly well with optimized palettes, and fairly badly with linear
|
||||
@ -799,7 +805,7 @@ time_t routine uses gmtime(). You don't have to use either of
|
||||
these, but if you wish to fill in the png_time structure directly,
|
||||
you should provide the time in universal time (GMT) if possible
|
||||
instead of your local time. Note that the year number is the full
|
||||
year (ie 1996, rather than 96)
|
||||
year (ie 1996, rather than 96).
|
||||
|
||||
It is possible to have libpng flush any pending output, either manually,
|
||||
or automatically after a certain number of lines have been written. To
|
||||
@ -1024,8 +1030,9 @@ The replacement I/O functions should have prototypes as follows:
|
||||
png_uint_32 length);
|
||||
void user_flush_data(png_structp png_ptr);
|
||||
|
||||
Note that you can pass NULL for the flush function if you are not doing
|
||||
flushing of the output data.
|
||||
Supplying NULL for the read, write, or flush functions sets them back
|
||||
to using the default C stream functions. It is an error to read from
|
||||
a write stream, and vice versa.
|
||||
|
||||
Error handling in libpng is done through png_error() and png_warning().
|
||||
Errors handled through png_error() are fatal, meaning that png_error()
|
||||
@ -1073,13 +1080,19 @@ itself.
|
||||
|
||||
Configuring for 16 bit platforms:
|
||||
|
||||
You will probably need to change the png_large_malloc() and
|
||||
You may need to change the png_large_malloc() and
|
||||
png_large_free() routines in pngmem.c, as these are requred
|
||||
to allocate 64K. Also, you will want to look into zconf.h to tell
|
||||
zlib (and thus libpng) that it cannot allocate more then 64K at a
|
||||
time. Even if you can, the memory won't be accessable. So limit zlib
|
||||
and libpng to 64K by defining MAXSEG_64K.
|
||||
|
||||
Configuring for DOS:
|
||||
|
||||
For DOS users which only have access to the lower 640K, you will
|
||||
have to limit zlib's memory usage via a png_set_compression_mem_level()
|
||||
call. See zlib.h or zconf.h in the zlib library for more information.
|
||||
|
||||
Configuring for Medium Model:
|
||||
|
||||
Libpng's support for medium model has been tested on most of the popular
|
||||
@ -1089,7 +1102,7 @@ all set. Everything in the library (except for zlib's structure) is
|
||||
expecting far data. You must use the typedefs with the p or pp on
|
||||
the end for pointers (or at least look at them and be careful). Make
|
||||
note that the row's of data are defined as png_bytepp which is a
|
||||
unsigned char far * far *
|
||||
unsigned char far * far *.
|
||||
|
||||
Configuring for gui/windowing platforms:
|
||||
|
||||
@ -1099,14 +1112,47 @@ You may want to write a single function to do this and call it something
|
||||
like png_message(). On some compliers, you may have to change the
|
||||
memory allocators (png_malloc, etc.).
|
||||
|
||||
|
||||
Configuring for compiler xxx:
|
||||
|
||||
All includes for libpng are in pngconf.h. If you need to add/change/delete
|
||||
an include, this is the place to do it. The includes that are not
|
||||
needed outside libpng are protected by the PNG_INTERNAL definition,
|
||||
which is only defined for those routines inside libpng itself. The
|
||||
files in libpng proper only include png.h.
|
||||
files in libpng proper only include png.h, which includes pngconf.h.
|
||||
|
||||
Configuring zlib:
|
||||
|
||||
There are special functions to configure the compression. Perhaps
|
||||
the most useful one changes the compression level. The library
|
||||
normally uses the default compression level, but for maximum
|
||||
compression (9) or maximum speed (1), you may desire to change the
|
||||
level. You do this by calling:
|
||||
|
||||
png_set_compression_mem_level(png_ptr, level);
|
||||
|
||||
Another useful one is to reduce the memory level used by the library.
|
||||
The memory level defaults to 8, but it can be lowered if you are
|
||||
short on memory (running DOS, for example, where you only have 640K).
|
||||
|
||||
png_set_compression_mem_level(png_ptr, level);
|
||||
|
||||
If you want to control whether libpng uses filtering or not, you
|
||||
can call this function. I recommend not changing the default unless
|
||||
you are experimenting with compression ratios.
|
||||
|
||||
png_set_filtering(png_ptr, use_filter);
|
||||
|
||||
The other functions are for configuring zlib. They are not recommended
|
||||
for normal use and may result in writing an invalid png file. See
|
||||
zlib.h for more information on what these mean.
|
||||
|
||||
png_set_compression_strategy(png_ptr, strategy);
|
||||
png_set_compression_window_bits(png_ptr, window_bits);
|
||||
png_set_compression_method(png_ptr, method);
|
||||
|
||||
Except for png_set_filtering(), all of these are just controlling
|
||||
zlib, so see the zlib documentation (zlib.h and zconf.h) for more
|
||||
information.
|
||||
|
||||
Removing unwanted object code:
|
||||
|
||||
|
73
makefile.elf
Normal file
73
makefile.elf
Normal file
@ -0,0 +1,73 @@
|
||||
# makefile for libpng on (linux) ELF
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
# For conditions of distribution and use, see copyright notice in png.h
|
||||
|
||||
CC=gcc
|
||||
CFLAGS=-I../zlib -O2 -Wall -fPIC
|
||||
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
|
||||
|
||||
RANLIB=ranlib
|
||||
#RANLIB=echo
|
||||
|
||||
PNGVER = 0.87
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.h
|
||||
prefix=/usr/local
|
||||
|
||||
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
|
||||
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
|
||||
pngmem.o pngerror.o pngpread.o
|
||||
|
||||
all: libpng.so pngtest
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
ar rc $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
libpng.so: libpng.so.1
|
||||
ln -sf libpng.so.1 libpng.so
|
||||
|
||||
libpng.so.1: libpng.so.1.$(PNGVER)
|
||||
ln -sf libpng.so.1.$(PNGVER) libpng.so.1
|
||||
|
||||
libpng.so.1.$(PNGVER): $(OBJS)
|
||||
gcc -shared -Wl,-soname,libpng.so.1 -o libpng.so.1.$(PNGVER) $(OBJS)
|
||||
|
||||
pngtest: pngtest.o libpng.so
|
||||
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
|
||||
|
||||
test: pngtest
|
||||
./pngtest
|
||||
|
||||
install: libpng.so.1.$(PNGVER)
|
||||
-@mkdir $(prefix)/include
|
||||
-@mkdir $(prefix)/lib
|
||||
cp png.h $(prefix)/include
|
||||
cp pngconf.h $(prefix)/include
|
||||
chmod 644 $(prefix)/include/png.h
|
||||
chmod 644 $(prefix)/include/pngconf.h
|
||||
cp libpng.so.1.$(PNGVER) $(prefix)/lib
|
||||
chmod 755 $(prefix)/lib/libpng.so.1.$(PNGVER)
|
||||
-@/bin/rm $(prefix)/lib/libpng.so.1 $(prefix)/lib/libpng.so
|
||||
(cd $(prefix)/lib; ln -sf libpng.so.1.$(PNGVER) libpng.so.1; \
|
||||
ln -sf libpng.so.1 libpng.so)
|
||||
|
||||
clean:
|
||||
rm -f *.o libpng.so.1.$(PNGVER) libpng.so.1 libpng.so pngtest pngout.png
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o: png.h pngconf.h
|
||||
pngerror.o: png.h pngconf.h
|
||||
pngio.o: png.h pngconf.h
|
||||
pngmem.o: png.h pngconf.h
|
||||
pngrcb.o: png.h pngconf.h
|
||||
pngread.o: png.h pngconf.h
|
||||
pngrtran.o: png.h pngconf.h
|
||||
pngrutil.o: png.h pngconf.h
|
||||
pngtest.o: png.h pngconf.h
|
||||
pngtrans.o: png.h pngconf.h
|
||||
pngwrite.o: png.h pngconf.h
|
||||
pngwtran.o: png.h pngconf.h
|
||||
pngwutil.o: png.h pngconf.h
|
||||
pngpread.o: png.h pngconf.h
|
@ -2,15 +2,15 @@
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
# For conditions of distribution and use, see copyright notice in png.h
|
||||
|
||||
CC=cc
|
||||
CFLAGS=-I../zlib -O
|
||||
CC=gcc
|
||||
CFLAGS=-I../zlib -O2 -Wall
|
||||
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
|
||||
|
||||
#RANLIB=ranlib
|
||||
RANLIB=echo
|
||||
RANLIB=ranlib
|
||||
#RANLIB=echo
|
||||
|
||||
# where make install puts libpng.a and png.h
|
||||
prefix=/usr/local
|
||||
prefix=/home/munet-d2/sun/local
|
||||
|
||||
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
|
||||
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
|
||||
@ -31,11 +31,12 @@ test: pngtest
|
||||
install: libpng.a
|
||||
-@mkdir $(prefix)/include
|
||||
-@mkdir $(prefix)/lib
|
||||
cp png.h $(prefix)/include
|
||||
cp pngconf.h $(prefix)/include
|
||||
cp png.h pngconf.h $(prefix)/include
|
||||
rcp png.h pngconf.h vlsi:bin/include
|
||||
chmod 644 $(prefix)/include/png.h
|
||||
chmod 644 $(prefix)/include/pngconf.h
|
||||
cp libpng.a $(prefix)/lib
|
||||
rcp libpng.a vlsi:bin/lib
|
||||
chmod 644 $(prefix)/lib/libpng.a
|
||||
|
||||
clean:
|
||||
@ -57,3 +58,4 @@ pngwrite.o: png.h pngconf.h
|
||||
pngwtran.o: png.h pngconf.h
|
||||
pngwutil.o: png.h pngconf.h
|
||||
pngpread.o: png.h pngconf.h
|
||||
|
27
png.c
27
png.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* png.c - location for general purpose png functions
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
/* version information for c files. This better match the version
|
||||
string defined in png.h */
|
||||
char FARDATA png_libpng_ver[] = "0.86";
|
||||
char png_libpng_ver[] = "0.87";
|
||||
|
||||
/* place to hold the signiture string for a png file. */
|
||||
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
@ -107,11 +107,22 @@ png_check_sig(png_bytep sig, int num)
|
||||
voidpf
|
||||
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
{
|
||||
voidp ptr;
|
||||
png_voidp ptr;
|
||||
png_uint_32 num_bytes;
|
||||
|
||||
ptr = ((voidp)png_large_malloc((png_structp)png_ptr,
|
||||
(png_uint_32)items * (png_uint_32)size));
|
||||
png_memset(ptr, 0, (png_uint_32)items * (png_uint_32)size);
|
||||
ptr = png_large_malloc((png_structp)png_ptr,
|
||||
(png_uint_32)items * (png_uint_32)size);
|
||||
num_bytes = (png_uint_32)items * (png_uint_32)size;
|
||||
if (num_bytes > (png_uint_32)0x7fff)
|
||||
{
|
||||
png_memset(ptr, 0, (png_size_t)0x8000L);
|
||||
png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
|
||||
(png_size_t)(num_bytes - (png_uint_32)0x8000L));
|
||||
}
|
||||
else
|
||||
{
|
||||
png_memset(ptr, 0, (png_size_t)num_bytes);
|
||||
}
|
||||
return (voidpf)(ptr);
|
||||
}
|
||||
|
||||
@ -119,7 +130,7 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
void
|
||||
png_zfree(voidpf png_ptr, voidpf ptr)
|
||||
{
|
||||
png_large_free((png_structp)png_ptr, (voidp)ptr);
|
||||
png_large_free((png_structp)png_ptr, (png_voidp)ptr);
|
||||
}
|
||||
|
||||
/* reset the crc variable to 32 bits of 1's. Care must be taken
|
||||
|
62
png.h
62
png.h
@ -1,12 +1,12 @@
|
||||
|
||||
/* png.h - header file for png reference library
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
Jan 10, 1996
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
Jan 15, 1996
|
||||
|
||||
Note: This is a beta version. It reads and writes valid files
|
||||
on the platforms I have, but it has had limited portability
|
||||
testing. Furthermore, you will may have to modify the
|
||||
testing. Furthermore, you may have to modify the
|
||||
includes below to get it to work on your system, and you
|
||||
may have to supply the correct compiler flags in the makefile.
|
||||
Read the readme.txt for more information, and how to contact
|
||||
@ -74,10 +74,10 @@
|
||||
|
||||
/* version information for png.h - this should match the version
|
||||
number in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "0.86"
|
||||
/* careful here. I wanted to use 086, but that would be octal. Version
|
||||
#define PNG_LIBPNG_VER_STRING "0.87"
|
||||
/* careful here. I wanted to use 087, but that would be octal. Version
|
||||
1.0 will be 100 here, etc. */
|
||||
#define PNG_LIBPNG_VER 86
|
||||
#define PNG_LIBPNG_VER 87
|
||||
|
||||
/* variables defined in png.c - only it needs to define PNG_NO_EXTERN */
|
||||
#ifndef PNG_NO_EXTERN
|
||||
@ -269,7 +269,7 @@ typedef png_info FAR * FAR * png_infopp;
|
||||
#define PNG_INFO_oFFs 0x0100
|
||||
#define PNG_INFO_tIME 0x0200
|
||||
|
||||
/* these determine if a function in the info needs freed */
|
||||
/* these determine if a function in the info needs to be freed */
|
||||
#define PNG_FREE_PALETTE 0x0001
|
||||
#define PNG_FREE_HIST 0x0002
|
||||
#define PNG_FREE_TRANS 0x0004
|
||||
@ -392,6 +392,14 @@ struct png_struct_def
|
||||
png_uint_32 current_text_left;
|
||||
png_charp current_text;
|
||||
png_charp current_text_ptr;
|
||||
#endif
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* for the Borland special 64K segment handler */
|
||||
png_bytepp offset_table_ptr;
|
||||
png_bytep offset_table;
|
||||
png_uint_16 offset_table_number;
|
||||
png_uint_16 offset_table_count;
|
||||
png_uint_16 offset_table_count_free;
|
||||
#endif
|
||||
png_byte push_chunk_name[4];
|
||||
png_bytep save_buffer_ptr;
|
||||
@ -694,9 +702,11 @@ extern void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
|
||||
extern void png_init_io PNGARG((png_structp png_ptr, FILE *fp));
|
||||
|
||||
/* Replace the error message and abort, and warning functions with user
|
||||
supplied functions. If no messages are to be printed, NULL can be
|
||||
supplied for error_fn and warning_fn, although error_fn will still do
|
||||
a longjmp to the last setjmp location. */
|
||||
supplied functions. If no messages are to be printed then you must
|
||||
supply replacement message functions. The replacement error_fn should
|
||||
still do a longjmp to the last setjmp location if you are using this
|
||||
method of error handling. If error_fn or warning_fn is NULL, the
|
||||
default functions will be used. */
|
||||
extern void png_set_message_fn PNGARG((png_structp png_ptr, png_voidp msg_ptr,
|
||||
png_msg_ptr error_fn, png_msg_ptr warning_fn));
|
||||
|
||||
@ -711,19 +721,21 @@ extern void png_set_write_fn PNGARG((png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
|
||||
|
||||
/* Replace the default data input function with a user supplied one. */
|
||||
extern void png_set_read_fn PNGARG((png_structp png_ptr, void *io_ptr,
|
||||
extern void png_set_read_fn PNGARG((png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn));
|
||||
|
||||
/* Return the user pointer associated with the I/O functions */
|
||||
extern png_voidp png_get_io_ptr PNGARG((png_structp png_ptr));
|
||||
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
/* Replace the default push model read functions */
|
||||
extern void png_set_push_fn PNGARG((png_structp png_ptr, png_voidp push_ptr,
|
||||
png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
|
||||
png_progressive_end_ptr end_fn));
|
||||
|
||||
/* returns the user pointer assiciated with the push read functions */
|
||||
/* returns the user pointer associated with the push read functions */
|
||||
extern png_voidp png_get_progressive_ptr PNGARG((png_structp png_ptr));
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
extern png_voidp png_large_malloc PNGARG((png_structp png_ptr,
|
||||
png_uint_32 size));
|
||||
@ -732,14 +744,14 @@ extern png_voidp png_large_malloc PNGARG((png_structp png_ptr,
|
||||
extern void png_large_free PNGARG((png_structp png_ptr, png_voidp ptr));
|
||||
|
||||
/* Allocate memory. */
|
||||
extern png_voidp png_malloc PNGARG((png_structp png_ptr, png_uint_32 size));
|
||||
extern void * png_malloc PNGARG((png_structp png_ptr, png_uint_32 size));
|
||||
|
||||
/* Reallocate memory. */
|
||||
extern png_voidp png_realloc PNGARG((png_structp png_ptr, png_voidp ptr,
|
||||
extern void * png_realloc PNGARG((png_structp png_ptr, void * ptr,
|
||||
png_uint_32 size, png_uint_32 old_size));
|
||||
|
||||
/* free's a pointer allocated by png_malloc() */
|
||||
extern void png_free PNGARG((png_structp png_ptr, png_voidp ptr));
|
||||
extern void png_free PNGARG((png_structp png_ptr, void * ptr));
|
||||
|
||||
/* Fatal error in libpng - can't continue */
|
||||
extern void png_error PNGARG((png_structp png_ptr, png_const_charp error));
|
||||
@ -883,11 +895,13 @@ extern void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
|
||||
png_uint_32 length));
|
||||
|
||||
/* default error and warning functions if user doesn't supply them */
|
||||
extern void png_default_warning PNGARG((png_structp png_ptr, png_const_charp message));
|
||||
extern void png_default_error PNGARG((png_structp png_ptr, png_const_charp error));
|
||||
extern void png_default_warning PNGARG((png_structp png_ptr,
|
||||
png_const_charp message));
|
||||
extern void png_default_error PNGARG((png_structp png_ptr,
|
||||
png_const_charp error));
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
extern void png_flush PNGARG((png_struct *png_ptr));
|
||||
extern void png_default_flush PNGARG((png_struct *png_ptr));
|
||||
extern void png_flush PNGARG((png_structp png_ptr));
|
||||
extern void png_default_flush PNGARG((png_structp png_ptr));
|
||||
#endif
|
||||
|
||||
/* place a 32 bit number into a buffer in png byte order. We work
|
||||
@ -1280,16 +1294,12 @@ extern void png_process_IDAT_data PNGARG((png_structp png_ptr,
|
||||
png_bytep buffer, png_uint_32 buffer_length));
|
||||
extern void png_push_process_row PNGARG((png_structp png_ptr));
|
||||
extern void png_push_handle_PLTE PNGARG((png_structp png_ptr,
|
||||
png_infop info, png_uint_32 length));
|
||||
png_uint_32 length));
|
||||
extern void png_push_read_plte PNGARG((png_structp png_ptr, png_infop info));
|
||||
extern void png_push_handle_tRNS PNGARG((png_structp png_ptr, png_infop info,
|
||||
png_uint_32 length));
|
||||
extern void png_push_handle_hIST PNGARG((png_structp png_ptr, png_infop info,
|
||||
png_uint_32 length));
|
||||
extern void png_push_handle_tEXt PNGARG((png_structp png_ptr, png_infop info,
|
||||
png_uint_32 length));
|
||||
extern void png_push_handle_zTXt PNGARG((png_structp png_ptr, png_infop info,
|
||||
png_uint_32 length));
|
||||
extern void png_push_have_info PNGARG((png_structp png_ptr, png_infop info));
|
||||
extern void png_push_have_end PNGARG((png_structp png_ptr, png_infop info));
|
||||
extern void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
|
||||
@ -1298,12 +1308,12 @@ extern void png_process_some_data PNGARG((png_structp png_ptr,
|
||||
png_infop info));
|
||||
extern void png_read_push_finish_row PNGARG((png_structp png_ptr));
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
extern void png_push_handle_tEXt PNGARG((png_structp png_ptr, png_infop info,
|
||||
extern void png_push_handle_tEXt PNGARG((png_structp png_ptr,
|
||||
png_uint_32 length));
|
||||
extern void png_push_read_text PNGARG((png_structp png_ptr, png_infop info));
|
||||
#endif
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
extern void png_push_handle_zTXt PNGARG((png_structp png_ptr, png_infop info,
|
||||
extern void png_push_handle_zTXt PNGARG((png_structp png_ptr,
|
||||
png_uint_32 length));
|
||||
extern void png_push_read_ztxt PNGARG((png_structp png_ptr, png_infop info));
|
||||
#endif
|
||||
|
@ -65,5 +65,8 @@ version 0.85
|
||||
version 0.86
|
||||
fixed bugs
|
||||
improved documentation
|
||||
|
||||
version 0.87
|
||||
fixed medium model bugs
|
||||
fixed other bugs introduced in 0.85 and 0.86
|
||||
added some minor documentation
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngconf.c - machine configurable file for libpng
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
@ -27,7 +27,7 @@
|
||||
Unless this gets smaller then the size of a row (compressed),
|
||||
it should not make much difference how big this is. */
|
||||
|
||||
#define PNG_ZBUF_SIZE 8192
|
||||
#define PNG_ZBUF_SIZE 32768
|
||||
|
||||
/* While libpng currently uses zlib for it's compression, it has been designed
|
||||
to stand on it's own. Towards this end, there are two defines that are
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
|
||||
This file provides a location for all error handling. Users which
|
||||
need special error handling are expected to write replacement functions
|
||||
@ -42,6 +42,10 @@ png_warning(png_structp png_ptr, png_const_charp message)
|
||||
png_default_warning(png_ptr, message);
|
||||
}
|
||||
|
||||
/* This is the default error handling function. Note that replacements for
|
||||
this function MUST NOT RETURN, or the program will likely crash. This
|
||||
function is used by default, or if the program supplies NULL for the
|
||||
error function pointer in png_set_message_fn(). */
|
||||
void
|
||||
png_default_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
|
41
pngio.c
41
pngio.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngio.c - stub functions for i/o and memory allocation
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
|
||||
This file provides a location for all input/output. Users which need
|
||||
special handling are expected to write functions which have the same
|
||||
@ -164,7 +164,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_uint_32 length)
|
||||
#else
|
||||
/* this works in MSC also but with lost segment warning */
|
||||
n_data = (png_byte *)data;
|
||||
if ((PNG_BYTEP )n_data == data)
|
||||
if ((png_bytep)n_data == data)
|
||||
#endif
|
||||
{
|
||||
check = fread(n_data, 1, (size_t)length, png_ptr->fp);
|
||||
@ -196,16 +196,19 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_uint_32 length)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function is called to output any data pending writing (normally
|
||||
to disk. After png_flush is called, there should be no data pending
|
||||
writing in any buffers. */
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
void
|
||||
png_flush(png_struct *png_ptr)
|
||||
png_flush(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->output_flush_fn)
|
||||
(*(png_ptr->output_flush_fn))(png_ptr);
|
||||
}
|
||||
|
||||
void
|
||||
png_default_flush(png_struct *png_ptr)
|
||||
png_default_flush(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->fp)
|
||||
fflush(png_ptr->fp);
|
||||
@ -223,19 +226,20 @@ png_default_flush(png_struct *png_ptr)
|
||||
arguments a pointer to a png_struct, a pointer to
|
||||
data to be written, and a 32-bit unsigned int which is
|
||||
the number of bytes to be written. The new write
|
||||
function should call png_error("Error msg")
|
||||
function should call png_error(png_ptr, "Error msg")
|
||||
to exit and output any fatal error messages.
|
||||
flush_data_fn - pointer to a new flush function which takes as its
|
||||
arguments a pointer to a png_struct. After a call to
|
||||
the flush function, there should be no data in any buffers
|
||||
or pending transmission. If the output method doesn't do
|
||||
any buffering of ouput, this parameter can be NULL. If
|
||||
PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng
|
||||
compile time, output_flush_fn will be ignored, although
|
||||
it must be supplied for compatibility. */
|
||||
any buffering of ouput, a function prototype must still be
|
||||
supplied although it doesn't have to do anything. If
|
||||
PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
||||
time, output_flush_fn will be ignored, although it must be
|
||||
supplied for compatibility. */
|
||||
void
|
||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn,
|
||||
png_flush_ptr output_flush_fn)
|
||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
{
|
||||
png_ptr->io_ptr = io_ptr;
|
||||
|
||||
@ -245,10 +249,10 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn
|
||||
png_ptr->write_data_fn = png_default_write_data;
|
||||
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
if (output_flush_fn == NULL)
|
||||
png_ptr->output_flush_fn = png_default_flush;
|
||||
else
|
||||
if (output_flush_fn)
|
||||
png_ptr->output_flush_fn = output_flush_fn;
|
||||
else
|
||||
png_ptr->output_flush_fn = png_default_flush;
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
|
||||
/* It is an error to read while writing a png file */
|
||||
@ -270,7 +274,8 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn
|
||||
To exit and output any fatal error messages the new write
|
||||
function should call png_error(png_ptr, "Error msg"). */
|
||||
void
|
||||
png_set_read_fn(png_struct *png_ptr, void *io_ptr, png_rw_ptr read_data_fn)
|
||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
png_ptr->io_ptr = io_ptr;
|
||||
|
||||
@ -291,8 +296,8 @@ png_set_read_fn(png_struct *png_ptr, void *io_ptr, png_rw_ptr read_data_fn)
|
||||
/* This function returns a pointer to the io_ptr associated with the user
|
||||
functions. The application should free any memory associated with this
|
||||
pointer before png_write_destroy and png_read_destroy are called. */
|
||||
void *
|
||||
png_get_io_ptr(png_struct *png_ptr)
|
||||
png_voidp
|
||||
png_get_io_ptr(png_structp png_ptr)
|
||||
{
|
||||
return png_ptr->io_ptr;
|
||||
}
|
||||
|
174
pngmem.c
174
pngmem.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
|
||||
This file provides a location for all memory allocation. Users which
|
||||
need special memory handling are expected to modify the code in this file
|
||||
@ -13,6 +13,160 @@
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
/* Borland DOS special memory handler */
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* if you change this, be sure to change the one in png.h also */
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
64K. However, zlib may allocate more then 64K if you don't tell
|
||||
it not to. See zconf.h and png.h for more information. zlib does
|
||||
need to allocate exactly 64K, so whatever you call here must
|
||||
have the ability to do that. */
|
||||
|
||||
/* Borland seems to have a problem in DOS mode for exactly 64K.
|
||||
It gives you a segment with an offset of 8 (perhaps to store it's
|
||||
memory stuff). zlib doesn't like this at all, so we have to
|
||||
detect and deal with it. This code should not be needed in
|
||||
Windows or OS/2 modes, and only in 16 bit mode.
|
||||
*/
|
||||
|
||||
png_voidp
|
||||
png_large_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
png_voidp ret;
|
||||
if (!png_ptr || !size)
|
||||
return ((voidp)0);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||
#endif
|
||||
|
||||
if (size == (png_uint_32)(65536L))
|
||||
{
|
||||
if (!png_ptr->offset_table)
|
||||
{
|
||||
/* try to see if we need to do any of this fancy stuff */
|
||||
ret = farmalloc(size);
|
||||
if (!ret || ((long)ret & 0xffff))
|
||||
{
|
||||
int num_blocks;
|
||||
png_uint_32 total_size;
|
||||
png_bytep table;
|
||||
int i;
|
||||
png_byte huge * hptr;
|
||||
|
||||
if (ret)
|
||||
farfree(ret);
|
||||
ret = 0;
|
||||
|
||||
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
|
||||
if (num_blocks < 1)
|
||||
num_blocks = 1;
|
||||
if (png_ptr->zlib_mem_level >= 7)
|
||||
num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
|
||||
else
|
||||
num_blocks++;
|
||||
|
||||
total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks;
|
||||
|
||||
table = farmalloc(total_size);
|
||||
|
||||
if (!table)
|
||||
{
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
}
|
||||
|
||||
if ((long)table & 0xffff)
|
||||
{
|
||||
farfree(table);
|
||||
total_size += (png_uint_32)65536L;
|
||||
}
|
||||
|
||||
table = farmalloc(total_size);
|
||||
|
||||
if (!table)
|
||||
{
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
}
|
||||
|
||||
png_ptr->offset_table = table;
|
||||
png_ptr->offset_table_ptr = farmalloc(
|
||||
num_blocks * sizeof (png_bytep));
|
||||
hptr = (png_byte huge *)table;
|
||||
if ((long)hptr & 0xffff)
|
||||
{
|
||||
hptr = (png_byte huge *)((long)(hptr) & 0xffff0000L);
|
||||
hptr += 65536L;
|
||||
}
|
||||
for (i = 0; i < num_blocks; i++)
|
||||
{
|
||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||
hptr += 65536L;
|
||||
}
|
||||
|
||||
png_ptr->offset_table_number = num_blocks;
|
||||
png_ptr->offset_table_count = 0;
|
||||
png_ptr->offset_table_count_free = 0;
|
||||
}
|
||||
|
||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
|
||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
||||
}
|
||||
}
|
||||
else
|
||||
ret = farmalloc(size);
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* free a pointer allocated by png_large_malloc(). In the default
|
||||
configuration, png_ptr is not used, but is passed in case it
|
||||
is needed. If ptr is NULL, return without taking any action. */
|
||||
void
|
||||
png_large_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (!png_ptr)
|
||||
return;
|
||||
|
||||
if (ptr != NULL)
|
||||
{
|
||||
if (png_ptr->offset_table)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < png_ptr->offset_table_count; i++)
|
||||
{
|
||||
if (ptr == png_ptr->offset_table_ptr[i])
|
||||
{
|
||||
ptr = 0;
|
||||
png_ptr->offset_table_count_free++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)
|
||||
{
|
||||
farfree(png_ptr->offset_table);
|
||||
farfree(png_ptr->offset_table_ptr);
|
||||
png_ptr->offset_table = 0;
|
||||
png_ptr->offset_table_ptr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ptr)
|
||||
farfree(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
#else /* Not the Borland DOS special memory handler */
|
||||
|
||||
/* Allocate memory. For 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
|
||||
@ -34,8 +188,12 @@ png_large_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
ret = farmalloc(size);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
ret = halloc(size, 1);
|
||||
# else
|
||||
ret = malloc(size);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (ret == NULL)
|
||||
@ -59,16 +217,23 @@ png_large_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(ptr);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(ptr);
|
||||
# else
|
||||
free(ptr);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
|
||||
/* Allocate memory. This is called for smallish blocks only It
|
||||
should not get anywhere near 64K. On segmented machines, this
|
||||
must come from the local heap (for zlib). */
|
||||
must come from the local heap (for zlib). Currently, zlib is
|
||||
the only one that uses this, so you should only get one call
|
||||
to this, and that a small block. */
|
||||
void *
|
||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
@ -96,7 +261,8 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
}
|
||||
|
||||
/* Reallocate memory. This will not get near 64K on a
|
||||
even marginally reasonable file. */
|
||||
even marginally reasonable file. This is not used in
|
||||
the current version of the library. */
|
||||
void *
|
||||
png_realloc(png_structp png_ptr, void * ptr, png_uint_32 size,
|
||||
png_uint_32 old_size)
|
||||
|
87
pngpread.c
87
pngpread.c
@ -1,15 +1,17 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
|
||||
void
|
||||
png_process_data(png_structp png_ptr, png_infop info,
|
||||
png_bytep buffer, png_uint_32 buffer_size)
|
||||
@ -110,7 +112,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info)
|
||||
|
||||
png_push_fill_buffer(png_ptr, chunk_start, 8);
|
||||
png_ptr->push_length = png_get_uint_32(chunk_start);
|
||||
memcpy(png_ptr->push_chunk_name, chunk_start + 4, 4);
|
||||
png_memcpy(png_ptr->push_chunk_name, (png_voidp)(chunk_start + 4), 4);
|
||||
png_ptr->have_chunk_header = 1;
|
||||
png_reset_crc(png_ptr);
|
||||
png_calculate_crc(png_ptr, chunk_start + 4, 4);
|
||||
@ -142,7 +144,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info)
|
||||
else
|
||||
#else
|
||||
{
|
||||
png_push_handle_PLTE(png_ptr, info, png_ptr->push_length);
|
||||
png_push_handle_PLTE(png_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
png_ptr->mode = PNG_HAVE_PLTE;
|
||||
@ -316,7 +318,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info)
|
||||
png_ptr->mode == PNG_AFTER_IEND)
|
||||
png_error(png_ptr, "Out of Place tEXt");
|
||||
|
||||
png_push_handle_tEXt(png_ptr, info, png_ptr->push_length);
|
||||
png_push_handle_tEXt(png_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
@ -326,7 +328,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info)
|
||||
png_ptr->mode == PNG_AFTER_IEND)
|
||||
png_error(png_ptr, "Out of Place zTXt");
|
||||
|
||||
png_push_handle_zTXt(png_ptr, info, png_ptr->push_length);
|
||||
png_push_handle_zTXt(png_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
@ -376,7 +378,7 @@ png_push_skip(png_structp png_ptr)
|
||||
png_ptr->skip_length -= save_size;
|
||||
png_ptr->buffer_size -= save_size;
|
||||
png_ptr->save_buffer_size -= save_size;
|
||||
png_ptr->save_buffer_ptr += save_size;
|
||||
png_ptr->save_buffer_ptr += (png_size_t)save_size;
|
||||
}
|
||||
if (png_ptr->skip_length && png_ptr->current_buffer_size)
|
||||
{
|
||||
@ -392,7 +394,7 @@ png_push_skip(png_structp png_ptr)
|
||||
png_ptr->skip_length -= save_size;
|
||||
png_ptr->buffer_size -= save_size;
|
||||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
png_ptr->current_buffer_ptr += (png_size_t)save_size;
|
||||
}
|
||||
if (!png_ptr->skip_length && png_ptr->buffer_size >= 4)
|
||||
{
|
||||
@ -405,7 +407,7 @@ void
|
||||
png_push_fill_buffer(png_structp png_ptr, png_bytep buffer,
|
||||
png_uint_32 length)
|
||||
{
|
||||
png_byte * ptr;
|
||||
png_bytep ptr;
|
||||
|
||||
ptr = buffer;
|
||||
if (png_ptr->save_buffer_size)
|
||||
@ -417,12 +419,12 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer,
|
||||
else
|
||||
save_size = png_ptr->save_buffer_size;
|
||||
|
||||
memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
|
||||
png_memcpy(ptr, png_ptr->save_buffer_ptr, (png_size_t)save_size);
|
||||
length -= save_size;
|
||||
ptr += save_size;
|
||||
ptr += (png_size_t)save_size;
|
||||
png_ptr->buffer_size -= save_size;
|
||||
png_ptr->save_buffer_size -= save_size;
|
||||
png_ptr->save_buffer_ptr += save_size;
|
||||
png_ptr->save_buffer_ptr += (png_size_t)save_size;
|
||||
}
|
||||
if (length && png_ptr->current_buffer_size)
|
||||
{
|
||||
@ -433,10 +435,10 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer,
|
||||
else
|
||||
save_size = png_ptr->current_buffer_size;
|
||||
|
||||
memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
|
||||
png_memcpy(ptr, png_ptr->current_buffer_ptr, (png_size_t)save_size);
|
||||
png_ptr->buffer_size -= save_size;
|
||||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
png_ptr->current_buffer_ptr += (png_size_t)save_size;
|
||||
}
|
||||
}
|
||||
|
||||
@ -448,8 +450,8 @@ png_push_save_buffer(png_structp png_ptr)
|
||||
if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
|
||||
{
|
||||
int i;
|
||||
png_byte * sp;
|
||||
png_byte * dp;
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
|
||||
for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;
|
||||
i < png_ptr->save_buffer_size;
|
||||
@ -463,22 +465,24 @@ png_push_save_buffer(png_structp png_ptr)
|
||||
png_ptr->save_buffer_max)
|
||||
{
|
||||
int new_max;
|
||||
png_byte * old_buffer;
|
||||
png_bytep old_buffer;
|
||||
|
||||
new_max = png_ptr->save_buffer_size +
|
||||
png_ptr->current_buffer_size + 256;
|
||||
new_max = (int)(png_ptr->save_buffer_size +
|
||||
png_ptr->current_buffer_size + 256);
|
||||
old_buffer = png_ptr->save_buffer;
|
||||
png_ptr->save_buffer = (png_byte *)
|
||||
png_ptr->save_buffer = (png_bytep)
|
||||
png_large_malloc(png_ptr, new_max);
|
||||
memcpy(png_ptr->save_buffer, old_buffer,
|
||||
png_ptr->save_buffer_size);
|
||||
png_memcpy(png_ptr->save_buffer, old_buffer,
|
||||
(png_size_t)png_ptr->save_buffer_size);
|
||||
png_large_free(png_ptr, old_buffer);
|
||||
png_ptr->save_buffer_max = new_max;
|
||||
}
|
||||
if (png_ptr->current_buffer_size)
|
||||
{
|
||||
memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
|
||||
png_ptr->current_buffer_ptr, png_ptr->current_buffer_size);
|
||||
png_memcpy(png_ptr->save_buffer +
|
||||
(png_size_t)png_ptr->save_buffer_size,
|
||||
png_ptr->current_buffer_ptr,
|
||||
(png_size_t)png_ptr->current_buffer_size);
|
||||
png_ptr->save_buffer_size += png_ptr->current_buffer_size;
|
||||
png_ptr->current_buffer_size = 0;
|
||||
}
|
||||
@ -511,7 +515,8 @@ png_push_read_idat(png_structp png_ptr)
|
||||
|
||||
png_push_fill_buffer(png_ptr, chunk_start, 8);
|
||||
png_ptr->push_length = png_get_uint_32(chunk_start);
|
||||
memcpy(png_ptr->push_chunk_name, chunk_start + 4, 4);
|
||||
png_memcpy(png_ptr->push_chunk_name,
|
||||
(png_voidp)(chunk_start + 4), 4);
|
||||
png_ptr->have_chunk_header = 1;
|
||||
png_reset_crc(png_ptr);
|
||||
png_calculate_crc(png_ptr, chunk_start + 4, 4);
|
||||
@ -540,7 +545,7 @@ png_push_read_idat(png_structp png_ptr)
|
||||
png_ptr->idat_size -= save_size;
|
||||
png_ptr->buffer_size -= save_size;
|
||||
png_ptr->save_buffer_size -= save_size;
|
||||
png_ptr->save_buffer_ptr += save_size;
|
||||
png_ptr->save_buffer_ptr += (png_size_t)save_size;
|
||||
}
|
||||
if (png_ptr->idat_size && png_ptr->current_buffer_size)
|
||||
{
|
||||
@ -557,7 +562,7 @@ png_push_read_idat(png_structp png_ptr)
|
||||
png_ptr->idat_size -= save_size;
|
||||
png_ptr->buffer_size -= save_size;
|
||||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
png_ptr->current_buffer_ptr += (png_size_t)save_size;
|
||||
}
|
||||
if (!png_ptr->idat_size && png_ptr->buffer_size >= 4)
|
||||
{
|
||||
@ -785,14 +790,14 @@ png_read_push_finish_row(png_structp png_ptr)
|
||||
|
||||
|
||||
void
|
||||
png_push_handle_PLTE(png_structp png_ptr, png_infop info, png_uint_32 length)
|
||||
png_push_handle_PLTE(png_structp png_ptr, png_uint_32 length)
|
||||
{
|
||||
if (length % 3)
|
||||
png_error(png_ptr, "Invalid Palette Chunk");
|
||||
|
||||
png_ptr->num_palette = length / 3;
|
||||
png_ptr->num_palette = (png_uint_16)(length / 3);
|
||||
png_ptr->cur_palette = 0;
|
||||
png_ptr->palette = (png_colorp)png_malloc(png_ptr,
|
||||
png_ptr->palette = (png_colorp)png_large_malloc(png_ptr,
|
||||
png_ptr->num_palette * sizeof (png_color));
|
||||
png_ptr->process_mode = PNG_READ_PLTE_MODE;
|
||||
}
|
||||
@ -828,8 +833,7 @@ png_push_read_plte(png_structp png_ptr, png_infop info)
|
||||
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
void
|
||||
png_push_handle_tEXt(png_structp png_ptr, png_infop info,
|
||||
png_uint_32 length)
|
||||
png_push_handle_tEXt(png_structp png_ptr, png_uint_32 length)
|
||||
{
|
||||
png_ptr->current_text = (png_charp)png_large_malloc(png_ptr, length + 1);
|
||||
png_ptr->current_text[(png_size_t)length] = '\0';
|
||||
@ -855,7 +859,7 @@ png_push_read_text(png_structp png_ptr, png_infop info)
|
||||
png_calculate_crc(png_ptr, (png_bytep)png_ptr->current_text_ptr,
|
||||
text_size);
|
||||
png_ptr->current_text_left -= text_size;
|
||||
png_ptr->current_text_ptr += text_size;
|
||||
png_ptr->current_text_ptr += (png_size_t)text_size;
|
||||
}
|
||||
if (!(png_ptr->current_text_left) && png_ptr->buffer_size >= 4)
|
||||
{
|
||||
@ -882,7 +886,7 @@ png_push_read_text(png_structp png_ptr, png_infop info)
|
||||
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
void
|
||||
png_push_handle_zTXt(png_structp png_ptr, png_infop info,
|
||||
png_push_handle_zTXt(png_structp png_ptr,
|
||||
png_uint_32 length)
|
||||
{
|
||||
png_ptr->current_text = (png_charp)png_large_malloc(png_ptr, length + 1);
|
||||
@ -909,7 +913,7 @@ png_push_read_ztxt(png_structp png_ptr, png_infop info)
|
||||
png_calculate_crc(png_ptr, (png_bytep)png_ptr->current_text_ptr,
|
||||
text_size);
|
||||
png_ptr->current_text_left -= text_size;
|
||||
png_ptr->current_text_ptr += text_size;
|
||||
png_ptr->current_text_ptr += (png_size_t)text_size;
|
||||
}
|
||||
if (!(png_ptr->current_text_left) && png_ptr->buffer_size >= 4)
|
||||
{
|
||||
@ -923,8 +927,6 @@ png_push_read_ztxt(png_structp png_ptr, png_infop info)
|
||||
key = png_ptr->current_text;
|
||||
png_ptr->current_text = 0;
|
||||
|
||||
text = NULL;
|
||||
|
||||
for (text = key; *text; text++)
|
||||
/* empty loop */ ;
|
||||
|
||||
@ -971,7 +973,7 @@ png_push_read_ztxt(png_structp png_ptr, png_infop info)
|
||||
{
|
||||
if (!text)
|
||||
{
|
||||
text = (png_charp)png_malloc(png_ptr,
|
||||
text = (png_charp)png_large_malloc(png_ptr,
|
||||
png_ptr->zbuf_size - png_ptr->zstream->avail_out +
|
||||
key_size + 1);
|
||||
png_memcpy(text + (png_size_t)key_size, png_ptr->zbuf,
|
||||
@ -1073,7 +1075,7 @@ png_push_read_end(png_structp png_ptr, png_infop info)
|
||||
|
||||
png_push_fill_buffer(png_ptr, chunk_start, 8);
|
||||
png_ptr->push_length = png_get_uint_32(chunk_start);
|
||||
memcpy(png_ptr->push_chunk_name, chunk_start + 4, 4);
|
||||
png_memcpy(png_ptr->push_chunk_name, (png_voidp)(chunk_start + 4), 4);
|
||||
png_ptr->have_chunk_header = 1;
|
||||
png_reset_crc(png_ptr);
|
||||
png_calculate_crc(png_ptr, chunk_start + 4, 4);
|
||||
@ -1173,7 +1175,7 @@ png_push_read_end(png_structp png_ptr, png_infop info)
|
||||
png_ptr->mode == PNG_AFTER_IEND)
|
||||
png_error(png_ptr, "Out of Place tEXt");
|
||||
|
||||
png_push_handle_tEXt(png_ptr, info, png_ptr->push_length);
|
||||
png_push_handle_tEXt(png_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
@ -1183,7 +1185,7 @@ png_push_read_end(png_structp png_ptr, png_infop info)
|
||||
png_ptr->mode == PNG_AFTER_IEND)
|
||||
png_error(png_ptr, "Out of Place zTXt");
|
||||
|
||||
png_push_handle_zTXt(png_ptr, info, png_ptr->push_length);
|
||||
png_push_handle_zTXt(png_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
@ -1214,6 +1216,9 @@ void
|
||||
png_progressive_combine_row (png_structp png_ptr,
|
||||
png_bytep old_row, png_bytep new_row)
|
||||
{
|
||||
if (new_row)
|
||||
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
|
||||
}
|
||||
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
|
40
pngrcb.c
40
pngrcb.c
@ -1,9 +1,9 @@
|
||||
/* pngrcb.c - callbacks while reading a png file
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -20,11 +20,11 @@ png_read_IHDR(png_structp png_ptr, png_infop info,
|
||||
|
||||
info->width = width;
|
||||
info->height = height;
|
||||
info->bit_depth = bit_depth;
|
||||
info->color_type = color_type;
|
||||
info->compression_type = compression_type;
|
||||
info->filter_type = filter_type;
|
||||
info->interlace_type = interlace_type;
|
||||
info->bit_depth = (png_byte)bit_depth;
|
||||
info->color_type =(png_byte) color_type;
|
||||
info->compression_type = (png_byte)compression_type;
|
||||
info->filter_type = (png_byte)filter_type;
|
||||
info->interlace_type = (png_byte)interlace_type;
|
||||
if (info->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
info->channels = 1;
|
||||
else if (info->color_type & PNG_COLOR_MASK_COLOR)
|
||||
@ -33,7 +33,7 @@ png_read_IHDR(png_structp png_ptr, png_infop info,
|
||||
info->channels = 1;
|
||||
if (info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
info->channels++;
|
||||
info->pixel_depth = info->channels * info->bit_depth;
|
||||
info->pixel_depth = (png_byte)(info->channels * info->bit_depth);
|
||||
info->rowbytes = ((info->width * info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ png_read_PLTE(png_structp png_ptr, png_infop info,
|
||||
return;
|
||||
|
||||
info->palette = palette;
|
||||
info->num_palette = num;
|
||||
info->num_palette = (png_uint_16)num;
|
||||
info->valid |= PNG_INFO_PLTE;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ png_read_tRNS(png_structp png_ptr, png_infop info,
|
||||
png_memcpy(&(info->trans_values), trans_values,
|
||||
sizeof(png_color_16));
|
||||
}
|
||||
info->num_trans = num_trans;
|
||||
info->num_trans = (png_uint_16)num_trans;
|
||||
info->valid |= PNG_INFO_tRNS;
|
||||
}
|
||||
#endif
|
||||
@ -152,7 +152,7 @@ png_read_pHYs(png_structp png_ptr, png_infop info,
|
||||
|
||||
info->x_pixels_per_unit = res_x;
|
||||
info->y_pixels_per_unit = res_y;
|
||||
info->phys_unit_type = unit_type;
|
||||
info->phys_unit_type = (png_byte)unit_type;
|
||||
info->valid |= PNG_INFO_pHYs;
|
||||
}
|
||||
#endif
|
||||
@ -167,7 +167,7 @@ png_read_oFFs(png_structp png_ptr, png_infop info,
|
||||
|
||||
info->x_offset = offset_x;
|
||||
info->y_offset = offset_y;
|
||||
info->offset_unit_type = unit_type;
|
||||
info->offset_unit_type = (png_byte)unit_type;
|
||||
info->valid |= PNG_INFO_oFFs;
|
||||
}
|
||||
#endif
|
||||
@ -201,15 +201,21 @@ png_read_zTXt(png_structp png_ptr, png_infop info,
|
||||
|
||||
old_max = info->max_text;
|
||||
info->max_text = info->num_text + 16;
|
||||
info->text = (png_textp)png_realloc(png_ptr,
|
||||
info->text,
|
||||
info->max_text * sizeof (png_text),
|
||||
old_max * sizeof (png_text));
|
||||
{
|
||||
png_textp old_text;
|
||||
|
||||
old_text = info->text;
|
||||
info->text = (png_textp)png_large_malloc(png_ptr,
|
||||
info->max_text * sizeof (png_text));
|
||||
png_memcpy(info->text, old_text,
|
||||
(png_size_t)(old_max * sizeof (png_text)));
|
||||
png_large_free(png_ptr, old_text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info->max_text = info->num_text + 16;
|
||||
info->text = (png_textp)png_malloc(png_ptr,
|
||||
info->text = (png_textp)png_large_malloc(png_ptr,
|
||||
info->max_text * sizeof (png_text));
|
||||
info->num_text = 0;
|
||||
}
|
||||
|
60
pngread.c
60
pngread.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngread.c - read a png file
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -36,7 +36,7 @@ png_read_init(png_structp png_ptr)
|
||||
png_ptr->zstream = (z_stream *)png_malloc(png_ptr, sizeof (z_stream));
|
||||
png_ptr->zstream->zalloc = png_zalloc;
|
||||
png_ptr->zstream->zfree = png_zfree;
|
||||
png_ptr->zstream->opaque = (voidp)png_ptr;
|
||||
png_ptr->zstream->opaque = (voidpf)png_ptr;
|
||||
inflateInit(png_ptr->zstream);
|
||||
png_ptr->zstream->next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream->avail_out = (uInt)png_ptr->zbuf_size;
|
||||
@ -630,23 +630,13 @@ png_read_destroy(png_structp png_ptr, png_infop info, png_infop end_info)
|
||||
|
||||
if (info)
|
||||
{
|
||||
if (png_ptr->do_free & PNG_FREE_PALETTE)
|
||||
png_free(png_ptr, info->palette);
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_bKGD_SUPPORTED)
|
||||
if (png_ptr->do_free & PNG_FREE_TRANS)
|
||||
png_free(png_ptr, info->trans);
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
if (png_ptr->do_free & PNG_FREE_HIST)
|
||||
png_free(png_ptr, info->hist);
|
||||
#endif
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
for (i = 0; i < info->num_text; i++)
|
||||
{
|
||||
png_large_free(png_ptr, info->text[i].key);
|
||||
}
|
||||
|
||||
png_free(png_ptr, info->text);
|
||||
png_large_free(png_ptr, info->text);
|
||||
#endif
|
||||
png_memset(info, 0, sizeof(png_info));
|
||||
}
|
||||
@ -659,7 +649,7 @@ png_read_destroy(png_structp png_ptr, png_infop info, png_infop end_info)
|
||||
png_large_free(png_ptr, end_info->text[i].key);
|
||||
}
|
||||
|
||||
png_free(png_ptr, end_info->text);
|
||||
png_large_free(png_ptr, end_info->text);
|
||||
#endif
|
||||
png_memset(end_info, 0, sizeof(png_info));
|
||||
}
|
||||
@ -669,56 +659,58 @@ png_read_destroy(png_structp png_ptr, png_infop info, png_infop end_info)
|
||||
png_large_free(png_ptr, png_ptr->prev_row);
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
png_large_free(png_ptr, png_ptr->palette_lookup);
|
||||
png_free(png_ptr, png_ptr->dither_index);
|
||||
png_large_free(png_ptr, png_ptr->dither_index);
|
||||
#endif
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->gamma_table);
|
||||
png_large_free(png_ptr, png_ptr->gamma_table);
|
||||
#endif
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->gamma_from_1);
|
||||
png_free(png_ptr, png_ptr->gamma_to_1);
|
||||
png_large_free(png_ptr, png_ptr->gamma_from_1);
|
||||
png_large_free(png_ptr, png_ptr->gamma_to_1);
|
||||
#endif
|
||||
if (png_ptr->do_free & PNG_FREE_PALETTE)
|
||||
png_large_free(png_ptr, png_ptr->palette);
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_bKGD_SUPPORTED)
|
||||
if (png_ptr->do_free & PNG_FREE_TRANS)
|
||||
png_large_free(png_ptr, png_ptr->trans);
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
if (png_ptr->do_free & PNG_FREE_HIST)
|
||||
png_large_free(png_ptr, png_ptr->hist);
|
||||
#endif
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
if (png_ptr->gamma_16_table)
|
||||
{
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_table[i]);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_table[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->gamma_16_table);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_table);
|
||||
if (png_ptr->gamma_16_from_1)
|
||||
{
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_from_1[i]);
|
||||
}
|
||||
}
|
||||
png_free(png_ptr, png_ptr->gamma_16_from_1);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_from_1);
|
||||
if (png_ptr->gamma_16_to_1)
|
||||
{
|
||||
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_to_1[i]);
|
||||
}
|
||||
}
|
||||
png_free(png_ptr, png_ptr->gamma_16_to_1);
|
||||
png_large_free(png_ptr, png_ptr->gamma_16_to_1);
|
||||
#endif
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->trans);
|
||||
#endif
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->hist);
|
||||
#endif
|
||||
if (!png_ptr->user_palette)
|
||||
png_free(png_ptr, png_ptr->palette);
|
||||
|
||||
inflateEnd(png_ptr->zstream);
|
||||
png_free(png_ptr, png_ptr->zstream);
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->save_buffer);
|
||||
png_large_free(png_ptr, png_ptr->save_buffer);
|
||||
#endif
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
|
||||
png_memset(png_ptr, 0, sizeof (png_struct));
|
||||
|
366
pngrtran.c
366
pngrtran.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for png readers
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -21,8 +21,8 @@ png_set_background(png_structp png_ptr,
|
||||
png_memcpy(&(png_ptr->background), background_color,
|
||||
sizeof(png_color_16));
|
||||
png_ptr->background_gamma = (float)background_gamma;
|
||||
png_ptr->background_gamma_type = background_gamma_code;
|
||||
png_ptr->background_expand = need_expand;
|
||||
png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
|
||||
png_ptr->background_expand = (png_byte)need_expand;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -63,10 +63,10 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
{
|
||||
int i;
|
||||
|
||||
png_ptr->dither_index = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->dither_index = (png_bytep)png_large_malloc(png_ptr,
|
||||
num_palette * sizeof (png_byte));
|
||||
for (i = 0; i < num_palette; i++)
|
||||
png_ptr->dither_index[i] = i;
|
||||
png_ptr->dither_index[i] = (png_byte)i;
|
||||
}
|
||||
|
||||
if (num_palette > maximum_colors)
|
||||
@ -80,11 +80,11 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
png_bytep sort;
|
||||
|
||||
/* initialize an array to sort colors */
|
||||
sort = (png_bytep)png_malloc(png_ptr, num_palette * sizeof (png_byte));
|
||||
sort = (png_bytep)png_large_malloc(png_ptr, num_palette * sizeof (png_byte));
|
||||
|
||||
/* initialize the sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
sort[i] = i;
|
||||
sort[i] = (png_byte)i;
|
||||
|
||||
/* find the least used palette entries by starting a
|
||||
bubble sort, and running it until we have sorted
|
||||
@ -155,8 +155,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
palette[j] = palette[i];
|
||||
palette[i] = tmp_color;
|
||||
/* indicate where the color went */
|
||||
png_ptr->dither_index[j] = i;
|
||||
png_ptr->dither_index[i] = j;
|
||||
png_ptr->dither_index[j] = (png_byte)i;
|
||||
png_ptr->dither_index[i] = (png_byte)j;
|
||||
}
|
||||
}
|
||||
/* find closest color for those colors we are not
|
||||
@ -186,11 +186,11 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
}
|
||||
}
|
||||
/* point to closest color */
|
||||
png_ptr->dither_index[i] = min_j;
|
||||
png_ptr->dither_index[i] = (png_byte)min_j;
|
||||
}
|
||||
}
|
||||
}
|
||||
png_free(png_ptr, sort);
|
||||
png_large_free(png_ptr, sort);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -210,19 +210,19 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
/* which original index points to this palette color */
|
||||
|
||||
/* initialize palette index arrays */
|
||||
index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||
index_to_palette = (png_bytep)png_large_malloc(png_ptr,
|
||||
num_palette * sizeof (png_byte));
|
||||
palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||
palette_to_index = (png_bytep)png_large_malloc(png_ptr,
|
||||
num_palette * sizeof (png_byte));
|
||||
|
||||
/* initialize the sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
index_to_palette[i] = i;
|
||||
palette_to_index[i] = i;
|
||||
index_to_palette[i] = (png_byte)i;
|
||||
palette_to_index[i] = (png_byte)i;
|
||||
}
|
||||
|
||||
hash = (png_dsortpp)png_malloc(png_ptr, 769 * sizeof (png_dsortp));
|
||||
hash = (png_dsortpp)png_large_malloc(png_ptr, 769 * sizeof (png_dsortp));
|
||||
for (i = 0; i < 769; i++)
|
||||
hash[i] = (png_dsortp)0;
|
||||
/* png_memset(hash, 0, 769 * sizeof (png_dsortp)); */
|
||||
@ -255,10 +255,10 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
{
|
||||
png_dsortp t;
|
||||
|
||||
t = png_malloc(png_ptr, sizeof (png_dsort));
|
||||
t = png_large_malloc(png_ptr, sizeof (png_dsort));
|
||||
t->next = hash[d];
|
||||
t->left = i;
|
||||
t->right = j;
|
||||
t->left = (png_byte)i;
|
||||
t->right = (png_byte)j;
|
||||
hash[d] = t;
|
||||
}
|
||||
}
|
||||
@ -313,8 +313,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
palette_to_index[index_to_palette[j]] =
|
||||
palette_to_index[num_new_palette];
|
||||
|
||||
index_to_palette[j] = num_new_palette;
|
||||
palette_to_index[num_new_palette] = j;
|
||||
index_to_palette[j] = (png_byte)num_new_palette;
|
||||
palette_to_index[num_new_palette] = (png_byte)j;
|
||||
}
|
||||
if (num_new_palette <= maximum_colors)
|
||||
break;
|
||||
@ -336,7 +336,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
png_dsortp t;
|
||||
|
||||
t = p->next;
|
||||
png_free(png_ptr, p);
|
||||
png_large_free(png_ptr, p);
|
||||
p = t;
|
||||
}
|
||||
}
|
||||
@ -344,9 +344,9 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
}
|
||||
max_d += 96;
|
||||
}
|
||||
png_free(png_ptr, hash);
|
||||
png_free(png_ptr, palette_to_index);
|
||||
png_free(png_ptr, index_to_palette);
|
||||
png_large_free(png_ptr, hash);
|
||||
png_large_free(png_ptr, palette_to_index);
|
||||
png_large_free(png_ptr, index_to_palette);
|
||||
}
|
||||
num_palette = maximum_colors;
|
||||
}
|
||||
@ -355,7 +355,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
png_ptr->palette = palette;
|
||||
png_ptr->user_palette = 1;
|
||||
}
|
||||
png_ptr->num_palette = num_palette;
|
||||
png_ptr->num_palette = (png_uint_16)num_palette;
|
||||
|
||||
if (full_dither)
|
||||
{
|
||||
@ -415,8 +415,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
|
||||
if (d < distance[index])
|
||||
{
|
||||
distance[index] = d;
|
||||
png_ptr->palette_lookup[index] = i;
|
||||
distance[index] = (png_byte)d;
|
||||
png_ptr->palette_lookup[index] = (png_byte)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -485,13 +485,13 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
switch (png_ptr->bit_depth)
|
||||
{
|
||||
case 1:
|
||||
png_ptr->background.gray *= 0xff;
|
||||
png_ptr->background.gray *= (png_byte)0xff;
|
||||
break;
|
||||
case 2:
|
||||
png_ptr->background.gray *= 0x55;
|
||||
png_ptr->background.gray *= (png_byte)0x55;
|
||||
break;
|
||||
case 4:
|
||||
png_ptr->background.gray *= 0x11;
|
||||
png_ptr->background.gray *= (png_byte)0x11;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -672,7 +672,8 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
info_ptr->channels = 1;
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
info_ptr->channels++;
|
||||
info_ptr->pixel_depth = info_ptr->channels * info_ptr->bit_depth;
|
||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
|
||||
info_ptr->bit_depth);
|
||||
info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
|
||||
}
|
||||
|
||||
@ -796,7 +797,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
shift = 7 - (int)((row_info->width + 7) & 7);
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
*dp = (*sp >> shift) & 0x1;
|
||||
*dp = (png_byte)((*sp >> shift) & 0x1);
|
||||
if (shift == 7)
|
||||
{
|
||||
shift = 0;
|
||||
@ -817,7 +818,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
shift = (int)((3 - ((row_info->width + 3) & 3)) << 1);
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
*dp = (*sp >> shift) & 0x3;
|
||||
*dp = (png_byte)((*sp >> shift) & 0x3);
|
||||
if (shift == 6)
|
||||
{
|
||||
shift = 0;
|
||||
@ -837,7 +838,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
shift = (int)((1 - ((row_info->width + 1) & 1)) << 2);
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
*dp = (*sp >> shift) & 0xf;
|
||||
*dp = (png_byte)((*sp >> shift) & 0xf);
|
||||
if (shift == 4)
|
||||
{
|
||||
shift = 0;
|
||||
@ -852,7 +853,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = 8 * row_info->channels;
|
||||
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
|
||||
row_info->rowbytes = row_info->width * row_info->channels;
|
||||
}
|
||||
}
|
||||
@ -896,8 +897,8 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (i = 0; i < channels; i++)
|
||||
{
|
||||
if (shift[i] <= 0)
|
||||
shift[i] = 0;
|
||||
if (shift[(png_size_t)i] <= 0)
|
||||
shift[(png_size_t)i] = 0;
|
||||
else
|
||||
value = 1;
|
||||
}
|
||||
@ -922,7 +923,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_byte mask;
|
||||
mask = (png_byte)(((int)0xf0 >> shift[0]) & (int)0xf0) |
|
||||
((int)0xf >> shift[0]);
|
||||
(png_byte)((int)0xf >> shift[0]);
|
||||
for (bp = row, i = 0;
|
||||
i < row_info->rowbytes;
|
||||
i++, bp++)
|
||||
@ -955,10 +956,10 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (c = 0; c < row_info->channels; c++, bp += 2)
|
||||
{
|
||||
value = (*bp << 8) + *(bp + 1);
|
||||
value = (png_uint_16)((*bp << 8) + *(bp + 1));
|
||||
value >>= shift[c];
|
||||
*bp = value >> 8;
|
||||
*(bp + 1) = value & 0xff;
|
||||
*bp = (png_byte)(value >> 8);
|
||||
*(bp + 1) = (png_byte)(value & 0xff);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -991,7 +992,7 @@ png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
dp++;
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = 8 * row_info->channels;
|
||||
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
|
||||
row_info->rowbytes = row_info->width * row_info->channels;
|
||||
}
|
||||
}
|
||||
@ -1125,9 +1126,10 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
}
|
||||
}
|
||||
row_info->channels += 2;
|
||||
row_info->channels += (png_byte)2;
|
||||
row_info->color_type |= PNG_COLOR_MASK_COLOR;
|
||||
row_info->pixel_depth = row_info->channels * row_info->bit_depth;
|
||||
row_info->pixel_depth = (png_byte)(row_info->channels *
|
||||
row_info->bit_depth);
|
||||
row_info->rowbytes = ((row_info->width *
|
||||
row_info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
@ -1175,9 +1177,9 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
|
||||
|
||||
for (i = 0, v = 0; i < num_palette; i++, v += color_inc)
|
||||
{
|
||||
palette[i].red = v;
|
||||
palette[i].green = v;
|
||||
palette[i].blue = v;
|
||||
palette[i].red = (png_byte)v;
|
||||
palette[i].green = (png_byte)v;
|
||||
palette[i].blue = (png_byte)v;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1262,9 +1264,9 @@ png_correct_palette(png_structp png_ptr, png_colorp palette,
|
||||
{
|
||||
if (palette[i].red == png_ptr->trans_values.gray)
|
||||
{
|
||||
palette[i].red = back;
|
||||
palette[i].green = back;
|
||||
palette[i].blue = back;
|
||||
palette[i].red = (png_byte)back;
|
||||
palette[i].green = (png_byte)back;
|
||||
palette[i].blue = (png_byte)back;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1384,8 +1386,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
if (((*sp >> shift) & 0x1) ==
|
||||
trans_values->gray)
|
||||
{
|
||||
*sp &= ((0x7f7f >> (7 - shift)) & 0xff);
|
||||
*sp |= (background->gray << shift);
|
||||
*sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(background->gray << shift);
|
||||
}
|
||||
if (!shift)
|
||||
{
|
||||
@ -1406,8 +1408,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
if (((*sp >> shift) & 0x3) ==
|
||||
trans_values->gray)
|
||||
{
|
||||
*sp &= ((0x3f3f >> (6 - shift)) & 0xff);
|
||||
*sp |= (background->gray << shift);
|
||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(background->gray << shift);
|
||||
}
|
||||
if (!shift)
|
||||
{
|
||||
@ -1428,8 +1430,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
if (((*sp >> shift) & 0xf) ==
|
||||
trans_values->gray)
|
||||
{
|
||||
*sp &= ((0xf0f >> (4 - shift)) & 0xff);
|
||||
*sp |= (background->gray << shift);
|
||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(background->gray << shift);
|
||||
}
|
||||
if (!shift)
|
||||
{
|
||||
@ -1484,19 +1486,19 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_uint_16 v;
|
||||
|
||||
v = ((png_uint_16)(*sp) << 8) +
|
||||
(png_uint_16)(*(sp + 1));
|
||||
v = (png_uint_16)(((png_uint_16)(*sp) << 8) +
|
||||
(png_uint_16)(*(sp + 1)));
|
||||
if (v == trans_values->gray)
|
||||
{
|
||||
*sp = (background->gray >> 8) & 0xff;
|
||||
*(sp + 1) = background->gray & 0xff;
|
||||
*sp = (png_byte)((background->gray >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(background->gray & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
v = gamma_16[
|
||||
*(sp + 1) >> gamma_shift][*sp];
|
||||
*sp = (v >> 8) & 0xff;
|
||||
*(sp + 1) = v & 0xff;
|
||||
*sp = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(v & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1508,12 +1510,12 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_uint_16 v;
|
||||
|
||||
v = ((png_uint_16)(*sp) << 8) +
|
||||
(png_uint_16)(*(sp + 1));
|
||||
v = (png_uint_16)(((png_uint_16)(*sp) << 8) +
|
||||
(png_uint_16)(*(sp + 1)));
|
||||
if (v == trans_values->gray)
|
||||
{
|
||||
*sp = (background->gray >> 8) & 0xff;
|
||||
*(sp + 1) = background->gray & 0xff;
|
||||
*sp = (png_byte)((background->gray >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(background->gray & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1575,38 +1577,38 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_uint_16 r, g, b;
|
||||
|
||||
r = ((png_uint_16)(*sp) << 8) +
|
||||
(png_uint_16)(*(sp + 1));
|
||||
g = ((png_uint_16)(*(sp + 2)) << 8) +
|
||||
(png_uint_16)(*(sp + 3));
|
||||
b = ((png_uint_16)(*(sp + 4)) << 8) +
|
||||
(png_uint_16)(*(sp + 5));
|
||||
r = (png_uint_16)(((png_uint_16)(*sp) << 8) +
|
||||
(png_uint_16)(*(sp + 1)));
|
||||
g = (png_uint_16)(((png_uint_16)(*(sp + 2)) << 8) +
|
||||
(png_uint_16)(*(sp + 3)));
|
||||
b = (png_uint_16)(((png_uint_16)(*(sp + 4)) << 8) +
|
||||
(png_uint_16)(*(sp + 5)));
|
||||
if (r == trans_values->red &&
|
||||
g == trans_values->green &&
|
||||
b == trans_values->blue)
|
||||
{
|
||||
*sp = (background->red >> 8) & 0xff;
|
||||
*(sp + 1) = background->red & 0xff;
|
||||
*(sp + 2) = (background->green >> 8) & 0xff;
|
||||
*(sp + 3) = background->green & 0xff;
|
||||
*(sp + 4) = (background->blue >> 8) & 0xff;
|
||||
*(sp + 5) = background->blue & 0xff;
|
||||
*sp = (png_byte)((background->red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(background->red & 0xff);
|
||||
*(sp + 2) = (png_byte)((background->green >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(background->green & 0xff);
|
||||
*(sp + 4) = (png_byte)((background->blue >> 8) & 0xff);
|
||||
*(sp + 5) = (png_byte)(background->blue & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_uint_16 v;
|
||||
v = gamma_16[
|
||||
*(sp + 1) >> gamma_shift][*sp];
|
||||
*sp = (v >> 8) & 0xff;
|
||||
*(sp + 1) = v & 0xff;
|
||||
*sp = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(v & 0xff);
|
||||
v = gamma_16[
|
||||
*(sp + 3) >> gamma_shift][*(sp + 2)];
|
||||
*(sp + 2) = (v >> 8) & 0xff;
|
||||
*(sp + 3) = v & 0xff;
|
||||
*(sp + 2) = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(v & 0xff);
|
||||
v = gamma_16[
|
||||
*(sp + 5) >> gamma_shift][*(sp + 4)];
|
||||
*(sp + 4) = (v >> 8) & 0xff;
|
||||
*(sp + 5) = v & 0xff;
|
||||
*(sp + 4) = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 5) = (png_byte)(v & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1618,22 +1620,22 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_uint_16 r, g, b;
|
||||
|
||||
r = ((png_uint_16)(*sp) << 8) +
|
||||
(png_uint_16)(*(sp + 1));
|
||||
g = ((png_uint_16)(*(sp + 2)) << 8) +
|
||||
(png_uint_16)(*(sp + 3));
|
||||
b = ((png_uint_16)(*(sp + 4)) << 8) +
|
||||
(png_uint_16)(*(sp + 5));
|
||||
r = (png_uint_16)(((png_uint_16)(*sp) << 8) +
|
||||
(png_uint_16)(*(sp + 1)));
|
||||
g = (png_uint_16)(((png_uint_16)(*(sp + 2)) << 8) +
|
||||
(png_uint_16)(*(sp + 3)));
|
||||
b = (png_uint_16)(((png_uint_16)(*(sp + 4)) << 8) +
|
||||
(png_uint_16)(*(sp + 5)));
|
||||
if (r == trans_values->red &&
|
||||
g == trans_values->green &&
|
||||
b == trans_values->blue)
|
||||
{
|
||||
*sp = (background->red >> 8) & 0xff;
|
||||
*(sp + 1) = background->red & 0xff;
|
||||
*(sp + 2) = (background->green >> 8) & 0xff;
|
||||
*(sp + 3) = background->green & 0xff;
|
||||
*(sp + 4) = (background->blue >> 8) & 0xff;
|
||||
*(sp + 5) = background->blue & 0xff;
|
||||
*sp = (png_byte)((background->red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(background->red & 0xff);
|
||||
*(sp + 2) = (png_byte)((background->green >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(background->green & 0xff);
|
||||
*(sp + 4) = (png_byte)((background->blue >> 8) & 0xff);
|
||||
*(sp + 5) = (png_byte)(background->blue & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1669,9 +1671,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
png_uint_16 v;
|
||||
|
||||
v = gamma_to_1[*sp];
|
||||
v = ((png_uint_16)(v) * a +
|
||||
v = (png_uint_16)(((png_uint_16)(v) * a +
|
||||
(png_uint_16)background_1->gray *
|
||||
(255 - a) + 127) / 255;
|
||||
(255 - a) + 127) / 255);
|
||||
*dp = gamma_from_1[v];
|
||||
}
|
||||
}
|
||||
@ -1696,9 +1698,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
else
|
||||
{
|
||||
*dp = ((png_uint_16)(*sp) * a +
|
||||
*dp = (png_byte)(((png_uint_16)(*sp) * a +
|
||||
(png_uint_16)background_1->gray *
|
||||
(255 - a) + 127) / 255;
|
||||
(255 - a) + 127) / 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1715,8 +1717,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_uint_16 a;
|
||||
|
||||
a = ((png_uint_16)(*(sp + 2)) << 8) +
|
||||
(png_uint_16)(*(sp + 3));
|
||||
a = (png_uint_16)(((png_uint_16)(*(sp + 2)) << 8) +
|
||||
(png_uint_16)(*(sp + 3)));
|
||||
if (a == (png_uint_16)0xffff)
|
||||
{
|
||||
png_uint_32 v;
|
||||
@ -1728,8 +1730,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
else if (a == 0)
|
||||
{
|
||||
*dp = (background->gray >> 8) & 0xff;
|
||||
*(dp + 1) = background->gray & 0xff;
|
||||
*dp = (png_byte)((background->gray >> 8) & 0xff);
|
||||
*(dp + 1) = (png_byte)(background->gray & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1757,16 +1759,16 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_uint_16 a;
|
||||
|
||||
a = ((png_uint_16)(*(sp + 2)) << 8) +
|
||||
(png_uint_16)(*(sp + 3));
|
||||
a = (png_uint_16)(((png_uint_16)(*(sp + 2)) << 8) +
|
||||
(png_uint_16)(*(sp + 3)));
|
||||
if (a == (png_uint_16)0xffff)
|
||||
{
|
||||
png_memcpy(dp, sp, 2);
|
||||
}
|
||||
else if (a == 0)
|
||||
{
|
||||
*dp = (background->gray >> 8) & 0xff;
|
||||
*(dp + 1) = background->gray & 0xff;
|
||||
*dp = (png_byte)((background->gray >> 8) & 0xff);
|
||||
*(dp + 1) = (png_byte)(background->gray & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1819,19 +1821,19 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
png_uint_16 v;
|
||||
|
||||
v = gamma_to_1[*sp];
|
||||
v = ((png_uint_16)(v) * a +
|
||||
v = (png_uint_16)(((png_uint_16)(v) * a +
|
||||
(png_uint_16)background_1->red *
|
||||
(255 - a) + 127) / 255;
|
||||
(255 - a) + 127) / 255);
|
||||
*dp = gamma_from_1[v];
|
||||
v = gamma_to_1[*(sp + 1)];
|
||||
v = ((png_uint_16)(v) * a +
|
||||
v = (png_uint_16)(((png_uint_16)(v) * a +
|
||||
(png_uint_16)background_1->green *
|
||||
(255 - a) + 127) / 255;
|
||||
(255 - a) + 127) / 255);
|
||||
*(dp + 1) = gamma_from_1[v];
|
||||
v = gamma_to_1[*(sp + 2)];
|
||||
v = ((png_uint_16)(v) * a +
|
||||
v = (png_uint_16)(((png_uint_16)(v) * a +
|
||||
(png_uint_16)background_1->blue *
|
||||
(255 - a) + 127) / 255;
|
||||
(255 - a) + 127) / 255);
|
||||
*(dp + 2) = gamma_from_1[v];
|
||||
}
|
||||
}
|
||||
@ -1860,15 +1862,15 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
else
|
||||
{
|
||||
*dp = ((png_uint_16)(*sp) * a +
|
||||
*dp = (png_byte)(((png_uint_16)(*sp) * a +
|
||||
(png_uint_16)background->red *
|
||||
(255 - a) + 127) / 255;
|
||||
*(dp + 1) = ((png_uint_16)(*(sp + 1)) * a +
|
||||
(255 - a) + 127) / 255);
|
||||
*(dp + 1) = (png_byte)(((png_uint_16)(*(sp + 1)) * a +
|
||||
(png_uint_16)background->green *
|
||||
(255 - a) + 127) / 255;
|
||||
*(dp + 2) = ((png_uint_16)(*(sp + 2)) * a +
|
||||
(255 - a) + 127) / 255);
|
||||
*(dp + 2) = (png_byte)(((png_uint_16)(*(sp + 2)) * a +
|
||||
(png_uint_16)background->blue *
|
||||
(255 - a) + 127) / 255;
|
||||
(255 - a) + 127) / 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1884,33 +1886,33 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_uint_16 a;
|
||||
|
||||
a = ((png_uint_16)(*(sp + 6)) << 8) +
|
||||
(png_uint_16)(*(sp + 7));
|
||||
a = (png_uint_16)(((png_uint_16)(*(sp + 6)) << 8) +
|
||||
(png_uint_16)(*(sp + 7)));
|
||||
if (a == (png_uint_16)0xffff)
|
||||
{
|
||||
png_uint_16 v;
|
||||
|
||||
v = gamma_16[
|
||||
*(sp + 1) >> gamma_shift][*sp];
|
||||
*dp = (v >> 8) & 0xff;
|
||||
*(dp + 1) = v & 0xff;
|
||||
*dp = (png_byte)((v >> 8) & 0xff);
|
||||
*(dp + 1) = (png_byte)(v & 0xff);
|
||||
v = gamma_16[
|
||||
*(sp + 3) >> gamma_shift][*(sp + 2)];
|
||||
*(dp + 2) = (v >> 8) & 0xff;
|
||||
*(dp + 3) = v & 0xff;
|
||||
*(dp + 2) = (png_byte)((v >> 8) & 0xff);
|
||||
*(dp + 3) = (png_byte)(v & 0xff);
|
||||
v = gamma_16[
|
||||
*(sp + 5) >> gamma_shift][*(sp + 4)];
|
||||
*(dp + 4) = (v >> 8) & 0xff;
|
||||
*(dp + 5) = v & 0xff;
|
||||
*(dp + 4) = (png_byte)((v >> 8) & 0xff);
|
||||
*(dp + 5) = (png_byte)(v & 0xff);
|
||||
}
|
||||
else if (a == 0)
|
||||
{
|
||||
*dp = (background->red >> 8) & 0xff;
|
||||
*(dp + 1) = background->red & 0xff;
|
||||
*(dp + 2) = (background->green >> 8) & 0xff;
|
||||
*(dp + 3) = background->green & 0xff;
|
||||
*(dp + 4) = (background->blue >> 8) & 0xff;
|
||||
*(dp + 5) = background->blue & 0xff;
|
||||
*dp = (png_byte)((background->red >> 8) & 0xff);
|
||||
*(dp + 1) = (png_byte)(background->red & 0xff);
|
||||
*(dp + 2) = (png_byte)((background->green >> 8) & 0xff);
|
||||
*(dp + 3) = (png_byte)(background->green & 0xff);
|
||||
*(dp + 4) = (png_byte)((background->blue >> 8) & 0xff);
|
||||
*(dp + 5) = (png_byte)(background->blue & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1958,20 +1960,20 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_uint_16 a;
|
||||
|
||||
a = ((png_uint_16)(*(sp + 6)) << 8) +
|
||||
(png_uint_16)(*(sp + 7));
|
||||
a = (png_uint_16)(((png_uint_16)(*(sp + 6)) << 8) +
|
||||
(png_uint_16)(*(sp + 7)));
|
||||
if (a == (png_uint_16)0xffff)
|
||||
{
|
||||
png_memcpy(dp, sp, 6);
|
||||
}
|
||||
else if (a == 0)
|
||||
{
|
||||
*dp = (background->red >> 8) & 0xff;
|
||||
*(dp + 1) = background->red & 0xff;
|
||||
*(dp + 2) = (background->green >> 8) & 0xff;
|
||||
*(dp + 3) = background->green & 0xff;
|
||||
*(dp + 4) = (background->blue >> 8) & 0xff;
|
||||
*(dp + 5) = background->blue & 0xff;
|
||||
*dp = (png_byte)((background->red >> 8) & 0xff);
|
||||
*(dp + 1) = (png_byte)(background->red & 0xff);
|
||||
*(dp + 2) = (png_byte)((background->green >> 8) & 0xff);
|
||||
*(dp + 3) = (png_byte)(background->green & 0xff);
|
||||
*(dp + 4) = (png_byte)((background->blue >> 8) & 0xff);
|
||||
*(dp + 5) = (png_byte)(background->blue & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2011,9 +2013,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
{
|
||||
row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
|
||||
row_info->channels -= 1;
|
||||
row_info->pixel_depth = row_info->channels *
|
||||
row_info->bit_depth;
|
||||
row_info->channels -= (png_byte)1;
|
||||
row_info->pixel_depth = (png_byte)(row_info->channels *
|
||||
row_info->bit_depth);
|
||||
row_info->rowbytes = ((row_info->width *
|
||||
row_info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
@ -2065,18 +2067,18 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
|
||||
v = gamma_16_table[*(sp + 1) >>
|
||||
gamma_shift][*sp];
|
||||
*sp = (v >> 8) & 0xff;
|
||||
*(sp + 1) = v & 0xff;
|
||||
*sp = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(v & 0xff);
|
||||
sp += 2;
|
||||
v = gamma_16_table[*(sp + 1) >>
|
||||
gamma_shift][*sp];
|
||||
*sp = (v >> 8) & 0xff;
|
||||
*(sp + 1) = v & 0xff;
|
||||
*sp = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(v & 0xff);
|
||||
sp += 2;
|
||||
v = gamma_16_table[*(sp + 1) >>
|
||||
gamma_shift][*sp];
|
||||
*sp = (v >> 8) & 0xff;
|
||||
*(sp + 1) = v & 0xff;
|
||||
*sp = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(v & 0xff);
|
||||
sp += 2;
|
||||
}
|
||||
}
|
||||
@ -2107,18 +2109,18 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
|
||||
v = gamma_16_table[*(sp + 1) >>
|
||||
gamma_shift][*sp];
|
||||
*sp = (v >> 8) & 0xff;
|
||||
*(sp + 1) = v & 0xff;
|
||||
*sp = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(v & 0xff);
|
||||
sp += 2;
|
||||
v = gamma_16_table[*(sp + 1) >>
|
||||
gamma_shift][*sp];
|
||||
*sp = (v >> 8) & 0xff;
|
||||
*(sp + 1) = v & 0xff;
|
||||
*sp = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(v & 0xff);
|
||||
sp += 2;
|
||||
v = gamma_16_table[*(sp + 1) >>
|
||||
gamma_shift][*sp];
|
||||
*sp = (v >> 8) & 0xff;
|
||||
*(sp + 1) = v & 0xff;
|
||||
*sp = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(v & 0xff);
|
||||
sp += 4;
|
||||
}
|
||||
}
|
||||
@ -2145,8 +2147,8 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
|
||||
v = gamma_16_table[*(sp + 1) >>
|
||||
gamma_shift][*sp];
|
||||
*sp = (v >> 8) & 0xff;
|
||||
*(sp + 1) = v & 0xff;
|
||||
*sp = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(v & 0xff);
|
||||
sp += 4;
|
||||
}
|
||||
}
|
||||
@ -2172,8 +2174,8 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
|
||||
v = gamma_16_table[*(sp + 1) >>
|
||||
gamma_shift][*sp];
|
||||
*sp = (v >> 8) & 0xff;
|
||||
*(sp + 1) = v & 0xff;
|
||||
*sp = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(v & 0xff);
|
||||
sp += 2;
|
||||
}
|
||||
}
|
||||
@ -2233,7 +2235,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0x3;
|
||||
*dp = value;
|
||||
*dp = (png_byte)value;
|
||||
if (shift == 6)
|
||||
{
|
||||
shift = 0;
|
||||
@ -2254,7 +2256,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0xf;
|
||||
*dp = value;
|
||||
*dp = (png_byte)value;
|
||||
if (shift == 4)
|
||||
{
|
||||
shift = 0;
|
||||
@ -2370,7 +2372,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0x3;
|
||||
*dp = (value | (value << 2) | (value << 4) |
|
||||
*dp = (png_byte)(value | (value << 2) | (value << 4) |
|
||||
(value << 6));
|
||||
if (shift == 6)
|
||||
{
|
||||
@ -2392,7 +2394,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0xf;
|
||||
*dp = (value | (value << 4));
|
||||
*dp = (png_byte)(value | (value << 4));
|
||||
if (shift == 4)
|
||||
{
|
||||
shift = 0;
|
||||
@ -2448,7 +2450,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
|
||||
row_info->channels = 2;
|
||||
row_info->pixel_depth = (row_info->bit_depth << 1);
|
||||
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1);
|
||||
row_info->rowbytes =
|
||||
((row_info->width * row_info->pixel_depth) >> 3);
|
||||
}
|
||||
@ -2502,7 +2504,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||
row_info->channels = 4;
|
||||
row_info->pixel_depth = (row_info->bit_depth << 2);
|
||||
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);
|
||||
row_info->rowbytes =
|
||||
((row_info->width * row_info->pixel_depth) >> 3);
|
||||
}
|
||||
@ -2613,7 +2615,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
|
||||
g = 1.0 / (png_ptr->gamma * png_ptr->display_gamma);
|
||||
|
||||
png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->gamma_table = (png_bytep)png_large_malloc(png_ptr,
|
||||
(png_uint_32)256);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
@ -2626,7 +2628,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
{
|
||||
g = 1.0 / (png_ptr->gamma);
|
||||
|
||||
png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->gamma_to_1 = (png_bytep)png_large_malloc(png_ptr,
|
||||
(png_uint_32)256);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
@ -2637,7 +2639,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
|
||||
g = 1.0 / (png_ptr->display_gamma);
|
||||
|
||||
png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->gamma_from_1 = (png_bytep)png_large_malloc(png_ptr,
|
||||
(png_uint_32)256);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
@ -2683,13 +2685,13 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
if (shift < 0)
|
||||
shift = 0;
|
||||
|
||||
png_ptr->gamma_shift = shift;
|
||||
png_ptr->gamma_shift = (png_byte)shift;
|
||||
|
||||
num = (1 << (8 - shift));
|
||||
|
||||
g = 1.0 / (png_ptr->gamma * png_ptr->display_gamma);
|
||||
|
||||
png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
|
||||
png_ptr->gamma_16_table = (png_uint_16pp)png_large_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16p ));
|
||||
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) &&
|
||||
@ -2700,7 +2702,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16p)png_large_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
}
|
||||
|
||||
@ -2714,8 +2716,8 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
while (last <= max)
|
||||
{
|
||||
png_ptr->gamma_16_table[(int)(last & (0xff >> shift))]
|
||||
[(int)(last >> (8 - shift))] =
|
||||
(png_uint_16)i | ((png_uint_16)i << 8);
|
||||
[(int)(last >> (8 - shift))] = (png_uint_16)(
|
||||
(png_uint_16)i | ((png_uint_16)i << 8));
|
||||
last++;
|
||||
}
|
||||
}
|
||||
@ -2731,7 +2733,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
{
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16p)png_large_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
@ -2749,12 +2751,12 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
{
|
||||
g = 1.0 / (png_ptr->gamma);
|
||||
|
||||
png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
|
||||
png_ptr->gamma_16_to_1 = (png_uint_16pp)png_large_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16p ));
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_large_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
@ -2768,12 +2770,12 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
}
|
||||
g = 1.0 / (png_ptr->display_gamma);
|
||||
|
||||
png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
|
||||
png_ptr->gamma_16_from_1 = (png_uint_16pp)png_large_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16p));
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_large_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
|
50
pngrutil.c
50
pngrutil.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a png file
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -30,8 +30,8 @@ png_get_uint_16(png_bytep buf)
|
||||
{
|
||||
png_uint_16 i;
|
||||
|
||||
i = ((png_uint_16)(*buf) << 8) +
|
||||
(png_uint_16)(*(buf + 1));
|
||||
i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
|
||||
(png_uint_16)(*(buf + 1)));
|
||||
|
||||
return i;
|
||||
}
|
||||
@ -121,9 +121,9 @@ png_handle_IHDR(png_structp png_ptr, png_infop info, png_uint_32 length)
|
||||
/* set internal variables */
|
||||
png_ptr->width = width;
|
||||
png_ptr->height = height;
|
||||
png_ptr->bit_depth = bit_depth;
|
||||
png_ptr->interlaced = interlace_type;
|
||||
png_ptr->color_type = color_type;
|
||||
png_ptr->bit_depth = (png_byte)bit_depth;
|
||||
png_ptr->interlaced = (png_byte)interlace_type;
|
||||
png_ptr->color_type = (png_byte)color_type;
|
||||
|
||||
/* find number of channels */
|
||||
switch (png_ptr->color_type)
|
||||
@ -143,8 +143,8 @@ png_handle_IHDR(png_structp png_ptr, png_infop info, png_uint_32 length)
|
||||
break;
|
||||
}
|
||||
/* set up other useful info */
|
||||
png_ptr->pixel_depth = png_ptr->bit_depth *
|
||||
png_ptr->channels;
|
||||
png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *
|
||||
png_ptr->channels);
|
||||
png_ptr->rowbytes = ((png_ptr->width *
|
||||
(png_uint_32)png_ptr->pixel_depth + 7) >> 3);
|
||||
/* call the IHDR callback (which should just set up info) */
|
||||
@ -163,7 +163,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info, png_uint_32 length)
|
||||
png_error(png_ptr, "Invalid Palette Chunk");
|
||||
|
||||
num = (int)length / 3;
|
||||
palette = (png_colorp)png_malloc(png_ptr, num * sizeof (png_color));
|
||||
palette = (png_colorp)png_large_malloc(png_ptr, num * sizeof (png_color));
|
||||
png_ptr->do_free |= PNG_FREE_PALETTE;
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
@ -176,7 +176,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info, png_uint_32 length)
|
||||
palette[i].blue = buf[2];
|
||||
}
|
||||
png_ptr->palette = palette;
|
||||
png_ptr->num_palette = num;
|
||||
png_ptr->num_palette = (png_uint_16)num;
|
||||
png_read_PLTE(png_ptr, info, palette, num);
|
||||
}
|
||||
|
||||
@ -310,10 +310,10 @@ png_handle_tRNS(png_structp png_ptr, png_infop info, png_uint_32 length)
|
||||
return;
|
||||
}
|
||||
|
||||
png_ptr->trans = (png_bytep)png_malloc(png_ptr, length);
|
||||
png_ptr->trans = (png_bytep)png_large_malloc(png_ptr, length);
|
||||
png_ptr->do_free |= PNG_FREE_TRANS;
|
||||
png_crc_read(png_ptr, png_ptr->trans, length);
|
||||
png_ptr->num_trans = (int)length;
|
||||
png_ptr->num_trans = (png_uint_16)length;
|
||||
}
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
@ -406,7 +406,7 @@ png_handle_hIST(png_structp png_ptr, png_infop info, png_uint_32 length)
|
||||
}
|
||||
|
||||
num = (int)length / 2;
|
||||
png_ptr->hist = (png_uint_16p)png_malloc(png_ptr,
|
||||
png_ptr->hist = (png_uint_16p)png_large_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16));
|
||||
png_ptr->do_free |= PNG_FREE_HIST;
|
||||
for (i = 0; i < num; i++)
|
||||
@ -503,8 +503,6 @@ png_handle_tEXt(png_structp png_ptr, png_infop info, png_uint_32 length)
|
||||
png_charp key;
|
||||
png_charp text;
|
||||
|
||||
text = NULL;
|
||||
|
||||
key = (png_charp )png_large_malloc(png_ptr, length + 1);
|
||||
png_crc_read(png_ptr, (png_bytep )key, length);
|
||||
key[(png_size_t)length] = '\0';
|
||||
@ -529,8 +527,6 @@ png_handle_zTXt(png_structp png_ptr, png_infop info, png_uint_32 length)
|
||||
int ret;
|
||||
png_uint_32 text_size, key_size;
|
||||
|
||||
text = NULL;
|
||||
|
||||
key = png_large_malloc(png_ptr, length + 1);
|
||||
png_crc_read(png_ptr, (png_bytep )key, length);
|
||||
key[(png_size_t)length] = '\0';
|
||||
@ -585,7 +581,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info, png_uint_32 length)
|
||||
{
|
||||
if (!text)
|
||||
{
|
||||
text = (png_charp)png_malloc(png_ptr,
|
||||
text = (png_charp)png_large_malloc(png_ptr,
|
||||
png_ptr->zbuf_size - png_ptr->zstream->avail_out +
|
||||
key_size + 1);
|
||||
png_memcpy(text + (png_size_t)key_size, png_ptr->zbuf,
|
||||
@ -687,7 +683,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
{
|
||||
value = (*sp >> shift) & 0x1;
|
||||
*dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
|
||||
*dp |= (value << shift);
|
||||
*dp |= (png_byte)(value << shift);
|
||||
}
|
||||
|
||||
if (shift == 0)
|
||||
@ -725,7 +721,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
{
|
||||
value = (*sp >> shift) & 0x3;
|
||||
*dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
*dp |= (value << shift);
|
||||
*dp |= (png_byte)(value << shift);
|
||||
}
|
||||
|
||||
if (shift == 0)
|
||||
@ -762,7 +758,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
|
||||
{
|
||||
value = (*sp >> shift) & 0xf;
|
||||
*dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
*dp |= (value << shift);
|
||||
*dp |= (png_byte)(value << shift);
|
||||
}
|
||||
|
||||
if (shift == 0)
|
||||
@ -839,7 +835,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
dshift = 7 - (int)((final_width + 7) & 7);
|
||||
for (i = row_info->width; i; i--)
|
||||
{
|
||||
v = (*sp >> sshift) & 0x1;
|
||||
v = (png_byte)((*sp >> sshift) & 0x1);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
{
|
||||
*dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff);
|
||||
@ -875,11 +871,11 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1);
|
||||
for (i = row_info->width; i; i--)
|
||||
{
|
||||
v = (*sp >> sshift) & 0x3;
|
||||
v = (png_byte)((*sp >> sshift) & 0x3);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
{
|
||||
*dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff);
|
||||
*dp |= (v << dshift);
|
||||
*dp |= (png_byte)(v << dshift);
|
||||
if (dshift == 6)
|
||||
{
|
||||
dshift = 0;
|
||||
@ -912,11 +908,11 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2);
|
||||
for (i = row_info->width; i; i--)
|
||||
{
|
||||
v = (*sp >> sshift) & 0xf;
|
||||
v = (png_byte)((*sp >> sshift) & 0xf);
|
||||
for (j = 0; j < png_pass_inc[pass]; j++)
|
||||
{
|
||||
*dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff);
|
||||
*dp |= (v << dshift);
|
||||
*dp |= (png_byte)(v << dshift);
|
||||
if (dshift == 4)
|
||||
{
|
||||
dshift = 0;
|
||||
|
14
pngtest.c
14
pngtest.c
@ -1,9 +1,9 @@
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@ -33,11 +33,13 @@ int main()
|
||||
{
|
||||
FILE *fpin, *fpout;
|
||||
png_bytep row_buf;
|
||||
png_byte * near_row_buf;
|
||||
png_uint_32 rowbytes;
|
||||
png_uint_32 y;
|
||||
int channels, num_pass, pass;
|
||||
|
||||
row_buf = (png_bytep)0;
|
||||
near_row_buf = (png_byte *)0;
|
||||
|
||||
fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
|
||||
|
||||
@ -99,7 +101,8 @@ int main()
|
||||
channels++;
|
||||
|
||||
rowbytes = ((info_ptr.width * info_ptr.bit_depth * channels + 7) >> 3);
|
||||
row_buf = (png_bytep )malloc((size_t)rowbytes);
|
||||
near_row_buf = (png_byte *)malloc((size_t)rowbytes);
|
||||
row_buf = (png_bytep)near_row_buf;
|
||||
if (!row_buf)
|
||||
{
|
||||
fprintf(STDERR, "no memory to allocate row buffer\n");
|
||||
@ -124,6 +127,9 @@ int main()
|
||||
{
|
||||
for (y = 0; y < info_ptr.height; y++)
|
||||
{
|
||||
#ifdef TESTING
|
||||
fprintf(STDERR, "Processing line #%ld\n", y);
|
||||
#endif
|
||||
png_read_rows(&read_ptr, (png_bytepp)&row_buf, (png_bytepp)0, 1);
|
||||
png_write_rows(&write_ptr, (png_bytepp)&row_buf, 1);
|
||||
}
|
||||
@ -138,7 +144,7 @@ int main()
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
|
||||
free((void *)row_buf);
|
||||
free((void *)near_row_buf);
|
||||
|
||||
fpin = fopen(inname, "rb");
|
||||
|
||||
|
@ -4,6 +4,7 @@ for 0.9
|
||||
improved dithering
|
||||
final bug fixes
|
||||
cHRM transformation
|
||||
better documentation
|
||||
|
||||
after 1.0
|
||||
overlaying one image on top of another
|
||||
|
@ -2,10 +2,10 @@
|
||||
/* pngtrans.c - transforms the data in a row
|
||||
routines used by both readers and writers
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -113,7 +113,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
i < row_info->rowbytes;
|
||||
i++, rp++)
|
||||
{
|
||||
*rp = ~(*rp);
|
||||
*rp = (png_byte)(~(*rp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
26
pngwrite.c
26
pngwrite.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a png file
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
/* get internal access to png.h */
|
||||
@ -161,12 +161,12 @@ png_write_end(png_structp png_ptr, png_infop info)
|
||||
void
|
||||
png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime)
|
||||
{
|
||||
ptime->year = 1900 + ttime->tm_year;
|
||||
ptime->month = ttime->tm_mon + 1;
|
||||
ptime->day = ttime->tm_mday;
|
||||
ptime->hour = ttime->tm_hour;
|
||||
ptime->minute = ttime->tm_min;
|
||||
ptime->second = ttime->tm_sec;
|
||||
ptime->year = (png_uint_16)(1900 + ttime->tm_year);
|
||||
ptime->month = (png_byte)(ttime->tm_mon + 1);
|
||||
ptime->day = (png_byte)ttime->tm_mday;
|
||||
ptime->hour = (png_byte)ttime->tm_hour;
|
||||
ptime->minute = (png_byte)ttime->tm_min;
|
||||
ptime->second = (png_byte)ttime->tm_sec;
|
||||
}
|
||||
|
||||
void
|
||||
@ -322,8 +322,8 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
||||
png_ptr->row_info.width = png_ptr->usr_width;
|
||||
png_ptr->row_info.channels = png_ptr->usr_channels;
|
||||
png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth;
|
||||
png_ptr->row_info.pixel_depth = png_ptr->row_info.bit_depth *
|
||||
png_ptr->row_info.channels;
|
||||
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
|
||||
png_ptr->row_info.channels);
|
||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||
|
||||
@ -421,14 +421,14 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
/* Set the automatic flush interval or 0 to turn flushing off */
|
||||
void
|
||||
png_set_flush(png_struct *png_ptr, int nrows)
|
||||
png_set_flush(png_structp png_ptr, int nrows)
|
||||
{
|
||||
png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);
|
||||
}
|
||||
|
||||
/* flush the current output buffers now */
|
||||
void
|
||||
png_write_flush(png_struct *png_ptr)
|
||||
png_write_flush(png_structp png_ptr)
|
||||
{
|
||||
int wrote_IDAT;
|
||||
|
||||
@ -501,7 +501,7 @@ void
|
||||
png_set_filtering(png_structp png_ptr, int filter)
|
||||
{
|
||||
png_ptr->do_custom_filter = 1;
|
||||
png_ptr->do_filter = filter;
|
||||
png_ptr->do_filter = (png_byte)filter;
|
||||
}
|
||||
|
||||
void
|
||||
|
29
pngwtran.c
29
pngwtran.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for png writers
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -78,13 +78,13 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_byte bit_depth)
|
||||
else
|
||||
{
|
||||
mask = 0x80;
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
}
|
||||
if (mask != 0x80)
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
@ -102,12 +102,12 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_byte bit_depth)
|
||||
v = 0;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
value = *sp & 0x3;
|
||||
value = (png_byte)(*sp & 0x3);
|
||||
v |= (value << shift);
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 6;
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
@ -116,7 +116,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_byte bit_depth)
|
||||
sp++;
|
||||
}
|
||||
if (shift != 6)
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
@ -134,13 +134,13 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_byte bit_depth)
|
||||
v = 0;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
value = *sp & 0xf;
|
||||
value = (png_byte)(*sp & 0xf);
|
||||
v |= (value << shift);
|
||||
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 4;
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
@ -150,12 +150,12 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_byte bit_depth)
|
||||
sp++;
|
||||
}
|
||||
if (shift != 4)
|
||||
*dp = v;
|
||||
*dp = (png_byte)v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
row_info->bit_depth = bit_depth;
|
||||
row_info->pixel_depth = bit_depth * row_info->channels;
|
||||
row_info->pixel_depth = (png_uint_16)(bit_depth * row_info->channels);
|
||||
row_info->rowbytes =
|
||||
((row_info->width * row_info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
@ -276,7 +276,8 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
{
|
||||
png_uint_16 value, v;
|
||||
|
||||
v = ((png_uint_16)(*bp) << 8) + (png_uint_16)(*(bp + 1));
|
||||
v = (png_uint_16)(((png_uint_16)(*bp) << 8) +
|
||||
(png_uint_16)(*(bp + 1)));
|
||||
value = 0;
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
@ -285,8 +286,8 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
else
|
||||
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
|
||||
}
|
||||
*bp = value >> 8;
|
||||
*(bp + 1) = value & 0xff;
|
||||
*bp = (png_byte)(value >> 8);
|
||||
*(bp + 1) = (png_byte)(value & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
77
pngwutil.c
77
pngwutil.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a png file
|
||||
|
||||
libpng 1.0 beta 2 - version 0.86
|
||||
libpng 1.0 beta 2 - version 0.87
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
January 10, 1996
|
||||
January 15, 1996
|
||||
*/
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
@ -142,15 +142,15 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
/* pack the header information into the buffer */
|
||||
png_save_uint_32(buf, width);
|
||||
png_save_uint_32(buf + 4, height);
|
||||
buf[8] = bit_depth;
|
||||
buf[9] = color_type;
|
||||
buf[10] = compression_type;
|
||||
buf[11] = filter_type;
|
||||
buf[12] = interlace_type;
|
||||
buf[8] = (png_byte)bit_depth;
|
||||
buf[9] = (png_byte)color_type;
|
||||
buf[10] = (png_byte)compression_type;
|
||||
buf[11] = (png_byte)filter_type;
|
||||
buf[12] = (png_byte)interlace_type;
|
||||
/* save off the relevent information */
|
||||
png_ptr->bit_depth = bit_depth;
|
||||
png_ptr->color_type = color_type;
|
||||
png_ptr->interlaced = interlace_type;
|
||||
png_ptr->bit_depth = (png_byte)bit_depth;
|
||||
png_ptr->color_type = (png_byte)color_type;
|
||||
png_ptr->interlaced = (png_byte)interlace_type;
|
||||
png_ptr->width = width;
|
||||
png_ptr->height = height;
|
||||
|
||||
@ -170,7 +170,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
png_ptr->channels = 4;
|
||||
break;
|
||||
}
|
||||
png_ptr->pixel_depth = bit_depth * png_ptr->channels;
|
||||
png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels);
|
||||
png_ptr->rowbytes = ((width * (png_uint_32)png_ptr->pixel_depth + 7) >> 3);
|
||||
/* set the usr info, so any transformations can modify it */
|
||||
png_ptr->usr_width = png_ptr->width;
|
||||
@ -184,7 +184,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
png_ptr->zstream = (z_stream *)png_malloc(png_ptr, sizeof (z_stream));
|
||||
png_ptr->zstream->zalloc = png_zalloc;
|
||||
png_ptr->zstream->zfree = png_zfree;
|
||||
png_ptr->zstream->opaque = (voidp)png_ptr;
|
||||
png_ptr->zstream->opaque = (voidpf)png_ptr;
|
||||
if (!png_ptr->do_custom_filter)
|
||||
{
|
||||
if (png_ptr->color_type == 3 || png_ptr->bit_depth < 8)
|
||||
@ -477,11 +477,18 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
old_max = max_output_ptr;
|
||||
max_output_ptr = num_output_ptr + 4;
|
||||
if (output_ptr)
|
||||
output_ptr = (png_charpp)png_realloc(png_ptr, output_ptr,
|
||||
max_output_ptr * sizeof (png_charpp),
|
||||
old_max * sizeof (png_charp));
|
||||
{
|
||||
png_charpp old_ptr;
|
||||
|
||||
old_ptr = output_ptr;
|
||||
output_ptr = (png_charpp)png_large_malloc(png_ptr,
|
||||
max_output_ptr * sizeof (png_charpp));
|
||||
png_memcpy(output_ptr, old_ptr,
|
||||
(png_size_t)(old_max * sizeof (png_charp)));
|
||||
png_large_free(png_ptr, old_ptr);
|
||||
}
|
||||
else
|
||||
output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
output_ptr = (png_charpp)png_large_malloc(png_ptr,
|
||||
max_output_ptr * sizeof (png_charp));
|
||||
}
|
||||
|
||||
@ -524,11 +531,18 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
old_max = max_output_ptr;
|
||||
max_output_ptr = num_output_ptr + 4;
|
||||
if (output_ptr)
|
||||
output_ptr = (png_charpp)png_realloc(png_ptr, output_ptr,
|
||||
max_output_ptr * sizeof (png_charp),
|
||||
old_max * sizeof (png_charp));
|
||||
{
|
||||
png_charpp old_ptr;
|
||||
|
||||
old_ptr = output_ptr;
|
||||
output_ptr = (png_charpp)png_large_malloc(png_ptr,
|
||||
max_output_ptr * sizeof (png_charpp));
|
||||
png_memcpy(output_ptr, old_ptr,
|
||||
(png_size_t)(old_max * sizeof (png_charp)));
|
||||
png_large_free(png_ptr, old_ptr);
|
||||
}
|
||||
else
|
||||
output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
output_ptr = (png_charpp)png_large_malloc(png_ptr,
|
||||
max_output_ptr * sizeof (png_charp));
|
||||
}
|
||||
|
||||
@ -556,7 +570,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
(png_uint_32)(key_len + text_len + 2));
|
||||
/* write key */
|
||||
png_write_chunk_data(png_ptr, (png_bytep )key, (png_uint_32)(key_len + 1));
|
||||
buf[0] = compression;
|
||||
buf[0] = (png_byte)compression;
|
||||
/* write compression */
|
||||
png_write_chunk_data(png_ptr, (png_bytep )buf, (png_uint_32)1);
|
||||
|
||||
@ -567,7 +581,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
png_large_free(png_ptr, output_ptr[i]);
|
||||
}
|
||||
if (max_output_ptr)
|
||||
png_free(png_ptr, output_ptr);
|
||||
png_large_free(png_ptr, output_ptr);
|
||||
/* write anything left in zbuf */
|
||||
if (png_ptr->zstream->avail_out < png_ptr->zbuf_size)
|
||||
png_write_chunk_data(png_ptr, png_ptr->zbuf,
|
||||
@ -591,7 +605,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
|
||||
|
||||
png_save_uint_32(buf, x_pixels_per_unit);
|
||||
png_save_uint_32(buf + 4, y_pixels_per_unit);
|
||||
buf[8] = unit_type;
|
||||
buf[8] = (png_byte)unit_type;
|
||||
|
||||
png_write_chunk(png_ptr, png_pHYs, buf, (png_uint_32)9);
|
||||
}
|
||||
@ -608,7 +622,7 @@ png_write_oFFs(png_structp png_ptr, png_uint_32 x_offset,
|
||||
|
||||
png_save_uint_32(buf, x_offset);
|
||||
png_save_uint_32(buf + 4, y_offset);
|
||||
buf[8] = unit_type;
|
||||
buf[8] = (png_byte)unit_type;
|
||||
|
||||
png_write_chunk(png_ptr, png_oFFs, buf, (png_uint_32)9);
|
||||
}
|
||||
@ -804,7 +818,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 7;
|
||||
*dp++ = d;
|
||||
*dp++ = (png_byte)d;
|
||||
d = 0;
|
||||
}
|
||||
else
|
||||
@ -812,7 +826,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
|
||||
}
|
||||
if (shift != 7)
|
||||
*dp = d;
|
||||
*dp = (png_byte)d;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
@ -838,14 +852,14 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 6;
|
||||
*dp++ = d;
|
||||
*dp++ = (png_byte)d;
|
||||
d = 0;
|
||||
}
|
||||
else
|
||||
shift -= 2;
|
||||
}
|
||||
if (shift != 6)
|
||||
*dp = d;
|
||||
*dp = (png_byte)d;
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
@ -871,14 +885,14 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 4;
|
||||
*dp++ = d;
|
||||
*dp++ = (png_byte)d;
|
||||
d = 0;
|
||||
}
|
||||
else
|
||||
shift -= 4;
|
||||
}
|
||||
if (shift != 4)
|
||||
*dp = d;
|
||||
*dp = (png_byte)d;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -1056,12 +1070,11 @@ png_write_filter_row(png_row_infop row_info, png_bytep row,
|
||||
|
||||
if (s4 < mins)
|
||||
{
|
||||
mins = s4;
|
||||
minf = 4;
|
||||
}
|
||||
|
||||
/* set filter byte */
|
||||
row[0] = minf;
|
||||
row[0] = (png_byte)minf;
|
||||
|
||||
/* do filter */
|
||||
switch (minf)
|
||||
|
@ -1,4 +1,4 @@
|
||||
readme.txt - for libpng 0.86
|
||||
readme.txt - for libpng 0.87
|
||||
|
||||
This is a bug fix for the second beta version of libpng 1.0, and
|
||||
a first try at a progressive (push) reader. It hasn't been
|
||||
@ -60,6 +60,11 @@ You can reach me at:
|
||||
internet: schalnat@group42.com
|
||||
CompuServe: 75501,1625
|
||||
|
||||
I tend to check my CompuServe account very infrequently, so you may
|
||||
want to use the internet account. If I don't answer your email
|
||||
immediately, please be patient. If you don't receive a reply within
|
||||
a week, you may want to write and ask if I got the first email.
|
||||
|
||||
Please do not send me general questions about PNG. Send them to
|
||||
the address in the specification. At the same time, please do
|
||||
not send libpng questions to that address, send them to me. I'll
|
||||
@ -70,7 +75,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
|
||||
to others, if necessary.
|
||||
|
||||
Please do not send suggestions on how to change PNG. We have
|
||||
been discussing PNG for 9 months now, and it is official and
|
||||
been discussing PNG for over a year now, and it is official and
|
||||
finished. If you have suggestions for libpng, however, I'll
|
||||
gladly listen. Even if your suggestion is not used for version
|
||||
1.0, it may be used later.
|
||||
|
Reference in New Issue
Block a user