Imported from libpng-0.89.tar

This commit is contained in:
Guy Schalnat 1996-06-05 15:50:50 -05:00 committed by Glenn Randers-Pehrson
parent b2e01bd505
commit e5a37797b4
38 changed files with 3198 additions and 2062 deletions

View File

@ -10,7 +10,7 @@ pref = /prefix=all
OBJS = png.obj, pngrcb.obj, pngrutil.obj, pngtrans.obj, pngwutil.obj,\
pngread.obj, pngmem.obj, pngwrite.obj, pngrtran.obj, pngwtran.obj,\
pngio.obj, pngerror.obj, pngpread.obj
pngrio.obj, pngwio.obj, pngerror.obj, pngpread.obj
CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF)
@ -41,7 +41,8 @@ pngrtran.obj : png.h, pngconf.h
pngrutil.obj : png.h, pngconf.h
pngerror.obj : png.h, pngconf.h
pngmem.obj : png.h, pngconf.h
pngio.obj : png.h, pngconf.h
pngrio.obj : png.h, pngconf.h
pngwio.obj : png.h, pngconf.h
pngtest.obj : png.h, pngconf.h
pngtrans.obj : png.h, pngconf.h
pngwrite.obj : png.h, pngconf.h

245
example.c
View File

@ -48,47 +48,45 @@ void read_png(char *file_name)
if (!fp)
return;
/* allocate the necessary structures */
png_ptr = malloc(sizeof (png_struct));
/* Create and initialize the png_struct with the desired error handler
functions. If you want to use the default stderr and longjump method,
you can supply NULL for the last three parameters. We also check that
the header file is compatible with the library version.
*/
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
(void *)user_error_ptr, user_error_fn, user_warning_fn);
if (!png_ptr)
{
fclose(fp);
return;
}
info_ptr = malloc(sizeof (png_info));
info_ptr = png_create_info_struct();
if (!info_ptr)
{
fclose(fp);
free(png_ptr);
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
return;
}
/* set error handling */
/* set error handling if you are using the setjmp/longjmp method */
if (setjmp(png_ptr->jmpbuf))
{
png_read_destroy(png_ptr, info_ptr, (png_info *)0);
/* Free all of the memory associated with the png_ptr and info_ptr */
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
fclose(fp);
free(png_ptr);
free(info_ptr);
/* If we get here, we had a problem reading the file */
return;
}
/* initialize the structures, info first for error handling */
png_info_init(info_ptr);
png_read_init(png_ptr);
/* set up the input control if you are using standard C streams */
png_init_io(png_ptr, fp);
/* if you are using replacement read functions, here you would call */
png_set_read_fn(png_ptr, (void *)io_ptr, user_read_fn);
/* where io_ptr is a structure you want available to the callbacks */
/* if you are using replacement message functions, here you would call */
png_set_message_fn(png_ptr, (void *)msg_ptr, user_error_fn, user_warning_fn);
/* where msg_ptr is a structure you want available to the callbacks */
/* if you are using replacement read functions, instead of calling
png_init_io() here you would call */
png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);
/* where user_io_ptr is a structure you want available to the callbacks */
/* read the file information */
png_read_info(png_ptr, info_ptr);
@ -96,29 +94,31 @@ void read_png(char *file_name)
/* set up the transformations you want. Note that these are
all optional. Only call them if you want them */
/* expand paletted colors into true rgb */
/* expand paletted colors into true RGB triplets */
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
png_set_expand(png_ptr);
/* expand grayscale images to the full 8 bits */
if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
info_ptr->bit_depth < 8)
if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY && info_ptr->bit_depth < 8)
png_set_expand(png_ptr);
/* expand images with transparency to full alpha channels */
/* expand paletted or RGB images with transparency to full alpha channels
* so the data will be available as RGBA quartets */
if (info_ptr->valid & PNG_INFO_tRNS)
png_set_expand(png_ptr);
/* Set the background color to draw transparent and alpha
images over */
images over. It is possible to set the red, green, and blue
components directly for paletted images. */
png_color_16 my_background;
if (info_ptr->valid & PNG_INFO_bKGD)
png_set_background(png_ptr, &(info_ptr->background),
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
else
png_set_background(png_ptr, &my_background,
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
/* tell libpng to handle the gamma conversion for you */
if (info_ptr->valid & PNG_INFO_gAMA)
@ -126,18 +126,17 @@ void read_png(char *file_name)
else
png_set_gamma(png_ptr, screen_gamma, 0.45);
/* tell libpng to strip 16 bit depth files down to 8 bits */
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
if (info_ptr->bit_depth == 16)
png_set_strip_16(png_ptr);
/* dither rgb files down to 8 bit palettes & reduce palettes
/* dither rgb files down to 8 bit palette & reduce palettes
to the number of colors available on your screen */
if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
{
if (info_ptr->valid & PNG_INFO_PLTE)
png_set_dither(png_ptr, info_ptr->palette,
info_ptr->num_palette, max_screen_colors,
info_ptr->histogram);
png_set_dither(png_ptr, info_ptr->palette, info_ptr->num_palette,
max_screen_colors, info_ptr->histogram);
else
{
png_color std_color_cube[MAX_SCREEN_COLORS] =
@ -148,9 +147,8 @@ void read_png(char *file_name)
}
}
/* invert monocrome files */
if (info_ptr->bit_depth == 1 &&
info_ptr->color_type == PNG_COLOR_GRAY)
/* invert monocrome files to have 0 as white and 1 as black */
if (info_ptr->bit_depth == 1 && info_ptr->color_type == PNG_COLOR_GRAY)
png_set_invert(png_ptr);
/* shift the pixels down to their true bit depth */
@ -158,7 +156,8 @@ void read_png(char *file_name)
info_ptr->bit_depth > info_ptr->sig_bit)
png_set_shift(png_ptr, &(info_ptr->sig_bit));
/* pack pixels into bytes */
/* pack multiple pixels with bit depths of 1, 2, and 4 into bytes
(useful only for paletted and grayscale images) */
if (info_ptr->bit_depth < 8)
png_set_packing(png_ptr);
@ -171,21 +170,15 @@ void read_png(char *file_name)
if (info_ptr->bit_depth == 16)
png_set_swap(png_ptr);
/* add a filler byte to rgb files */
if (info_ptr->bit_depth == 8 &&
info_ptr->color_type == PNG_COLOR_TYPE_RGB)
/* add a filler byte to RGB files (before or after each RGB triplet) */
if (info_ptr->bit_depth == 8 && info_ptr->color_type == PNG_COLOR_TYPE_RGB)
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
/* turn on interlace handling if you are not using png_read_image() */
if (info_ptr->interlace_type)
number_passes = png_set_interlace_handling(png_ptr);
else
number_passes = 1;
number_passes = png_set_interlace_handling(png_ptr);
/* optional call to update palette with transformations */
png_start_read_image(png_ptr);
/* optional call to update the info structure */
/* optional call to gamma correct and add the background to the palette
and update info structure. */
png_read_update_info(png_ptr, info_ptr);
/* allocate the memory to hold the image using the fields
@ -193,6 +186,12 @@ void read_png(char *file_name)
/* the easiest way to read the image */
png_bytep row_pointers[height];
for (row = 0; row < height; row++)
{
row_pointers[row] = malloc(info_ptr->rowbytes);
}
png_read_image(png_ptr, row_pointers);
/* the other way to read images - deal with interlacing */
@ -216,16 +215,11 @@ void read_png(char *file_name)
so here */
}
/* read the rest of the file, getting any additional chunks
in info_ptr */
/* read the rest of the file, getting any additional chunks in info_ptr */
png_read_end(png_ptr, info_ptr);
/* clean up after the read, and free any memory allocated */
png_read_destroy(png_ptr, info_ptr, (png_infop)0);
/* free the structures */
free(png_ptr);
free(info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
/* close the file */
fclose(fp);
@ -236,68 +230,74 @@ void read_png(char *file_name)
/* progressively read a file */
/* these will normally not be global unless you are only
reading in one image at a time */
png_structp png_ptr;
png_infop info_ptr;
int
initialize_png_reader()
initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
{
png_ptr = malloc(sizeof (png_struct));
if (!png_ptr)
return -1;
info_ptr = malloc(sizeof (png_info));
if (!info_ptr)
/* Create and initialize the png_struct with the desired error handler
functions. If you want to use the default stderr and longjump method,
you can supply NULL for the last three parameters. We also check that
the library version is compatible in case we are using dynamically
linked libraries.
*/
*png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
(void *)user_error_ptr, user_error_fn, user_warning_fn);
if (! *png_ptr)
{
free(png_ptr);
return -1;
*info_ptr = NULL;
return ERROR;
}
if (setjmp(png_ptr->jmpbuf))
*info_ptr = png_create_info_struct(png_ptr);
if (! *info_ptr)
{
png_read_destroy(png_ptr, info_ptr, (png_info *)0);
/* free pointers before returning, if necessary */
free(png_ptr);
free(info_ptr);
return -1;
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
return ERROR;
}
png_info_init(info_ptr);
png_read_init(png_ptr);
if (setjmp((*png_ptr)->jmpbuf))
{
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
return ERROR;
}
/* this one's new. You will need to provide all three
function callbacks, even if you aren't using them all.
You can put a void pointer in place of the NULL, and
retrieve the pointer from inside the callbacks using
the function png_get_progressive_ptr(png_ptr); */
png_set_progressive_read_fn(png_ptr, NULL,
These functions shouldn't be dependent on global or
static variables if you are decoding several images
simultaneously. You should store stream specific data
in a separate struct, given as the second parameter,
and retrieve the pointer from inside the callbacks using
the function png_get_progressive_ptr(png_ptr). */
png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
info_callback, row_callback, end_callback);
return 0;
return OK;
}
int
process_data(png_bytep buffer, png_uint_32 length)
process_data(png_structp *png_ptr, png_infop *info_ptr,
png_bytep buffer, png_uint_32 length)
{
if (setjmp(png_ptr->jmpbuf))
if (setjmp((*png_ptr)->jmpbuf))
{
png_read_destroy(png_ptr, info_ptr, (png_info *)0);
free(png_ptr);
free(info_ptr);
return -1;
/* Free the png_ptr and info_ptr memory on error */
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
return ERROR;
}
/* this one's new also. Simply give it a chunk of data
from the file stream (in order, of course). On Segmented
machines, don't give it any more then 64K. The library
seems to run fine with sizes of 4K, although you can give
it much less if necessary (I assume you can give it chunks
of 1 byte, but I haven't tried less then 256 bytes yet).
When this function returns, you may want to display any
rows that were generated in the row callback. */
png_process_data(png_ptr, info_ptr, buffer, length);
return 0;
/* this one's new also. Simply give it chunks of data as
they arrive from the data stream (in order, of course).
On Segmented machines, don't give it any more than 64K.
The library seems to run fine with sizes of 4K, although
you can give it much less if necessary (I assume you can
give it chunks of 1 byte, but I haven't tried with less
than 256 bytes yet). When this function returns, you may
want to display any rows that were generated in the row
callback, if you aren't already displaying them there. */
png_process_data(*png_ptr, *info_ptr, buffer, length);
return OK;
}
info_callback(png_structp png_ptr, png_infop info)
@ -363,44 +363,41 @@ void write_png(char *file_name, ... other image information ...)
if (!fp)
return;
/* allocate the necessary structures */
png_ptr = malloc(sizeof (png_struct));
/* Create and initialize the png_struct with the desired error handler
functions. If you want to use the default stderr and longjump method,
you can supply NULL for the last three parameters. We also check that
the library version is compatible in case we are using dynamically
linked libraries.
*/
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
(void *)user_error_ptr, user_error_fn, user_warning_fn);
if (!png_ptr)
{
fclose(fp);
return;
}
info_ptr = malloc(sizeof (png_info));
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
fclose(fp);
free(png_ptr);
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
return;
}
/* set error handling */
if (setjmp(png_ptr->jmpbuf))
{
png_write_destroy(png_ptr);
fclose(fp);
free(png_ptr);
free(info_ptr);
/* If we get here, we had a problem reading the file */
fclose(fp);
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
return;
}
/* initialize the structures */
png_info_init(info_ptr);
png_write_init(png_ptr);
/* set up the output control if you are using standard C streams */
png_init_io(png_ptr, fp);
/* if you are using replacement write functions, here you would call */
png_set_write_fn(png_ptr, (void *)io_ptr, user_write_fn, user_flush_fn);
/* where io_ptr is a structure you want available to the callbacks */
/* if you are using replacement message functions, here you would call */
png_set_message_fn(png_ptr, (void *)msg_ptr, user_error_fn, user_warning_fn);
/* where msg_ptr is a structure you want available to the callbacks */
@ -432,9 +429,9 @@ void write_png(char *file_name, ... other image information ...)
info_ptr->valid |= PNG_INFO_gAMA;
info_ptr->gamma = gamma;
/* other optional chunks */
/* other optional chunks like cHRM, bKGD, tRNS, tEXt, tIME, oFFs, pHYs, */
/* write the file information */
/* write the file header information */
png_write_info(png_ptr, info_ptr);
/* set up the transformations you want. Note that these are
@ -466,8 +463,10 @@ void write_png(char *file_name, ... other image information ...)
else
number_passes = 1;
/* the easiest way to write the image */
png_bytep row_pointers[height];
/* the easiest way to write the image (you may choose to allocate the
memory differently, however) */
png_byte row_pointers[height][width];
png_write_image(png_ptr, row_pointers);
/* the other way to write the image - deal with interlacing */
@ -485,19 +484,23 @@ void write_png(char *file_name, ... other image information ...)
}
}
/* You can write optional chunks like tEXt, tIME at the end as well.
* Note that if you wrote tEXt or zTXt chunks before the image, and
* you aren't writing out more at the end, you have to set
* info_ptr->num_text = 0 or they will be written out again.
*/
/* write the rest of the file */
png_write_end(png_ptr, info_ptr);
/* clean up after the write, and free any memory allocated */
png_write_destroy(png_ptr);
/* if you malloced the palette, free it here */
if (info_ptr->palette)
free(info_ptr->palette);
/* free the structures */
free(png_ptr);
free(info_ptr);
/* if you allocated any text comments, free them here */
/* clean up after the write, and free any memory allocated */
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
/* close the file */
fclose(fp);

File diff suppressed because it is too large Load Diff

View File

@ -13,8 +13,8 @@ RANLIB=echo
prefix=/usr/local
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
pngmem.o pngerror.o pngpread.o
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o
pngwtran.o pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest
@ -45,7 +45,8 @@ clean:
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngio.o: png.h pngconf.h
pngrio.o: png.h pngconf.h
pngwio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngrcb.o: png.h pngconf.h
pngread.o: png.h pngconf.h

114
makefile.aco Normal file
View File

@ -0,0 +1,114 @@
# Project: libpng
# Toolflags:
CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah
C++flags = -c -depend !Depend -IC: -throwback
Linkflags = -aif -c++ -o $@
ObjAsmflags = -throwback -NoCache -depend !Depend
CMHGflags =
LibFileflags = -c -o $@
Squeezeflags = -o $@
# Final targets:
@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \
@.o.pngpread @.o.pngrcb @.o.pngread @.o.pngrtran @.o.pngrutil \
@.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngwio \
@.o.pngmem @.o.pngpread @.o.pngrcb @.o.pngread @.o.pngrtran \
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
@.test: @.tests.pngtest
echo Please run "Test" in directory tests
@.tests.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
# User-editable dependencies:
.c.o:
cc $(ccflags) -o $@ $<
# Static dependencies:
@.o.example: @.tests.c.example
cc $(ccflags) -o @.o.example @.tests.c.example
@.o.pngtest: @.tests.c.pngtest
cc $(ccflags) -o @.o.pngtest @.tests.c.pngtest
# Dynamic dependencies:
o.png: c.png
o.png: h.png
o.png: Zlib:h.zlib
o.png: Zlib:h.zconf
o.png: h.pngconf
o.pngerror: c.pngerror
o.pngerror: h.png
o.pngerror: Zlib:h.zlib
o.pngerror: Zlib:h.zconf
o.pngerror: h.pngconf
o.pngrio: c.pngrio
o.pngrio: h.png
o.pngrio: Zlib:h.zlib
o.pngrio: Zlib:h.zconf
o.pngrio: h.pngconf
o.pngwio: c.pngwio
o.pngwio: h.png
o.pngwio: Zlib:h.zlib
o.pngwio: Zlib:h.zconf
o.pngwio: h.pngconf
o.pngmem: c.pngmem
o.pngmem: h.png
o.pngmem: Zlib:h.zlib
o.pngmem: Zlib:h.zconf
o.pngmem: h.pngconf
o.pngpread: c.pngpread
o.pngpread: h.png
o.pngpread: Zlib:h.zlib
o.pngpread: Zlib:h.zconf
o.pngpread: h.pngconf
o.pngrcb: c.pngrcb
o.pngrcb: h.png
o.pngrcb: Zlib:h.zlib
o.pngrcb: Zlib:h.zconf
o.pngrcb: h.pngconf
o.pngread: c.pngread
o.pngread: h.png
o.pngread: Zlib:h.zlib
o.pngread: Zlib:h.zconf
o.pngread: h.pngconf
o.pngrtran: c.pngrtran
o.pngrtran: h.png
o.pngrtran: Zlib:h.zlib
o.pngrtran: Zlib:h.zconf
o.pngrtran: h.pngconf
o.pngrutil: c.pngrutil
o.pngrutil: h.png
o.pngrutil: Zlib:h.zlib
o.pngrutil: Zlib:h.zconf
o.pngrutil: h.pngconf
o.pngtrans: c.pngtrans
o.pngtrans: h.png
o.pngtrans: Zlib:h.zlib
o.pngtrans: Zlib:h.zconf
o.pngtrans: h.pngconf
o.pngwrite: c.pngwrite
o.pngwrite: h.png
o.pngwrite: Zlib:h.zlib
o.pngwrite: Zlib:h.zconf
o.pngwrite: h.pngconf
o.pngwtran: c.pngwtran
o.pngwtran: h.png
o.pngwtran: Zlib:h.zlib
o.pngwtran: Zlib:h.zconf
o.pngwtran: h.pngconf
o.pngwutil: c.pngwutil
o.pngwutil: h.png
o.pngwutil: Zlib:h.zlib
o.pngwutil: Zlib:h.zconf
o.pngwutil: h.pngconf
o.pngtest: tests.c.pngtest
o.pngtest: h.png
o.pngtest: Zlib:h.zlib
o.pngtest: Zlib:h.zconf
o.pngtest: h.pngconf

View File

@ -23,7 +23,7 @@ AR= oml
MKDIR= makedir
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o pngpread.o \
pngread.o pngerror.o pngwrite.o pngrtran.o pngwtran.o pngio.o pngmem.o
pngread.o pngerror.o pngwrite.o pngrtran.o pngwtran.o pngrio.o pngwio.o pngmem.o
all: libpng.lib pngtest

View File

@ -14,7 +14,7 @@ OBJS = $(LBR)(png.o) $(LBR)(pngrcb.o) $(LBR)(pngrutil.o)\
$(LBR)(pngtrans.o) $(LBR)(pngwutil.o)\
$(LBR)(pngread.o) $(LBR)(pngerror.o) $(LBR)(pngwrite.o)\
$(LBR)(pngrtran.o) $(LBR)(pngwtran.o)\
$(LBR)(pngmem.o) $(LBR)(pngio.o) $(LBR)(pngpread.o)
$(LBR)(pngmem.o) $(LBR)(pngrio.o) $(LBR)(pngwio.o) $(LBR)(pngpread.o)
all: $(LBR) pngtest.ttp

View File

@ -71,35 +71,35 @@ O=obj
## variables
OBJS = \
png.$(O) \
pngerror.$(O) \
pngmem.$(O) \
pngpread.$(O) \
pngrcb.$(O) \
pngread.$(O) \
pngrio.$(O) \
pngrtran.$(O) \
pngrutil.$(O) \
pngtrans.$(O) \
pngwutil.$(O) \
pngmem.$(O) \
pngread.$(O) \
pngpread.$(O) \
pngerror.$(O) \
pngwrite.$(O) \
pngrtran.$(O) \
pngwtran.$(O) \
pngzlib.$(O) \
pngio.$(O)
pngwio.$(O) \
pngwutil.$(O)
LIBOBJS = \
+png.$(O) \
+pngrcb.$(O) \
+pngrutil.$(O) \
+pngtrans.$(O) \
+pngwutil.$(O) \
+pngerror.$(O) \
+pngmem.$(O) \
+pngpread.$(O) \
+pngread.$(O) \
+pngerror.$(O) \
+pngwrite.$(O) \
+pngrcb.$(O) \
+pngrio.$(O) \
+pngrtran.$(O) \
+pngrutil.$(O) \
+pngtrans.$(O) \
+pngwrite.$(O) \
+pngwtran.$(O) \
+pngzlib.$(O) \
+pngio.$(O)
+pngwio.$(O)
+pngwutil.$(O)
LIBNAME=libpng$(MODEL).lib
@ -133,12 +133,12 @@ pngrtran.obj: pngrtran.c
pngrutil.obj: pngrutil.c
pngerror.obj: pngerror.c
pngmem.obj: pngmem.c
pngio.obj: pngio.c
pngrio.obj: pngrio.c
pngwio.obj: pngwio.c
pngtrans.obj: pngtrans.c
pngwrite.obj: pngwrite.c
pngwtran.obj: pngwtran.c
pngwutil.obj: pngwutil.c
pngzlib.obj: pngzlib.c
$(LIBNAME): $(OBJS)

View File

@ -4,19 +4,19 @@
CC=gcc
CFLAGS=-I../zlib -O2 -Wall -fPIC
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
LDFLAGS=-L. -Wl,-rpath,. -L../zlib/ -Wl,-rpath,../zlib/ -lpng -lz -lm
RANLIB=ranlib
#RANLIB=echo
PNGVER = 0.86
PNGVER = 0.89
# where make install puts libpng.a, libpng.so*, and png.h
prefix=/usr/local
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
pngmem.o pngerror.o pngpread.o
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
all: libpng.so pngtest
@ -59,7 +59,8 @@ clean:
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngio.o: png.h pngconf.h
pngrio.o: png.h pngconf.h
pngwio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngrcb.o: png.h pngconf.h
pngread.o: png.h pngconf.h

View File

@ -13,7 +13,7 @@ RANLIB=ranlib
prefix=.
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o pngwtran.o \
pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest
@ -35,7 +35,8 @@ clean:
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngio.o: png.h pngconf.h
pngrio.o: png.h pngconf.h
pngwio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngrcb.o: png.h pngconf.h
pngread.o: png.h pngconf.h

View File

@ -15,8 +15,8 @@ RANLIB=ranlib
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
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
all: ansi2knr libpng.a pngtest
@ -57,7 +57,8 @@ clean:
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngio.o: png.h pngconf.h
pngrio.o: png.h pngconf.h
pngwio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngrcb.o: png.h pngconf.h
pngread.o: png.h pngconf.h

View File

@ -14,8 +14,8 @@ RANLIB=echo
prefix=/usr/local
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
pngmem.o pngerror.o pngpread.o
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest
@ -46,7 +46,8 @@ clean:
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngio.o: png.h pngconf.h
pngrio.o: png.h pngconf.h
pngwio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngrcb.o: png.h pngconf.h
pngread.o: png.h pngconf.h

View File

@ -17,7 +17,7 @@ ERRFILE= >> pngerrs
# variables
OBJS1 = png$(O) pngrcb$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) pngmem$(O) pngpread$(O)
OBJS2 = pngread$(O) pngerror$(O) pngwrite$(O) pngrtran$(O) pngwtran$(O) pngio$(O)
OBJS2 = pngread$(O) pngerror$(O) pngwrite$(O) pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O)
all: libpng.lib
@ -45,7 +45,10 @@ pngerror$(O): png.h pngconf.h
pngmem$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngio$(O): png.h pngconf.h
pngrio$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwio$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngtest$(O): png.h pngconf.h

View File

@ -13,8 +13,8 @@ RANLIB=echo
prefix=/usr/local
OBJS = png.o pngrcb.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngio.o pngwrite.o pngrtran.o pngwtran.o \
pngmem.o pngerror.o pngpread.o
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest
@ -45,7 +45,8 @@ clean:
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngio.o: png.h pngconf.h
pngrio.o: png.h pngconf.h
pngwio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngrcb.o: png.h pngconf.h
pngread.o: png.h pngconf.h

View File

@ -14,9 +14,9 @@ O=.obj
# variables
OBJS1 = png$(O) pngrcb$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) pngmem$(O) pngpread$(O)
OBJS2 = pngread$(O) pngerror$(O) pngwrite$(O) pngrtran$(O) pngwtran$(O) pngio$(O)
OBJS2 = pngread$(O) pngerror$(O) pngwrite$(O) pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O)
OBJSL1 = +png$(O) +pngrcb$(O) +pngrutil$(O) +pngtrans$(O) +pngwutil$(O) +pngmem$(O) +pngpread$(O)
OBJSL2 = +pngread$(O) +pngerror$(O) +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) pngio$(O)
OBJSL2 = +pngread$(O) +pngerror$(O) +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O)
all: libpng.lib
@ -44,7 +44,10 @@ pngerror$(O): png.h pngconf.h
pngmem$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngio$(O): png.h pngconf.h
pngrio$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngwio$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c
pngtest$(O): png.h pngconf.h

View File

@ -52,8 +52,10 @@ $ CALL MAKE pngerror.OBJ "cc ''CCOPT' pngerror" -
pngerror.c png.h pngconf.h
$ CALL MAKE pngmem.OBJ "cc ''CCOPT' pngmem" -
pngmem.c png.h pngconf.h
$ CALL MAKE pngio.OBJ "cc ''CCOPT' pngio" -
pngio.c png.h pngconf.h
$ CALL MAKE pngrio.OBJ "cc ''CCOPT' pngrio" -
pngrio.c png.h pngconf.h
$ CALL MAKE pngwio.OBJ "cc ''CCOPT' pngwio" -
pngwio.c png.h pngconf.h
$ CALL MAKE pngtrans.OBJ "cc ''CCOPT' pngtrans" -
pngtrans.c png.h pngconf.h
$ CALL MAKE pngwrite.OBJ "cc ''CCOPT' pngwrite" -

60
png.c
View File

@ -1,10 +1,10 @@
/* png.c - location for general purpose png functions
libpng 1.0 beta 2 - version 0.88
libpng 1.0 beta 3 - version 0.89
For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 25, 1996
May 25, 1996
*/
#define PNG_INTERNAL
@ -13,7 +13,7 @@
/* version information for c files. This better match the version
string defined in png.h */
char png_libpng_ver[] = "0.88";
char png_libpng_ver[] = "0.89";
/* place to hold the signiture string for a png file. */
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
@ -25,39 +25,17 @@ png_byte FARDATA png_IHDR[4] = { 73, 72, 68, 82};
png_byte FARDATA png_IDAT[4] = { 73, 68, 65, 84};
png_byte FARDATA png_IEND[4] = { 73, 69, 78, 68};
png_byte FARDATA png_PLTE[4] = { 80, 76, 84, 69};
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
png_byte FARDATA png_gAMA[4] = {103, 65, 77, 65};
#endif
#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
png_byte FARDATA png_sBIT[4] = {115, 66, 73, 84};
#endif
#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
png_byte FARDATA png_cHRM[4] = { 99, 72, 82, 77};
#endif
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
png_byte FARDATA png_tRNS[4] = {116, 82, 78, 83};
#endif
#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
png_byte FARDATA png_bKGD[4] = { 98, 75, 71, 68};
#endif
#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
png_byte FARDATA png_hIST[4] = {104, 73, 83, 84};
#endif
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED)
png_byte FARDATA png_tEXt[4] = {116, 69, 88, 116};
#endif
#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
png_byte FARDATA png_zTXt[4] = {122, 84, 88, 116};
#endif
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
png_byte FARDATA png_pHYs[4] = {112, 72, 89, 115};
#endif
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
png_byte FARDATA png_oFFs[4] = {111, 70, 70, 115};
#endif
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
png_byte FARDATA png_tIME[4] = {116, 73, 77, 69};
#endif
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
@ -209,6 +187,21 @@ png_calculate_crc(png_structp png_ptr, png_bytep ptr,
{
png_ptr->crc = update_crc(png_ptr->crc, ptr, length);
}
png_infop
png_create_info_struct(png_structp png_ptr)
{
png_infop info_ptr;
if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL)
{
png_memset(info_ptr, 0, sizeof(png_info));
png_ptr->do_free |= PNG_FREE_INFO;
}
return info_ptr;
}
void
png_info_init(png_infop info)
{
@ -216,3 +209,20 @@ png_info_init(png_infop info)
png_memset(info, 0, sizeof (png_info));
}
/* This function returns a pointer to the io_ptr associated with the user
functions. The application should free any memory associated with this
pointer before png_write_destroy and png_read_destroy are called. */
png_voidp
png_get_io_ptr(png_structp png_ptr)
{
return png_ptr->io_ptr;
}
/* Initialize the default input/output functions for the png file. If you
change the read, or write routines, you can call either png_set_read_fn()
or png_set_write_fn() instead of png_init_io(). */
void
png_init_io(png_structp png_ptr, FILE *fp)
{
png_ptr->io_ptr = (png_voidp)fp;
}

547
png.h
View File

@ -1,8 +1,8 @@
/* png.h - header file for png reference library
libpng 1.0 beta 2 - version 0.88
Jan 25, 1996
libpng 1.0 beta 3 - version 0.89
May 25, 1996
Note: This is a beta version. It reads and writes valid files
on the platforms I have, but it has had limited portability
@ -74,10 +74,10 @@
/* version information for png.h - this should match the version
number in png.c */
#define PNG_LIBPNG_VER_STRING "0.88"
/* careful here. I wanted to use 088, but that would be octal. Version
#define PNG_LIBPNG_VER_STRING "0.89"
/* careful here. I wanted to use 089, but that would be octal. Version
1.0 will be 100 here, etc. */
#define PNG_LIBPNG_VER 88
#define PNG_LIBPNG_VER 89
/* variables defined in png.c - only it needs to define PNG_NO_EXTERN */
#ifndef PNG_NO_EXTERN
@ -88,11 +88,7 @@ extern char png_libpng_ver[];
/* three color definitions. The order of the red, green, and blue, (and the
exact size) is not important, although the size of the fields need to
be png_byte or png_uint_16 (as defined below). While png_color_8 and
png_color_16 have more fields then they need, they are never used in
arrays, so the size isn't that important. I thought about using
unions, but it looked too clumsy, so I left it. If you're using C++,
you can union red, index, and gray, if you really want too. */
be png_byte or png_uint_16 (as defined below). */
typedef struct png_color_struct
{
png_byte red;
@ -144,7 +140,6 @@ typedef struct png_time_struct
{
png_uint_16 year; /* full year, as in, 1995 */
png_byte month; /* month of year, 1 - 12 */
png_byte day; /* day of month, 1 - 31 */
png_byte hour; /* hour of day, 0 - 23 */
png_byte minute; /* minute of hour, 0 - 59 */
@ -165,18 +160,22 @@ typedef struct png_info_struct
/* the following are necessary for every png file */
png_uint_32 width; /* with of file */
png_uint_32 height; /* height of file */
png_uint_32 valid; /* the PNG_INFO_ defines, OR'd together */
png_uint_32 rowbytes; /* bytes needed for untransformed row */
png_colorp palette; /* palette of file */
png_uint_16 num_palette; /* number of values in palette */
png_uint_16 num_trans; /* number of trans values */
png_byte bit_depth; /* 1, 2, 4, 8, or 16 */
png_byte color_type; /* use the PNG_COLOR_TYPE_ defines */
png_byte compression_type; /* must be 0 */
png_byte filter_type; /* must be 0 */
png_byte interlace_type; /* 0 for non-interlaced, 1 for interlaced */
png_uint_32 valid; /* the PNG_INFO_ defines, OR'd together */
/* the following is informational only on read, and not used on
writes */
png_byte channels; /* number of channels of data per pixel */
png_byte pixel_depth; /* number of bits per pixel */
png_byte spare_byte; /* To align the data, and for future use */
png_uint_32 rowbytes; /* bytes needed for untransformed row */
/* the rest are optional. If you are reading, check the valid
field to see if the information in these are valid. If you
are writing, set the valid field to those chunks you want
@ -184,9 +183,38 @@ typedef struct png_info_struct
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
float gamma; /* gamma value of file, if gAMA chunk is valid */
#endif
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
int num_text; /* number of comments */
int max_text; /* size of text array */
png_textp text; /* array of comments */
#endif
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
png_time mod_time; /* modification time */
#endif
#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
png_color_8 sig_bit; /* significant bits */
#endif
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
png_bytep trans; /* tRNS values for palette image */
png_color_16 trans_values; /* tRNS values for non-palette image */
#endif
#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
png_color_16 background; /* background color of image */
#endif
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
png_uint_32 x_offset; /* x offset on page */
png_uint_32 y_offset; /* y offset on page */
png_byte offset_unit_type; /* offset units type */
#endif
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
png_uint_32 x_pixels_per_unit; /* x resolution */
png_uint_32 y_pixels_per_unit; /* y resolution */
png_byte phys_unit_type; /* resolution type */
#endif
#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
png_uint_16p hist; /* histogram of palette usage */
#endif
#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
float x_white; /* cHRM chunk values */
float y_white;
@ -196,62 +224,31 @@ typedef struct png_info_struct
float y_green;
float x_blue;
float y_blue;
#endif
png_colorp palette; /* palette of file */
png_uint_16 num_palette; /* number of values in palette */
png_uint_16 num_trans; /* number of trans values */
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
png_bytep trans; /* tRNS values for palette image */
png_color_16 trans_values; /* tRNS values for non-palette image */
#endif
#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
png_color_16 background; /* background color of image */
#endif
#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
png_uint_16p hist; /* histogram of palette usage */
#endif
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
png_uint_32 x_pixels_per_unit; /* x resolution */
png_uint_32 y_pixels_per_unit; /* y resolution */
png_byte phys_unit_type; /* resolution type */
#endif
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
png_uint_32 x_offset; /* x offset on page */
png_uint_32 y_offset; /* y offset on page */
png_byte offset_unit_type; /* offset units type */
#endif
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
png_time mod_time; /* modification time */
#endif
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
int num_text; /* number of comments */
int max_text; /* size of text array */
png_textp text; /* array of comments */
#endif
} png_info;
typedef png_info FAR * png_infop;
typedef png_info FAR * FAR * png_infopp;
#define PNG_RESOLUTION_UNKNOWN 0
#define PNG_RESOLUTION_METER 1
#define PNG_RESOLUTION_METER 1
#define PNG_RESOLUTION_LAST 2
#define PNG_OFFSET_PIXEL 0
#define PNG_OFFSET_MICROMETER 1
#define PNG_OFFSET_PIXEL 0
#define PNG_OFFSET_MICROMETER 1
#define PNG_OFFSET_LAST 2
/* these describe the color_type field in png_info */
/* color type masks */
#define PNG_COLOR_MASK_PALETTE 1
#define PNG_COLOR_MASK_COLOR 2
#define PNG_COLOR_MASK_ALPHA 4
#define PNG_COLOR_MASK_COLOR 2
#define PNG_COLOR_MASK_ALPHA 4
/* color types. Note that not all combinations are legal */
#define PNG_COLOR_TYPE_GRAY 0
#define PNG_COLOR_TYPE_PALETTE \
(PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
#define PNG_COLOR_TYPE_GRAY 0
#define PNG_COLOR_TYPE_RGB_ALPHA \
(PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
@ -269,11 +266,6 @@ 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 to be freed */
#define PNG_FREE_PALETTE 0x0001
#define PNG_FREE_HIST 0x0002
#define PNG_FREE_TRANS 0x0004
/* this is used for the transformation routines, as some of them
change these values for the row. It also should enable using
the routines for other uses. */
@ -291,14 +283,14 @@ typedef png_row_info FAR * png_row_infop;
typedef png_row_info FAR * FAR * png_row_infopp;
/* These are the function types for the I/O functions, and the functions which
* modify the default I/O functions to user I/O functions. The png_msg_ptr
* modify the default I/O functions to user I/O functions. The png_error_ptr
* type should match that of user supplied warning and error functions, while
* the png_rw_ptr type should match that of the user read/write data functions.
*/
typedef struct png_struct_def png_struct;
typedef png_struct FAR * png_structp;
typedef void (*png_msg_ptr) PNGARG((png_structp, png_const_charp));
typedef void (*png_error_ptr) PNGARG((png_structp, png_const_charp));
typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_uint_32));
typedef void (*png_flush_ptr) PNGARG((png_structp));
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
@ -316,55 +308,28 @@ typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
struct png_struct_def
{
jmp_buf jmpbuf; /* used in png_error */
png_error_ptr error_fn; /* Function for printing errors and aborting */
png_error_ptr warning_fn; /* Function for printing warnings */
png_voidp error_ptr; /* user supplied struct for error functions */
png_rw_ptr write_data_fn; /* Function for writing output data */
png_rw_ptr read_data_fn; /* Function for reading input data */
png_voidp io_ptr; /* Pointer to user supplied struct for I/O functions */
png_byte mode; /* used to determine where we are in the png file */
png_byte read_mode;
png_byte color_type; /* color type of file */
png_byte bit_depth; /* bit depth of file */
png_byte interlaced; /* interlace type of file */
png_byte compession; /* compression type of file */
png_byte filter; /* filter type */
png_byte channels; /* number of channels in file */
png_byte pixel_depth; /* number of bits per pixel */
png_byte usr_bit_depth; /* bit depth of users row */
png_byte usr_channels; /* channels at start of write */
#if defined(PNG_READ_GAMMA_SUPPORTED)
png_byte gamma_shift; /* amount of shift for 16 bit gammas */
#endif
png_byte pass; /* current pass (0 - 6) */
png_byte row_init; /* 1 if png_read_start_row() has been called */
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
png_byte background_gamma_type;
png_byte background_expand;
#endif
png_byte zlib_finished;
png_byte user_palette;
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
png_byte filler;
png_byte filler_loc;
#endif
png_byte zlib_custom_level; /* one if custom compression level */
png_byte zlib_custom_method; /* one if custom compression method */
png_byte zlib_custom_window_bits; /* one if custom compression window bits */
png_byte zlib_custom_mem_level; /* one if custom compression memory level */
png_byte zlib_custom_strategy; /* one if custom compression strategy */
png_byte do_filter; /* one if filtering, zero if not */
png_byte do_custom_filter; /* one if filtering, zero if not */
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
png_byte have_chunk_header;
#endif
png_uint_16 num_palette; /* number of entries in palette */
png_uint_16 num_trans; /* number of transparency values */
png_uint_32 do_free; /* flags indicating if libpng should free memory */
png_uint_32 flags; /* flags indicating various things to libpng */
png_uint_32 transformations; /* which transformations to perform */
z_stream * zstream; /* pointer to decompression structure (below) */
png_bytep zbuf; /* buffer for zlib */
png_uint_32 zbuf_size; /* size of zbuf */
int zlib_level; /* holds zlib compression level */
int zlib_method; /* holds zlib compression method */
int zlib_window_bits; /* holds zlib compression window bits */
int zlib_mem_level; /* holds zlib compression memory level */
int zlib_strategy; /* holds zlib compression strategy */
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
int process_mode;
int cur_palette;
#endif
png_uint_32 transformations; /* which transformations to perform */
png_uint_32 crc; /* current crc value */
png_uint_32 width; /* width of file */
png_uint_32 height; /* height of file */
png_uint_32 num_rows; /* number of rows in current pass */
@ -373,20 +338,87 @@ struct png_struct_def
png_uint_32 iwidth; /* interlaced width */
png_uint_32 irowbytes; /* interlaced rowbytes */
png_uint_32 row_number; /* current row in pass */
png_bytep row_buf; /* row buffer */
png_bytep prev_row; /* previous row */
png_bytep sub_row; /* place to save row when filtering */
png_bytep up_row; /* place to save row when filtering */
png_bytep avg_row; /* place to save row when filtering */
png_bytep paeth_row; /* place to save row when filtering */
png_row_info row_info; /* used for transformation routines */
png_uint_32 idat_size; /* current idat size for read */
png_uint_32 zbuf_size; /* size of zbuf */
png_uint_32 do_free; /* flags indicating if libpng should free memory */
png_uint_32 crc; /* current crc value */
png_colorp palette; /* files palette */
png_uint_16 num_palette; /* number of entries in palette */
png_uint_16 num_trans; /* number of transparency values */
png_byte interlaced; /* interlace type of file */
png_byte pass; /* current pass (0 - 6) */
png_byte compression; /* compression type of file */
png_byte filter; /* filter type */
png_byte do_filter; /* non-zero if row filtering, zero if not */
png_byte color_type; /* color type of file */
png_byte bit_depth; /* bit depth of file */
png_byte usr_bit_depth; /* bit depth of users row */
png_byte pixel_depth; /* number of bits per pixel */
png_byte channels; /* number of channels in file */
png_byte usr_channels; /* channels at start of write */
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
png_byte filler; /* filler byte to be used for 32-bit frame buffers */
#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
png_byte background_gamma_type;
float background_gamma;
png_color_16 background; /* background color, gamma corrected for screen */
#if defined(PNG_READ_GAMMA_SUPPORTED)
png_color_16 background_1; /* background normalized to gamma 1.0 */
#endif
#endif
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
png_flush_ptr output_flush_fn;/* Function for flushing output */
png_uint_32 flush_dist; /* how many rows apart to flush, 0 for no flush */
png_uint_32 flush_rows; /* number of rows written since last flush */
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
#if defined(PNG_READ_GAMMA_SUPPORTED)
int gamma_shift; /* amount of shift for 16 bit gammas */
float gamma; /* file gamma value */
float display_gamma; /* display gamma value */
#endif
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep gamma_table; /* gamma table for 8 bit depth files */
png_bytep gamma_from_1; /* converts from 1.0 to screen */
png_bytep gamma_to_1; /* converts from file to 1.0 */
png_uint_16pp gamma_16_table; /* gamma table for 16 bit depth files */
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
#endif
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined (PNG_READ_sBIT_SUPPORTED)
png_color_8 sig_bit; /* significant bits in file */
#endif
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep trans; /* transparency values for paletted files */
png_color_16 trans_values; /* transparency values for non-paletted files */
#endif
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
png_color_8 shift; /* shift for significant bit tranformation */
#endif
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
png_progressive_info_ptr info_fn;
png_progressive_row_ptr row_fn;
png_progressive_end_ptr end_fn;
png_bytep save_buffer_ptr;
png_bytep save_buffer;
png_bytep current_buffer_ptr;
png_bytep current_buffer;
png_uint_32 push_length;
png_uint_32 skip_length;
png_uint_32 save_buffer_size;
png_uint_32 save_buffer_max;
png_uint_32 buffer_size;
png_uint_32 current_buffer_size;
int process_mode;
int cur_palette;
png_byte push_chunk_name[4];
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
png_uint_32 current_text_size;
png_uint_32 current_text_left;
@ -401,85 +433,29 @@ struct png_struct_def
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;
png_bytep save_buffer;
png_bytep current_buffer_ptr;
png_bytep current_buffer;
#endif
png_colorp palette; /* files palette */
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
#if defined(PNG_READ_DITHER_SUPPORTED)
png_bytep palette_lookup; /* lookup table for dithering */
#endif
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep gamma_table; /* gamma table for 8 bit depth files */
#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep gamma_from_1; /* converts from 1.0 to screen */
png_bytep gamma_to_1; /* converts from file to 1.0 */
#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep trans; /* transparency values for paletted files */
#endif
#if defined(PNG_READ_DITHER_SUPPORTED)
png_bytep dither_index; /* index translation for palette files */
#endif
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_uint_16pp gamma_16_table; /* gamma table for 16 bit depth files */
#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
#endif
#if defined(PNG_READ_DITHER_SUPPORTED)
png_uint_16p hist; /* histogram */
#endif
png_bytep zbuf; /* buffer for zlib */