diff --git a/CHANGES b/CHANGES index 57d3e7150920dee557138316d689e6bdda5f0d6f..100e02b01534c7d22fa2643cf34f6bdd1b23c0be 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -pngchange.txt - changes for libpng +CHANGES - changes for libpng version 0.2 added reader into png.h @@ -244,3 +244,21 @@ version 0.99e [February 28, 1998] Replaced pngtest.png with one created with zlib 1.1.1 Changed pngtest to report PASS even when file size is different (Jean-loup G.) Corrected some logic errors in png_do_invert_alpha() (Chris Patterson) +version 0.99f [March 5, 1998] + Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey) + Moved makefiles into a "scripts" directory, and added INSTALL instruction file + Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok) + Added pointers to "note on libpng versions" in makefile.lnx and README + Added row callback feature when reading and writing nonprogressive rows + and added a test of this feature in pngtest.c + Added user transform callbacks, with test of the feature in pngtest.c +version 0.99g [March 6, 1998, morning] + Minor changes to pngtest.c to suppress compiler warnings. + Removed "beta" language from documentation. +version 0.99h [March 6, 1998, evening] + Minor changes to previous minor changes to pngtest.c + Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED + and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro +version 1.00 [March 7, 1998] + Changed several typedefs in pngrutil.c + Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik) diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000000000000000000000000000000000000..a14e1acb36ddd2bbf9110f8fd02fd69d4f96100f --- /dev/null +++ b/INSTALL @@ -0,0 +1,85 @@ + +Installing libpng version 1.00 March 7, 1998 + +Before installing libpng, you must first install zlib. zlib +can usually be found wherever you got libpng. zlib can be +placed in another directory, at the same level as libpng. +Note that your system might already have a preinstalled +zlib, but you will still need to have access to the +zlib.h and zconf.h include files that correspond to the +version of zlib that's installed. + +You can rename the directories that you downloaded (they +might be called "libpng-1.00 or "lpng100" and "zlib-1.1.1" +or "zlib111") so that you have directories called "zlib" and "libpng". + +Your directory structure should look like this: + + .. (the parent directory) + libpng (this directory) + INSTALL (this file) + README + *.h + *.c + scripts + makefile.* + pngtest.png + etc. + zlib + README + *.h + *.c + contrib + etc. + +First enter the zlib directory and follow the instructions +in zlib/README. Then come back here and choose the +appropriate makefile.sys in the scripts directory. +The files that are presently available in the scripts directory +include + + descrip.mms => VMS makefile for MMS or MMK + makefile.std => Generic UNIX makefile + makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr + makefile.dec => DEC Alpha UNIX makefile + makefile.sgi => Silicon Graphics IRIX makefile + makefile.sun => Sun makefile + makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.00) + makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.00) + makefile.mip => MIPS makefile + makefile.aco => Acorn makefile + makefile.ama => Amiga makefile + makefile.atr => Atari makefile + makefile.bor => Borland makefile + build.bat => MS-DOS batch file for Borland compiler + makefile.dj2 => DJGPP 2 makefile + makefile.msc => Microsoft C makefile + makefile.tc3 => Turbo C 3.0 makefile + makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) + pngos2.def => OS/2 module definition file used by makefile.os2 + makefile.wat => Watcom 10a+ Makefile, 32-bit flat memory model + makevms.com => VMS build script + +Copy the file (or files) that you need from the +scripts directory into this directory, for example + + MSDOS example: copy scripts\makefile.msd makefile + UNIX example: cp scripts/makefile.std makefile + +Read the makefile to see if you need to change any source or +target directories to match your preferences. + +Then read pngconf.h to see if you want to make any configuration +changes. + +Then just run "make test" which will create the libpng library in +this directory and run a quick test that reads the "pngtest.png" +file and writes a "pngout.png" file that should be identical to it. + +Most of the makefiles will allow you to run "make install" to +put the library in its final resting place (if you want to +do that, run "make install" in the zlib directory first if necessary). + +Further information can be found in the README and libpng.txt +files, in the individual makefiles, and in png.h, and the manual +pages libpng.3 and png.5. diff --git a/README b/README index be12d5e55168430b932bcdb36ab8b4dafc42ccc4..4390f6a45ee55f0addd6edf1f0a36bc2f69a0429 100644 --- a/README +++ b/README @@ -1,8 +1,7 @@ -[NOTE: this is still beta version 0.99e; the text below has already - been updated in anticipation of the imminent 1.0 release.] +README for libpng 1.00 (shared library 2.1) +See the note about version numbers near the top of png.h - -README for libpng 1.0 +See INSTALL for instructions on how to install libpng. This is the first official release of libpng. Don't let the fact that it's the first release fool you. The libpng library has been in @@ -117,7 +116,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 a couple years now, and it is official and +been discussing PNG for three years 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. @@ -135,21 +134,6 @@ Files in this distribution: libpng.3 => manual page for libpng libpng.txt => Description of libpng and its functions libpngpf.3 => manual page for libpng's private functions - makefile.aco => ACORN makefile - makefile.ama => Amiga makefile - makefile.atr => Atari makefile - makefile.bor => Borland makefile - makefile.dec => DEC makefile - makefile.dj2 => DJGPP 2 makefile - makefile.knr => Makefile which calls ansi2knr to convert files - makefile.lnx => Unix Linux/ELF makefile - makefile.mip => MIPS makefile - makefile.msc => Microsoft C makefile - makefile.sgi => Silicon Graphics Irix makefile - makefile.std => Standard Unix makefile - makefile.sun => SUN makefile - makefile.tc3 => Turbo C 3.0 makefile - makevms.com => VMS make program png.5 => manual page for the PNG format png.c => Basic interface functions common to library png.h => Library function and interface declarations @@ -170,6 +154,28 @@ Files in this distribution: pngwrite.c => High-level write functions pngwtran.c => Write data transformations pngwutil.c => Write utility functions + scripts => Directory containing scripts for building libpng: + descrip.mms => VMS makefile for MMS or MMK + makefile.std => Generic UNIX makefile + makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr + makefile.dec => DEC Alpha UNIX makefile + makefile.sgi => Silicon Graphics IRIX makefile + makefile.sun => Sun makefile + makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.00) + makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.00) + makefile.mip => MIPS makefile + makefile.aco => Acorn makefile + makefile.ama => Amiga makefile + makefile.atr => Atari makefile + makefile.bor => Borland makefile + build.bat => MS-DOS batch file for Borland compiler + makefile.dj2 => DJGPP 2 makefile + makefile.msc => Microsoft C makefile + makefile.tc3 => Turbo C 3.0 makefile + makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) + makefile.wat => Watcom 10a+ Makefile, 32-bit flat memory model + pngos2.def => OS/2 module definition file used by makefile.os2 + makevms.com => VMS build script Good luck, and happy coding. diff --git a/TODO b/TODO index 93e98112da610ec35145a71e70e28c1d6ef9f2d4..245e602f82cf45758469ef626aeb6585b6548cc4 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -pngtodo.txt - list of things to do for libpng +TODO - list of things to do for libpng add "grayscale->palette" transformation and "palette->grayscale" detection improved dithering diff --git a/example.c b/example.c index e4b5c468d63757d238f6be1f3b85b507b5c70490..f984067cc6b4aba36be54859979baf489c4a6679 100644 --- a/example.c +++ b/example.c @@ -1,3 +1,4 @@ + /* example.c - an example of using libpng */ /* This is an example of how to use libpng to read and write PNG files. diff --git a/libpng.3 b/libpng.3 index 5e55a401adf7a07b81429cce3f63eb303b4d89bb..b5269d72f3de527b179ab3dd6fd40ef87fe0c748 100644 --- a/libpng.3 +++ b/libpng.3 @@ -1,4 +1,4 @@ -.TH LIBPNG 3 "February 28, 1998" +.TH LIBPNG 3 "March 7, 1998" .SH NAME libpng \- Portable Network Graphics (PNG) Reference Library .SH SYNOPSIS @@ -301,6 +301,12 @@ png_colorp palette, int num_palette); void png_set_read_fn (png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn); +void png_set_read_status_fn (png_structp png_ptr, png_read_status_ptr + read_row_fn); + +void png_set_read_user_transform_fn (png_structp png_ptr, + png_user_transform_ptr read_user_transform_fn); + void png_set_rgb_to_gray (png_structp png_ptr); void png_set_sBIT (png_structp png_ptr, png_infop info_ptr, @@ -337,6 +343,12 @@ png_bytep trans, int num_trans, png_color_16p trans_values); 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); +void png_set_write_status_fn (png_structp png_ptr, png_write_status_ptr + write_row_fn); + +void png_set_write_user_transform_fn (png_structp png_ptr, + png_user_transform_ptr write_user_transform_fn); + int png_sig_cmp (png_bytep sig, png_size_t start, png_size_t num_to_check); @@ -384,23 +396,23 @@ Following is a copy of the libpng.txt file that accompanies libpng. .SH LIBPNG.TXT libpng.txt - A description on how to use and modify libpng - libpng version 0.99e + libpng version 1.00 March 7, 1998 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998, Glenn Randers-Pehrson - February 28, 1998 + For conditions of distribution and use, see copyright + notice in png.h. based on: - libpng 1.0 beta 6 version 0.96 + libpng 1.0 beta 6 version 0.96 May 28, 1997 Updated and distributed by Andreas Dilger Copyright (c) 1996, 1997 Andreas Dilger - May 28, 1997 - libpng 1.0 beta 2 - version 0.88 + libpng 1.0 beta 2 - version 0.88 January 26, 1996 For conditions of distribution and use, see copyright notice in png.h. Copyright (c) 1995, 1996 Guy Eric - Schalnat, Group 42, Inc. January 26, 1996 + Schalnat, Group 42, Inc. Updated/rewritten per request in the libpng FAQ Copyright (c) 1995 Frank J. T. Wojcik @@ -414,7 +426,8 @@ file: introduction, structures, reading, writing, and modification and 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. +will need. We assume that libpng is already installed; see the +INSTALL file for instructions on how to install libpng. Libpng was written as a companion to the PNG specification, as a way of reducing the amount of time and effort it takes to support the PNG @@ -586,6 +599,22 @@ libpng know that there are some bytes missing from the start of the file. png_set_sig_bytes(png_ptr, number); +At this point, you can set up a callback function that will be +called after each row has been read, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void read_row_callback(png_ptr, png_uint_32 row, int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "read_row_callback") + +To inform libpng about your function, use + + png_set_read_status_fn(png_ptr, read_row_callback); + In PNG files, the alpha channel in an image is the level of opacity. If you need the alpha channel in an image to be the level of transparency instead of opacity, you can invert the alpha channel (or the tRNS chunk @@ -599,6 +628,21 @@ because the tRNS chunk data must be modified in the case of paletted images. If your image is not a paletted image, the tRNS data (which in such cases represents a single color to be rendered as transparent) won't be changed. +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_read_user_transform_fn(png_ptr, + read_transform_fn); + +You must supply the function + + void read_transform_fn(png_ptr ptr, row_info_ptr + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +after all of the other transformations have been processed. + You are now ready to read all the file information up to the actual image data. You do this with a call to png_read_info(). @@ -958,9 +1002,8 @@ the overall gamma correction required to produce pleasing results, which depends on the lighting conditions in the surrounding environment. Screen_gamma is display_gamma/viewing_gamma, where viewing_gamma is the amount of additional gamma correction needed to compensate for -a dark (viewing_gamma=1.25) environment. -In a dim or brightly lit room, no compensation other than the display_gamma -is needed (viewing_gamma=1.0). +a (viewing_gamma=1.25) environment. In a dim or brightly lit room, no +compensation other than the display_gamma is needed (viewing_gamma=1.0). if (/* We have a user-defined screen gamma value */) @@ -1299,6 +1342,7 @@ png_infop info_ptr; read. */ void + info_callback(png_structp png_ptr, png_infop info) { /* Do any setup here, including setting any of the transformations mentioned in the Reading @@ -1368,8 +1412,6 @@ png_infop info_ptr; */ } - - .SH IV. Writing Much of this is very similar to reading. However, everything of @@ -1390,7 +1432,10 @@ custom writing functions. See the discussion under Customizing libpng. Next, png_struct and png_info need to be allocated and initialized. As these can be both relatively large, you may not want to store these on the stack, unless you have stack space to spare. Of course, you -will want to check if they return NULL. +will want to check if they return NULL. If you are also reading, +you won't want to name your read structure and your write structure +both "png_ptr"; you can call them anything you like, such as +"read_ptr" and "write_ptr". Look at pngtest.c, for example. png_structp png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, (void *)user_error_ptr, @@ -1433,6 +1478,22 @@ Libpng section below. png_init_io(png_ptr, fp); +At this point, you can set up a callback function that will be +called after each row has been written, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void write_row_callback(png_ptr, png_uint_32 row, int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "write_row_callback") + +To inform libpng about your function, use + + png_set_write_status_fn(png_ptr, write_row_callback); + You now have the option of modifying how the compression library will run. The following functions are mainly for testing, but may be useful in some cases, like if you need to write PNG files extremely fast and @@ -1789,6 +1850,21 @@ one. This code would be used if the pixels are supplied with this reversed png_set_invert_mono(png_ptr); +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_write_user_transform_fn(png_ptr, + write_transform_fn); + +You must supply the function + + void write_transform_fn(png_ptr ptr, row_info_ptr + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +before any of the other transformations have been processed. + It is possible to have libpng flush any pending output, either manually, or automatically after a certain number of lines have been written. To flush the output stream a single time call: @@ -2143,15 +2219,18 @@ There are a bunch of #define's in pngconf.h that control what parts of libpng are compiled. All the defines end in _SUPPORTED. If you are never going to use an ability, you can change the #define to #undef before recompiling libpng and save yourself code and data space. -You can also turn them off en masse with a compiler directive that -defines PNG_READ[or WRITE]_NOT_FULLY_SUPPORTED, or +You can also turn a number of them off en masse with a compiler directive +that defines PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED, or PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four, along with directives to turn on any of the capabilities that you do -want. The NOT_FULLY_SUPPORTED directives disable the extra -transformations but still leave the library fully capable of reading +want. The PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED directives disable +the extra transformations but still leave the library fully capable of reading and writing PNG files with all known public chunks [except for sPLT]. Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive produces a library that is incapable of reading or writing ancillary chunks. +If you are not using the progressive reading capability, you can +turn that off with PNG_PROGRESSIVE_READ_NOT_SUPPORTED (don't confuse +this with the INTERLACING capability, which you'll still have). All the reading and writing specific code are in separate files, so the linker should only grab the files it needs. However, if you want to @@ -2227,9 +2306,7 @@ the first widely used release: 0.97c 0.97 2.0.97 0.98 0.98 2.0.98 0.99 0.99 2.0.99 - 0.99a 0.99 2.0.99 - 0.99b 0.99 2.0.99 - 0.99e 0.99 2.0.99 + 0.99a-g 0.99 2.0.99 1.0 1.00 2.1.0 Henceforth the source version will match the shared-library minor @@ -2288,7 +2365,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation. -Libpng version 0.99e (February 28, 1998): +Libpng version 1.00 (March 7, 1998): Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Currently maintained by Glenn Randers-Pehrson (randeg@alumni.rpi.edu). @@ -2296,17 +2373,6 @@ Supported by the PNG development group .br (png-implement@dworkin.wustl.edu). -.SH BETA NOTICE -This is a beta version. It reads and writes valid files on the -platforms I have, and has had a wide testing program. You may -have to modify the includes in png.h to get it to work on your -system, and you may have to supply the correct compiler flags in -the makefile if you can't find a makefile suitable for your -operating system/compiler combination. Please contact the authors -via the mailing list png-implement@dworkin.wustl.edu if you have any -problems, or if you want your compiler/platform to be supported in -the next official libpng release. - .SH COPYRIGHT NOTICE: The PNG Reference Library (libpng) is supplied "AS IS". The Contributing diff --git a/libpng.txt b/libpng.txt index 9638dabce229bd6886f8ceab4ab736447b13a45f..3740fbe562b9c6618a48d1b3cd60002212035cea 100644 --- a/libpng.txt +++ b/libpng.txt @@ -1,22 +1,22 @@ libpng.txt - A description on how to use and modify libpng - libpng version 0.99e + libpng version 1.00 March 7, 1998 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998, Glenn Randers-Pehrson - February 28, 1998 + For conditions of distribution and use, see copyright + notice in png.h. based on: - libpng 1.0 beta 6 version 0.96 + libpng 1.0 beta 6 version 0.96 May 28, 1997 Updated and distributed by Andreas Dilger Copyright (c) 1996, 1997 Andreas Dilger - May 28, 1997 - libpng 1.0 beta 2 - version 0.88 + libpng 1.0 beta 2 - version 0.88 January 26, 1996 For conditions of distribution and use, see copyright notice in png.h. Copyright (c) 1995, 1996 Guy Eric - Schalnat, Group 42, Inc. January 26, 1996 + Schalnat, Group 42, Inc. Updated/rewritten per request in the libpng FAQ Copyright (c) 1995 Frank J. T. Wojcik @@ -30,7 +30,8 @@ file: introduction, structures, reading, writing, and modification and 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. +will need. We assume that libpng is already installed; see the +INSTALL file for instructions on how to install libpng. Libpng was written as a companion to the PNG specification, as a way of reducing the amount of time and effort it takes to support the PNG @@ -202,6 +203,22 @@ libpng know that there are some bytes missing from the start of the file. png_set_sig_bytes(png_ptr, number); +At this point, you can set up a callback function that will be +called after each row has been read, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void read_row_callback(png_ptr, png_uint_32 row, int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "read_row_callback") + +To inform libpng about your function, use + + png_set_read_status_fn(png_ptr, read_row_callback); + In PNG files, the alpha channel in an image is the level of opacity. If you need the alpha channel in an image to be the level of transparency instead of opacity, you can invert the alpha channel (or the tRNS chunk @@ -215,6 +232,21 @@ because the tRNS chunk data must be modified in the case of paletted images. If your image is not a paletted image, the tRNS data (which in such cases represents a single color to be rendered as transparent) won't be changed. +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_read_user_transform_fn(png_ptr, + read_transform_fn); + +You must supply the function + + void read_transform_fn(png_ptr ptr, row_info_ptr + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +after all of the other transformations have been processed. + You are now ready to read all the file information up to the actual image data. You do this with a call to png_read_info(). @@ -914,6 +946,7 @@ png_infop info_ptr; read. */ void + info_callback(png_structp png_ptr, png_infop info) { /* Do any setup here, including setting any of the transformations mentioned in the Reading @@ -1005,7 +1038,10 @@ custom writing functions. See the discussion under Customizing libpng. Next, png_struct and png_info need to be allocated and initialized. As these can be both relatively large, you may not want to store these on the stack, unless you have stack space to spare. Of course, you -will want to check if they return NULL. +will want to check if they return NULL. If you are also reading, +you won't want to name your read structure and your write structure +both "png_ptr"; you can call them anything you like, such as +"read_ptr" and "write_ptr". Look at pngtest.c, for example. png_structp png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, (void *)user_error_ptr, @@ -1048,6 +1084,22 @@ Libpng section below. png_init_io(png_ptr, fp); +At this point, you can set up a callback function that will be +called after each row has been written, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void write_row_callback(png_ptr, png_uint_32 row, int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "write_row_callback") + +To inform libpng about your function, use + + png_set_write_status_fn(png_ptr, write_row_callback); + You now have the option of modifying how the compression library will run. The following functions are mainly for testing, but may be useful in some cases, like if you need to write PNG files extremely fast and @@ -1404,6 +1456,21 @@ one. This code would be used if the pixels are supplied with this reversed png_set_invert_mono(png_ptr); +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_write_user_transform_fn(png_ptr, + write_transform_fn); + +You must supply the function + + void write_transform_fn(png_ptr ptr, row_info_ptr + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +before any of the other transformations have been processed. + It is possible to have libpng flush any pending output, either manually, or automatically after a certain number of lines have been written. To flush the output stream a single time call: @@ -1758,15 +1825,18 @@ There are a bunch of #define's in pngconf.h that control what parts of libpng are compiled. All the defines end in _SUPPORTED. If you are never going to use an ability, you can change the #define to #undef before recompiling libpng and save yourself code and data space. -You can also turn them off en masse with a compiler directive that -defines PNG_READ[or WRITE]_NOT_FULLY_SUPPORTED, or +You can also turn a number of them off en masse with a compiler directive +that defines PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED, or PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four, along with directives to turn on any of the capabilities that you do -want. The NOT_FULLY_SUPPORTED directives disable the extra -transformations but still leave the library fully capable of reading +want. The PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED directives disable +the extra transformations but still leave the library fully capable of reading and writing PNG files with all known public chunks [except for sPLT]. Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive produces a library that is incapable of reading or writing ancillary chunks. +If you are not using the progressive reading capability, you can +turn that off with PNG_PROGRESSIVE_READ_NOT_SUPPORTED (don't confuse +this with the INTERLACING capability, which you'll still have). All the reading and writing specific code are in separate files, so the linker should only grab the files it needs. However, if you want to diff --git a/libpngpf.3 b/libpngpf.3 index 205348ef81fe8795671b8f19d2d8c17ecbd5bee4..082c47ebdd220c8554fe67ccc28c6c38a606fda8 100644 --- a/libpngpf.3 +++ b/libpngpf.3 @@ -1,4 +1,4 @@ -.TH LIBPNGPF 3 "February 28, 1998" +.TH LIBPNGPF 3 "March 7, 1998" .SH NAME libpng \- Portable Network Graphics (PNG) Reference Library (private functions) diff --git a/png.5 b/png.5 index 1948b412f0b6c58358bc60b928a882247abd5e28..49d6959cc91c5261c68c49d37defd720c788e9a1 100644 --- a/png.5 +++ b/png.5 @@ -1,4 +1,4 @@ -.TH PNG 5 "February 28, 1998" +.TH PNG 5 "March 7, 1998" .SH NAME png \- Portable Network Graphics (PNG) format .SH DESCRIPTION diff --git a/png.c b/png.c index 06916e87d1f80fcf7946e461f240dbfb98e546b6..bbbf8e4851760d4f433e5d84a2d695647a95d34c 100644 --- a/png.c +++ b/png.c @@ -1,12 +1,12 @@ /* png.c - location for general purpose libpng functions * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 */ #define PNG_INTERNAL @@ -16,7 +16,7 @@ /* Version information for C files. This had better match the version * string defined in png.h. */ -char png_libpng_ver[5] = "0.99"; +char png_libpng_ver[5] = "1.00"; /* Place to hold the signature string for a PNG file. */ png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; @@ -185,7 +185,7 @@ png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) } if (need_crc) - png_ptr->crc = crc32(png_ptr->crc, ptr, length); + png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); } /* Allocate the memory for an info_struct for the application. We don't diff --git a/png.h b/png.h index 18179bd0107f9cdbf317dc9ebba69981874b1324..13cb5a5b2797d3e525e0f115ae5eeb49d52e763a 100644 --- a/png.h +++ b/png.h @@ -1,12 +1,12 @@ /* png.h - header file for PNG reference library * - * libpng 0.99e beta + * libpng 1.00 * For conditions of distribution and use, see the COPYRIGHT NOTICE below. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998 Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 * * Note about libpng version numbers: * @@ -27,27 +27,13 @@ * 0.97c 0.97 2.0.97 * 0.98 0.98 2.0.98 * 0.99 0.99 2.0.99 - * 0.99a 0.99 2.0.99 - * 0.99b 0.99 2.0.99 - * 0.99c 0.99 2.0.99 - * 0.99e 0.99 2.0.99 - * 1.0 1.00 2.1.0 + * 0.99a-i 0.99 2.0.99 + * 1.00 1.00 2.1.0 * * Henceforth the source version will match the shared-library minor * and patch numbers; the shared-library major version number will be * used for changes in backward compatibility, as it is intended. * - * BETA NOTICE: - * This is a beta version. It reads and writes valid files on the - * platforms I have, and has had a wide testing program. 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 if you can't find a makefile suitable for your - * operating system/compiler combination. Read libpng.txt for more - * information, including how to contact the authors if you have any - * problems, or if you want your compiler/platform to be supported in - * the next official libpng release. - * * See libpng.txt for more information. The PNG specification is available * as RFC 2083 * and as a W3C Recommendation @@ -126,12 +112,12 @@ extern "C" { */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "0.99" +#define PNG_LIBPNG_VER_STRING "1.00" /* careful here. At one time, I wanted to use 082, but that would be octal. * Version 1.0 will be 100 here, etc. */ -#define PNG_LIBPNG_VER 99 +#define PNG_LIBPNG_VER 100 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) @@ -508,6 +494,8 @@ typedef png_struct FAR * png_structp; typedef void (*png_error_ptr) PNGARG((png_structp, png_const_charp)); typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); typedef void (*png_flush_ptr) PNGARG((png_structp)); +typedef void (*png_read_status_ptr) PNGARG((png_structp, png_uint_32, int)); +typedef void (*png_write_status_ptr) PNGARG((png_structp, png_uint_32, int)); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop)); typedef void (*png_progressive_end_ptr) PNGARG((png_structp, png_infop)); @@ -515,6 +503,12 @@ typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep, png_uint_32, int)); #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +typedef void (*png_user_transform_ptr) PNGARG((png_structp, + png_row_infop, png_bytep)); +#endif /* PNG_READ|WRITE_USER_TRANSFORM_SUPPORTED */ + /* The structure that holds the information to read and write PNG files. * The only people who need to care about what is inside of this are the * people who will be modifying the library for their own special needs. @@ -531,9 +525,14 @@ struct png_struct_def 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 */ +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr read_user_transform_fn; /* user read transform */ + png_user_transform_ptr write_user_transform_fn; /* user write transform */ +#endif png_voidp io_ptr; /* ptr to application struct for I/O functions*/ - png_uint_32 mode; /* tells us whre we are in the PNG file */ + png_uint_32 mode; /* tells us where we are in the PNG file */ png_uint_32 flags; /* flags indicating various things to libpng */ png_uint_32 transformations; /* which transformations to perform */ @@ -620,9 +619,11 @@ struct png_struct_def png_bytep trans; /* transparency values for paletted files */ png_color_16 trans_values; /* transparency values for non-paletted files */ #endif /* PNG_READ_tRNS_SUPPORTED || PNG_READ_BACKGROUND_SUPPORTED */ + png_read_status_ptr read_row_fn; /* called after each row is decoded */ + png_write_status_ptr write_row_fn; /* called after each row is encoded */ #ifdef PNG_PROGRESSIVE_READ_SUPPORTED png_progressive_info_ptr info_fn; /* called after header data fully read */ - png_progressive_row_ptr row_fn; /* called after each row is decoded */ + png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ png_progressive_end_ptr end_fn; /* called after image is complete */ png_bytep save_buffer_ptr; /* current location in save_buffer */ png_bytep save_buffer; /* buffer for previously read data */ @@ -1096,6 +1097,22 @@ extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, /* Return the user pointer associated with the I/O functions */ extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, + png_read_status_ptr read_row_fn)); + +extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, + png_write_status_ptr write_row_fn)); + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED +extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr read_user_transform_fn)); +#endif + +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED +extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr write_user_transform_fn)); +#endif + #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* Sets the function callbacks for the push reader, and a pointer to a * user-defined structure available to the callback functions. @@ -1470,6 +1487,7 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, #define PNG_SWAP_ALPHA 0x20000L #define PNG_STRIP_ALPHA 0x40000L #define PNG_INVERT_ALPHA 0x80000L +#define PNG_USER_TRANSFORM 0x100000L /* flags for png_create_struct */ #define PNG_STRUCT_PNG 0x0001 diff --git a/pngconf.h b/pngconf.h index 12c62c45a1fea80ee9c076e8edeb0706aa44aa1a..6d0adb1af02ae0029cedef0c917e6e56e9119487 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,12 +1,12 @@ /* pngconf.h - machine configurable file for libpng * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 */ /* Any machine specific code is near the front of this file, so if you @@ -236,21 +236,24 @@ __dont__ include it again /* Any transformations you will not be using can be undef'ed here */ -/* GR-P, 0.96a: Set "*FULLY_SUPPORTED as default but allow user - to turn it off with "*NOT_FULLY_SUPPORTED" on the compile line, +/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user + to turn it off with "*TRANSFORMS_NOT_SUPPORTED" on the compile line, then pick and choose which ones to define without having to edit - this file. + this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED if you + only want to have a png-compliant reader/writer but don't need + any of the extra transformations. This saves about 80 kbytes in a + typical installation of the library. */ -#ifndef PNG_READ_NOT_FULLY_SUPPORTED -#define PNG_READ_FULLY_SUPPORTED + +#ifndef PNG_READ_TRANSFORMS_NOT_SUPPORTED +#define PNG_READ_TRANSFORMS_SUPPORTED #endif -#ifndef PNG_WRITE_NOT_FULLY_SUPPORTED -#define PNG_WRITE_FULLY_SUPPORTED +#ifndef PNG_WRITE_TRANSFORMS_NOT_SUPPORTED +#define PNG_WRITE_TRANSFORMS_SUPPORTED #endif -#ifdef PNG_READ_FULLY_SUPPORTED -#define PNG_PROGRESSIVE_READ_SUPPORTED +#ifdef PNG_READ_TRANSFORMS_SUPPORTED #define PNG_READ_EXPAND_SUPPORTED #define PNG_READ_SHIFT_SUPPORTED #define PNG_READ_PACK_SUPPORTED @@ -267,12 +270,20 @@ __dont__ include it again #define PNG_READ_SWAP_ALPHA_SUPPORTED #define PNG_READ_INVERT_ALPHA_SUPPORTED #define PNG_READ_STRIP_ALPHA_SUPPORTED -#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel */ -#endif /* PNG_READ_FULLY_SUPPORTED */ +#define PNG_READ_USER_TRANSFORM_SUPPORTED +/* the following aren't implemented yet +#define PNG_READ_RGB_TO_GRAY_SUPPORTED + */ +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ -#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ +#ifndef PNG_PROGRESSIVE_READ_NOT_SUPPORTED /* if you don't do progressive */ +#define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ +#endif /* about interlacing capability! You'll */ + /* still have interlacing unless you change the following line: */ +#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ +#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel and SGI */ -#ifdef PNG_WRITE_FULLY_SUPPORTED +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED #define PNG_WRITE_SHIFT_SUPPORTED #define PNG_WRITE_PACK_SUPPORTED #define PNG_WRITE_BGR_SUPPORTED @@ -284,10 +295,11 @@ __dont__ include it again #define PNG_WRITE_SWAP_ALPHA_SUPPORTED #define PNG_WRITE_INVERT_ALPHA_SUPPORTED #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#endif /* PNG_WRITE_FULLY_SUPPORTED */ +#define PNG_WRITE_USER_TRANSFORM_SUPPORTED +#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ -#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant */ - /* encoders, but can cause trouble +#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant + encoders, but can cause trouble if left undefined */ #if !defined(PNG_NO_STDIO) diff --git a/pngerror.c b/pngerror.c index d9596265ff080099c54be577eaf5167e3d8be178..fec83a0067add050ddc1041d6dc3d6f6488eafa2 100644 --- a/pngerror.c +++ b/pngerror.c @@ -1,12 +1,12 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 * * This file provides a location for all error handling. Users which * need special error handling are expected to write replacement functions diff --git a/pngget.c b/pngget.c index 2aee339216b989eb295a69a912ea64289a612832..6296589d0ae3494d556cadbff2afd91d3f0c2cd9 100644 --- a/pngget.c +++ b/pngget.c @@ -1,12 +1,12 @@ /* pngget.c - retrieval of values from info struct * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 */ #define PNG_INTERNAL diff --git a/pngmem.c b/pngmem.c index 3659d47389da56f01f90f2e4867030755cee9fe4..a1b767732d1350c5761753e1005c68ed12c71fae 100644 --- a/pngmem.c +++ b/pngmem.c @@ -1,11 +1,12 @@ + /* pngmem.c - stub functions for memory allocation * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 * * This file provides a location for all memory allocation. Users which * need special memory handling are expected to modify the code in this file diff --git a/pngpread.c b/pngpread.c index d9c9e6309464ca24526bf83998603bedfd4cbccd..1b9fcf472d1454f525f6f8822f42a3f3c6823d6f 100644 --- a/pngpread.c +++ b/pngpread.c @@ -1,12 +1,12 @@ /* pngpread.c - read a png file in push mode * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 */ #define PNG_INTERNAL @@ -785,7 +785,10 @@ png_read_push_finish_row(png_structp png_ptr) png_pass_inc[png_ptr->pass] - 1 - png_pass_start[png_ptr->pass]) / png_pass_inc[png_ptr->pass]; - png_ptr->irowbytes = ((png_ptr->pixel_depth + 7) >> 3) + 1; + + png_ptr->irowbytes = ((png_ptr->iwidth * + png_ptr->pixel_depth + 7) >> 3) + 1; + if (!(png_ptr->transformations & PNG_INTERLACE)) { png_ptr->num_rows = (png_ptr->height + @@ -978,7 +981,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size - (text - key)); png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = png_ptr->zbuf_size; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; key_size = text - key; text_size = 0; diff --git a/pngread.c b/pngread.c index ad29375cc3da2fb3b0a4de06d6c555512e119145..616ec98aff2b8276d3712346267bab04cf4fb6c0 100644 --- a/pngread.c +++ b/pngread.c @@ -1,12 +1,12 @@ /* pngread.c - read a PNG file * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 * * This file contains routines that an application calls directly to * read a PNG file or stream. @@ -449,6 +449,9 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) png_combine_row(png_ptr, dsp_row, 0xff); } png_read_finish_row(png_ptr); + + if (png_ptr->read_row_fn != NULL) + (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); } /* Read one or more rows of image data. If the image is interlaced, @@ -778,3 +781,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); } + +void +png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) +{ + png_ptr->read_row_fn = read_row_fn; +} diff --git a/pngrio.c b/pngrio.c index 74d94124151cd44eaeb81389cd87de6c55055f85..5d6682cbd1107c4ee5e18ab3e098bfb5679fd8ef 100644 --- a/pngrio.c +++ b/pngrio.c @@ -1,12 +1,12 @@ /* pngrio.c - functions for data input * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 * * This file provides a location for all input. Users which need * special handling are expected to write a function which has the same diff --git a/pngrtran.c b/pngrtran.c index d2cb97adf53ef63e11f7cc157c0b37c2df1aa747..adc84dd6b01854a0f16c1012572327f5efd2b211 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,12 +1,12 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 * * This file contains functions optionally called by an application * in order to tell libpng how to handle data when reading a PNG. @@ -600,6 +600,17 @@ png_set_rgb_to_gray(png_structp png_ptr, int gray_bits) } #endif +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) +void +png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr + read_user_transform_fn) +{ + png_debug(1, "in png_set_read_user_transform_fn\n"); + png_ptr->transformations |= PNG_USER_TRANSFORM; + png_ptr->read_user_transform_fn = read_user_transform_fn; +} +#endif + /* Initialize everything needed for the read. This includes modifying * the palette. */ @@ -1078,7 +1089,7 @@ png_do_read_transformations(png_structp png_ptr) png_ptr->gamma_shift); #endif -#if defined(PNG_RGB_TO_GRAY_SUPPORTED) +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) if (png_ptr->transformations & PNG_RGB_TO_GRAY) png_do_rgb_to_gray(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif @@ -1149,6 +1160,22 @@ png_do_read_transformations(png_structp png_ptr) if (png_ptr->transformations & PNG_SWAP_BYTES) png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + if (png_ptr->transformations & PNG_USER_TRANSFORM) + if(png_ptr->read_user_transform_fn != NULL) + (*(png_ptr->read_user_transform_fn)) /* user read transform function */ + (png_ptr, /* png_ptr */ + &(png_ptr->row_info), /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_uint_32 rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ +#endif + } #if defined(PNG_READ_PACK_SUPPORTED) diff --git a/pngrutil.c b/pngrutil.c index a95b19cb97027907e4884f72f0bbeda6026cf0b0..2a2bbd867bae6c9bc53a821cbfab75d63cb0ba4f 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -6,7 +6,7 @@ * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 * * This file contains routines which are only called from within * libpng itself during the course of reading an image. @@ -1305,7 +1305,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_ptr->zstream.next_in = (png_bytep)text; png_ptr->zstream.avail_in = (uInt)(length - (text - key)); png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = png_ptr->zbuf_size; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; key_size = (png_size_t)(text - key); text_size = 0; @@ -1704,7 +1704,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, case 1: { png_bytep sp, dp; - int sshift, dshift; + png_uint_32 sshift, dshift; int s_start, s_end, s_inc; png_byte v; png_uint_32 i; @@ -1715,8 +1715,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, #if defined(PNG_READ_PACKSWAP_SUPPORTED) if (transformations & PNG_PACKSWAP) { - sshift = (int)((row_info->width + 7) & 7); - dshift = (int)((final_width + 7) & 7); + sshift = (png_uint_32)((row_info->width + 7) & 7); + dshift = (png_uint_32)((final_width + 7) & 7); s_start = 7; s_end = 0; s_inc = -1; @@ -1724,8 +1724,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, else #endif { - sshift = 7 - (int)((row_info->width + 7) & 7); - dshift = 7 - (int)((final_width + 7) & 7); + sshift = 7 - (png_uint_32)((row_info->width + 7) & 7); + dshift = 7 - (png_uint_32)((final_width + 7) & 7); s_start = 0; s_end = 7; s_inc = 1; @@ -1759,17 +1759,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, case 2: { png_bytep sp, dp; - int sshift, dshift; + png_uint_32 sshift, dshift; int s_start, s_end, s_inc; png_uint_32 i; - sp = row + (png_size_t)((row_info->width - 1) >> 2); - dp = row + (png_size_t)((final_width - 1) >> 2); + sp = row + (png_uint_32)((row_info->width - 1) >> 2); + dp = row + (png_uint_32)((final_width - 1) >> 2); #if defined(PNG_READ_PACKSWAP_SUPPORTED) if (transformations & PNG_PACKSWAP) { - sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); - dshift = (png_size_t)(((final_width + 3) & 3) << 1); + sshift = (png_uint_32)(((row_info->width + 3) & 3) << 1); + dshift = (png_uint_32)(((final_width + 3) & 3) << 1); s_start = 6; s_end = 0; s_inc = -2; @@ -1777,8 +1777,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, else #endif { - sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); - dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); + sshift = (png_uint_32)((3 - ((row_info->width + 3) & 3)) << 1); + dshift = (png_uint_32)((3 - ((final_width + 3) & 3)) << 1); s_start = 0; s_end = 6; s_inc = 2; @@ -1815,7 +1815,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, case 4: { png_bytep sp, dp; - int sshift, dshift; + png_uint_32 sshift, dshift; int s_start, s_end, s_inc; png_uint_32 i; @@ -1824,8 +1824,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, #if defined(PNG_READ_PACKSWAP_SUPPORTED) if (transformations & PNG_PACKSWAP) { - sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); - dshift = (png_size_t)(((final_width + 1) & 1) << 2); + sshift = (png_uint_32)(((row_info->width + 1) & 1) << 2); + dshift = (png_uint_32)(((final_width + 1) & 1) << 2); s_start = 4; s_end = 0; s_inc = -4; @@ -1833,8 +1833,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, else #endif { - sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); - dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); + sshift = (png_uint_32)((1 - ((row_info->width + 1) & 1)) << 2); + dshift = (png_uint_32)((1 - ((final_width + 1) & 1)) << 2); s_start = 0; s_end = 4; s_inc = 4; diff --git a/pngset.c b/pngset.c index cdc21837cb26dd39612e7dbe017f1310396067e2..9ccb1088204e06e947a42c420673c78b0c88f656 100644 --- a/pngset.c +++ b/pngset.c @@ -1,12 +1,12 @@ /* pngset.c - storage of image information into info struct * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 * * The functions here are used during reads to store data from the file * into the info struct, and during writes to store application data diff --git a/pngtest.c b/pngtest.c index f5909a0ead31eb0b945a00675599c3784b8d6618..5983ca34861f56b0ecf45f0de2e9fbf5e7370061 100644 --- a/pngtest.c +++ b/pngtest.c @@ -1,12 +1,12 @@ /* pngtest.c - a simple test program to test libpng * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 * * This program reads in a PNG image, writes it out again, and then * compares the two files. If the files are identical, this shows that @@ -32,8 +32,8 @@ /* Makes pngtest verbose so we can find problems (needs to be before png.h) */ #ifndef PNG_DEBUG -#define PNG_DEBUG 0 #endif +#define PNG_DEBUG 0 #include "png.h" @@ -47,6 +47,126 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname); /* #define STDERR stderr */ #define STDERR stdout /* for DOS */ +/* example of using row callbacks to make a simple progress meter */ +static int status_pass=1; +static int status_dots_requested=0; +static int status_dots=1; +void read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); +void read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) +{ + if(png_ptr == NULL || row_number > 0x3fffffff) return; + if(status_pass != pass) + { + fprintf(stdout,"\n Pass %d: ",pass); + status_pass = pass; + status_dots = 30; + } + status_dots--; + if(status_dots == 0) + { + fprintf(stdout, "\n "); + status_dots=30; + } + fprintf(stdout, "r"); +} +void write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); +void write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) +{ + if(png_ptr == NULL || row_number > 0x3fffffff || pass > 7) return; + fprintf(stdout, "w"); +} + + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +/* example of using user transform callback (we don't transform anything, + but merely count the black pixels) */ + +static png_uint_32 black_pixels; +void count_black_pixels(png_structp png_ptr, png_row_infop row_info, + png_bytep data); +void count_black_pixels(png_structp png_ptr, png_row_infop row_info, + png_bytep data) +{ + png_bytep dp = data; + if(png_ptr == NULL)return; + + /* contents of row_info: + * png_uint_32 width width of row + * png_uint_32 rowbytes number of bytes in row + * png_byte color_type color type of pixels + * png_byte bit_depth bit depth of samples + * png_byte channels number of channels (1-4) + * png_byte pixel_depth bits per pixel (depth*channels) + */ + + /* counts the number of black pixels (or zero pixels if color_type is 3 */ + + if(row_info->color_type == 0 || row_info->color_type == 3) + { + int pos=0; + png_uint_32 n; + for (n=0; n<(int)row_info->width; n++) + { + if(row_info->bit_depth == 1) + if(((*dp << pos++ )& 0x80) == 0) black_pixels++; + if(pos == 8) + { + pos=0; + dp++; + } + if(row_info->bit_depth == 2) + if(((*dp << (pos+=2))& 0xc0) == 0) black_pixels++; + if(pos == 8) + { + pos=0; + dp++; + } + if(row_info->bit_depth == 4) + if(((*dp << (pos+=4))& 0xf0) == 0) black_pixels++; + if(pos == 8) + { + pos=0; + dp++; + } + if(row_info->bit_depth == 8) + if(*dp++ == 0) black_pixels++; + if(row_info->bit_depth == 16) + { + if((*dp | *(dp+1)) == 0) black_pixels++; + dp+=2; + } + } + } + else /* other color types */ + { + png_uint_32 n; + int channel; + int color_channels = row_info->channels; + if(row_info->color_type > 3)color_channels--; + + for (n=0; nwidth; n++) + { + for (channel = 0; channel < color_channels; channel++) + { + if(row_info->bit_depth == 8) + if(*dp++ == 0) black_pixels++; + if(row_info->bit_depth == 16) + { + if((*dp | *(dp+1)) == 0) black_pixels++; + dp+=2; + } + } + if(row_info->color_type > 3) + { + dp++; + if(row_info->bit_depth == 16)dp++; + } + } + } +} +#endif /* PNG_READ|WRITE_USER_TRANSFORM_SUPPORTED */ + static int verbose = 0; static int wrote_question = 0; @@ -439,6 +559,22 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #else NULL); #endif +#endif + if(status_dots_requested == 1) + { + png_set_write_status_fn(write_ptr, write_row_callback); + png_set_read_status_fn(read_ptr, read_row_callback); + } + else + { + png_set_write_status_fn(write_ptr, NULL); + png_set_read_status_fn(read_ptr, NULL); + } + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + black_pixels=0; + png_set_write_user_transform_fn(write_ptr, count_black_pixels); #endif png_debug(0, "Reading info struct\n"); @@ -730,8 +866,8 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) /* input and output filenames */ #ifdef RISCOS -PNG_CONST char *inname = "pngtest_png"; -PNG_CONST char *outname = "pngout_png"; +PNG_CONST char *inname = "pngtest/png"; +PNG_CONST char *outname = "pngout/png"; #else static char *inname = "pngtest.png"; static char *outname = "pngout.png"; @@ -770,20 +906,28 @@ main(int argc, char *argv[]) if (argc > 1) { if (strcmp(argv[1], "-m") == 0) + { multiple = 1; + status_dots_requested = 0; + } else if (strcmp(argv[1], "-mv") == 0 || strcmp(argv[1], "-vm") == 0 ) { multiple = 1; verbose = 1; + status_dots_requested = 1; } else if (strcmp(argv[1], "-v") == 0) { verbose = 1; + status_dots_requested = 1; inname = argv[2]; } else + { inname = argv[1]; + status_dots_requested = 0; + } } if (!multiple && argc == 3+verbose) @@ -813,7 +957,12 @@ main(int argc, char *argv[]) fprintf(STDERR, "Testing %s:",argv[i]); kerror = test_one_file(argv[i], outname); if (kerror == 0) +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + fprintf(STDERR, " PASS (%lu black pixels)\n",black_pixels); +#else fprintf(STDERR, " PASS\n"); +#endif else { fprintf(STDERR, " FAIL\n"); ierror += kerror; @@ -847,12 +996,20 @@ main(int argc, char *argv[]) #ifdef PNGTEST_MEMORY_DEBUG int allocation_now = current_allocation; #endif + if (i == 1) status_dots_requested = 1; + else if(verbose == 0)status_dots_requested = 0; if (i == 0 || verbose == 1 || ierror != 0) fprintf(STDERR, "Testing %s:",inname); kerror = test_one_file(inname, outname); if(kerror == 0) { - if(verbose == 1 || i == 2) fprintf(STDERR, " PASS\n"); + if(verbose == 1 || i == 2) +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + fprintf(STDERR, " PASS (%lu black pixels)\n",black_pixels); +#else + fprintf(STDERR, " PASS\n"); +#endif } else { diff --git a/pngtrans.c b/pngtrans.c index 111815149bfdcf453af66a07ea6559e59ff17bb4..d67afa8e00d9745923853964d2272ef1e99530af 100644 --- a/pngtrans.c +++ b/pngtrans.c @@ -1,12 +1,12 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 */ #define PNG_INTERNAL diff --git a/pngwio.c b/pngwio.c index b2519cf2ac42bdffdbac61ebdbb263cc42b49bde..c8879ef5d50faff40025d1aa27e4f4d2460fa8a9 100644 --- a/pngwio.c +++ b/pngwio.c @@ -1,12 +1,12 @@ /* pngwio.c - functions for data output * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 * * This file provides a location for all output. Users which need * special handling are expected to write functions which have the same diff --git a/pngwrite.c b/pngwrite.c index 0e8b2000a7fa8727958a92d48210ad10bdb50866..afb4b43be8fa1b1cc65306b37ea8bd44352afc12 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,12 +1,12 @@ /* pngwrite.c - general routines to write a PNG file * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 */ /* get internal access to png.h */ @@ -527,6 +527,9 @@ png_write_row(png_structp png_ptr, png_bytep row) /* Find a filter if necessary, filter the row and write it out. */ png_write_find_filter(png_ptr, &(png_ptr->row_info)); + + if (png_ptr->write_row_fn != NULL) + (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); } #if defined(PNG_WRITE_FLUSH_SUPPORTED) @@ -947,3 +950,20 @@ png_set_compression_method(png_structp png_ptr, int method) png_ptr->zlib_method = method; } +void +png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn) +{ + png_ptr->write_row_fn = write_row_fn; +} + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +void +png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr + write_user_transform_fn) +{ + png_debug(1, "in png_set_write_user_transform_fn\n"); + png_ptr->transformations |= PNG_USER_TRANSFORM; + png_ptr->write_user_transform_fn = write_user_transform_fn; +} +#endif + diff --git a/pngwtran.c b/pngwtran.c index 01b148e2603070c436838b4fbc8854024d17d547..25a2d64bc614a0f8822a0199f9af6d055914dc27 100644 --- a/pngwtran.c +++ b/pngwtran.c @@ -1,12 +1,12 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 */ #define PNG_INTERNAL @@ -19,6 +19,21 @@ void png_do_write_transformations(png_structp png_ptr) { png_debug(1, "in png_do_write_transformations\n"); + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + if (png_ptr->transformations & PNG_USER_TRANSFORM) + if(png_ptr->write_user_transform_fn != NULL) + (*(png_ptr->write_user_transform_fn)) /* user write transform function */ + (png_ptr, /* png_ptr */ + &(png_ptr->row_info), /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_uint_32 rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ +#endif #if defined(PNG_WRITE_FILLER_SUPPORTED) if (png_ptr->transformations & PNG_FILLER) png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, diff --git a/pngwutil.c b/pngwutil.c index bbf5056b18e786f55ac952f331524cb597638974..6b971c83bf61666132df879b6fd3b634e48a7c02 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1,12 +1,12 @@ /* pngwutil.c - utilities to write a PNG file * - * libpng 0.99e + * libpng 1.00 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1998, Glenn Randers-Pehrson - * February 28, 1998 + * March 7, 1998 */ #define PNG_INTERNAL diff --git a/build.bat b/scripts/build.bat similarity index 100% rename from build.bat rename to scripts/build.bat diff --git a/descrip.mms b/scripts/descrip.mms similarity index 100% rename from descrip.mms rename to scripts/descrip.mms diff --git a/makefile.aco b/scripts/makefile.aco similarity index 100% rename from makefile.aco rename to scripts/makefile.aco diff --git a/makefile.ama b/scripts/makefile.ama similarity index 100% rename from makefile.ama rename to scripts/makefile.ama diff --git a/makefile.atr b/scripts/makefile.atr similarity index 100% rename from makefile.atr rename to scripts/makefile.atr diff --git a/makefile.bor b/scripts/makefile.bor similarity index 100% rename from makefile.bor rename to scripts/makefile.bor diff --git a/makefile.dec b/scripts/makefile.dec similarity index 100% rename from makefile.dec rename to scripts/makefile.dec diff --git a/makefile.dj2 b/scripts/makefile.dj2 similarity index 100% rename from makefile.dj2 rename to scripts/makefile.dj2 diff --git a/makefile.knr b/scripts/makefile.knr similarity index 100% rename from makefile.knr rename to scripts/makefile.knr diff --git a/makefile.lnx b/scripts/makefile.lnx similarity index 96% rename from makefile.lnx rename to scripts/makefile.lnx index 8ce98df4a1f019d3ff06cb6945a0aa5380023e6f..4547110b2ea142c40ebf57f127202efaf2982053 100644 --- a/makefile.lnx +++ b/scripts/makefile.lnx @@ -21,8 +21,10 @@ LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm RANLIB=ranlib #RANLIB=echo +# read libpng.txt or png.h to see why PNGMAJ is 2. You should not +# have to change it. PNGMAJ = 2 -PNGMIN = 0.99 +PNGMIN = 1.00 PNGVER = $(PNGMAJ).$(PNGMIN) # where make install puts libpng.a, libpng.so*, and png.h diff --git a/makefile.mip b/scripts/makefile.mip similarity index 100% rename from makefile.mip rename to scripts/makefile.mip diff --git a/makefile.msc b/scripts/makefile.msc similarity index 100% rename from makefile.msc rename to scripts/makefile.msc diff --git a/scripts/makefile.os2 b/scripts/makefile.os2 new file mode 100644 index 0000000000000000000000000000000000000000..a3ff2dcac6a51c89b2487ea3a1199f15b157ac4e --- /dev/null +++ b/scripts/makefile.os2 @@ -0,0 +1,69 @@ +# makefile for libpng on OS/2 with gcc +# For conditions of distribution and use, see copyright notice in png.h + +# Related files: pngos2.def + +CC=gcc -Zomf -s + +# Where the zlib library and include files are located +ZLIBLIB=../zlib +ZLIBINC=../zlib + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion +CFLAGS=-I$(ZLIBINC) -Wall -O6 -funroll-loops -malign-loops=2 \ + -malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5 +LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll +AR=emxomfar + +PNGLIB=png.lib +IMPLIB=emximp +SHAREDLIB=png.dll +SHAREDLIBIMP=pngdll.lib + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +.SUFFIXES: .c .o + +all: $(PNGLIB) $(SHAREDLIB) $(SHAREDLIBIMP) + +$(PNGLIB): $(OBJS) + $(AR) rc $@ $(OBJS) + +$(SHAREDLIB): $(OBJS) pngos2.def + $(CC) $(LDFLAGS) -Zdll -o $@ $^ + +$(SHAREDLIBIMP): pngos2.def + $(IMPLIB) -o $@ $^ + +pngtest.exe: pngtest.o png.dll pngdll.lib + $(CC) -o $@ $(CFLAGS) $< $(LDFLAGS) + +test: pngtest.exe + ./pngtest.exe + +clean: + rm -f *.o $(PNGLIB) png.dll pngdll.lib pngtest.exe pngout.png + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/scripts/makefile.s2x b/scripts/makefile.s2x new file mode 100644 index 0000000000000000000000000000000000000000..48055b6fa71749170ebc97e7dcfd19d309db8b25 --- /dev/null +++ b/scripts/makefile.s2x @@ -0,0 +1,98 @@ + makefile for libpng on Solaris 2.x with gcc +# Contributed by William L. Sebok, based on makefile.lnx +# Copyright (C) 1996, 1997 Andreas Dilger +# Copyright (C) 1998 Greg Roelofs +# For conditions of distribution and use, see copyright notice in png.h + +CC=gcc + +# Where the zlib library and include files are located +ZLIBLIB=/usr/local/lib +ZLIBINC=/usr/local/include + +WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ + -Wmissing-declarations -Wtraditional -Wcast-align \ + -Wstrict-prototypes -Wmissing-prototypes #-Wconversion +CFLAGS=-I$(ZLIBINC) -Wall -O3 \ + #$(WARNMORE) -g -DPNG_DEBUG=5 +LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng -lz -lm + +#RANLIB=ranlib +RANLIB=echo + +# read libpng.txt or png.h to see why PNGMAJ is 2. You should not +# have to change it. +PNGMAJ = 2 +PNGMIN = 1.00 +PNGVER = $(PNGMAJ).$(PNGMIN) + +# where make install puts libpng.a, libpng.so*, and png.h +prefix=/local +INCPATH=$(prefix)/include +LIBPATH=$(prefix)/lib + +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ + pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ + pngwtran.o pngmem.o pngerror.o pngpread.o + +OBJSDLL = $(OBJS:.o=.pic.o) + +.SUFFIXES: .c .o .pic.o + +.c.pic.o: + $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c + +all: libpng.a libpng.so pngtest + +libpng.a: $(OBJS) + ar rc $@ $(OBJS) + $(RANLIB) $@ + +libpng.so: libpng.so.$(PNGMAJ) + ln -sf libpng.so.$(PNGMAJ) libpng.so + +libpng.so.$(PNGMAJ): libpng.so.$(PNGVER) + ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ) + +libpng.so.$(PNGVER): $(OBJSDLL) + $(LD) -G -L$(LIBPATH) -R$(LIBPATH) -h libpng.so.$(PNGMAJ) \ + -o libpng.so.$(PNGVER) $(OBJSDLL) -lz + +pngtest: pngtest.o libpng.so + $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) + +test: pngtest + ./pngtest + +install: libpng.a libpng.so.$(PNGVER) + -@mkdir $(INCPATH) $(LIBPATH) + cp png.h pngconf.h $(INCPATH) + chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h + cp libpng.a libpng.so.$(PNGVER) $(LIBPATH) + chmod 755 $(LIBPATH)/libpng.so.$(PNGVER) + -@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so + (cd $(LIBPATH); ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \ + ln -sf libpng.so.$(PNGMAJ) libpng.so) + +clean: + /bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +png.o png.pic.o: png.h pngconf.h +pngerror.o pngerror.pic.o: png.h pngconf.h +pngrio.o pngrio.pic.o: png.h pngconf.h +pngwio.o pngwio.pic.o: png.h pngconf.h +pngmem.o pngmem.pic.o: png.h pngconf.h +pngset.o pngset.pic.o: png.h pngconf.h +pngget.o pngget.pic.o: png.h pngconf.h +pngread.o pngread.pic.o: png.h pngconf.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h +pngpread.o pngpread.pic.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/makefile.sgi b/scripts/makefile.sgi similarity index 100% rename from makefile.sgi rename to scripts/makefile.sgi diff --git a/makefile.std b/scripts/makefile.std similarity index 100% rename from makefile.std rename to scripts/makefile.std diff --git a/makefile.sun b/scripts/makefile.sun similarity index 100% rename from makefile.sun rename to scripts/makefile.sun diff --git a/makefile.tc3 b/scripts/makefile.tc3 similarity index 79% rename from makefile.tc3 rename to scripts/makefile.tc3 index 050c822ec8ac2c3b84d9de5bb5cf52c746de0cb1..03da1849d60dadd093c7270e84c377fe6c0f87db 100644 --- a/makefile.tc3 +++ b/scripts/makefile.tc3 @@ -9,18 +9,22 @@ CFLAGS=-O2 -Z $(MODEL) -I..\zlib CC=tcc LD=tcc LIB=tlib -LDFLAGS=$(MODEL) +LDFLAGS=$(MODEL) -L..\zlib O=.obj +E=.exe # variables -OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) +OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) +pngwutil$(O) OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) OBJSL1 = +png$(O) +pngset$(O) +pngget$(O) +pngrutil$(O) +pngtrans$(O) -OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O) -OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O) +OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) ++pngerror$(O) +OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) ++pngwio$(O) -all: libpng.lib +all: libpng.lib pngtest.exe png$(O): png.h pngconf.h $(CC) -c $(CFLAGS) $*.c @@ -75,4 +79,7 @@ libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) $(LIB) libpng +$(OBJSL2) $(LIB) libpng +$(OBJSL3) -# End of makefile for libpng +pngtest$(E): pngtest$(O) libpng.lib + $(CC) $(LDFLAGS) pngtest.obj libpng.lib zlib.lib + +# End of makefile for libpng \ No newline at end of file diff --git a/scripts/makefile.wat b/scripts/makefile.wat new file mode 100644 index 0000000000000000000000000000000000000000..9d41b2fe5d45105a91cae58740beca9dcf0957f3 --- /dev/null +++ b/scripts/makefile.wat @@ -0,0 +1,88 @@ +# Makefile for libpng +# Watcom 10a+ 32-bit protected mode flat memory model + +# Adapted by Pawel Mrochen, based on makefile.msc +# For conditions of distribution and use, see copyright notice in png.h +# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib + +# To use, do "wmake -f makefile.wat" + +# ------------- Watcom 10a+ ------------- +MODEL=-mf +CFLAGS= $(MODEL) -fpi87 -fp5 -5r -oaeilmnrt -s -i=..\zlib +CC=wcc386 +LD=wcl386 +LIB=wlib -b -c +LDFLAGS= +O=.obj + +#uncomment next to put error messages in a file +#ERRFILE= >> pngerrs + +# variables +OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O) +OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O) +OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) + +all: test + +png$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngset$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngget$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngread$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngpread$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngrtran$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngrutil$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngerror$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngmem$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngrio$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwio$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngtest$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngtrans$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwrite$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwtran$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +pngwutil$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + +libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) + $(LIB) -n libpng.lib +$(OBJS1) + $(LIB) libpng.lib +$(OBJS2) + $(LIB) libpng.lib +$(OBJS3) + +pngtest.exe: pngtest.obj libpng.lib + $(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib + +test: pngtest.exe + pngtest + +# End of makefile for libpng diff --git a/makevms.com b/scripts/makevms.com similarity index 100% rename from makevms.com rename to scripts/makevms.com diff --git a/scripts/pngos2.def b/scripts/pngos2.def new file mode 100644 index 0000000000000000000000000000000000000000..ba2d3e3d387d4b1b5e180af04f5ecc0e860729f9 --- /dev/null +++ b/scripts/pngos2.def @@ -0,0 +1,286 @@ +;---------------------------------------- +; PNGLIB module definition file for OS/2 +;---------------------------------------- + +LIBRARY PNG +DESCRIPTION "PNG image compression library for OS/2" +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE + +EXPORTS + png_set_sig_bytes + png_sig_cmp + png_check_sig + png_create_read_struct + png_create_write_struct + png_write_chunk + png_write_chunk_start + png_write_chunk_data + png_write_chunk_end + png_create_info_struct + png_info_init + png_write_info + png_read_info + png_convert_to_rfc1123 + png_convert_from_struct_tm + png_convert_from_time_t + png_set_expand + png_set_bgr + png_set_gray_to_rgb +; png_set_rgb_to_gray + png_build_grayscale_palette + png_set_strip_alpha + png_set_swap_alpha + png_set_invert_alpha + png_set_filler + png_set_swap + png_set_packing + png_set_packswap + png_set_shift + png_set_interlace_handling + png_set_invert_mono + png_set_background + png_set_strip_16 + png_set_dither + png_set_gamma + png_set_flush + png_write_flush + png_start_read_image + png_read_update_info + png_read_rows + png_read_row + png_read_image + png_write_row + png_write_rows + png_write_image + png_write_end + png_read_end + png_destroy_info_struct + png_destroy_read_struct + png_read_destroy + png_destroy_write_struct +; png_write_destroy_info + png_write_destroy + png_set_crc_action + png_set_filter + png_set_filter_heuristics + png_set_compression_level + png_set_compression_mem_level + png_set_compression_strategy + png_set_compression_window_bits + png_set_compression_method + png_init_io + png_set_error_fn + png_get_error_ptr + png_set_write_fn + png_set_read_fn + png_set_write_status_fn + png_set_read_status_fn + png_get_io_ptr + png_set_progressive_read_fn + png_set_read_status_fn + png_set_read_user_transform_fn + png_set_write_status_fn + png_set_write_user_transform_fn + png_get_progressive_ptr + png_process_data + png_progressive_combine_row + png_malloc + png_free + png_memcpy_check + png_memset_check +; png_debug_malloc +; png_debug_free +; png_far_to_near + png_error + png_chunk_error + png_warning + png_chunk_warning + png_get_valid + png_get_rowbytes + png_get_channels + png_get_image_width + png_get_image_height + png_get_bit_depth + png_get_color_type + png_get_filter_type + png_get_interlace_type + png_get_compression_type + png_get_pixels_per_meter + png_get_pixel_aspect_ratio + png_get_x_offset_pixels + png_get_y_offset_pixels + png_get_x_offset_microns + png_get_y_offset_microns + png_get_signature + png_get_bKGD + png_set_bKGD + png_get_cHRM + png_set_cHRM + png_get_gAMA + png_set_gAMA + png_get_hIST + png_set_hIST + png_get_IHDR + png_set_IHDR + png_get_oFFs + png_set_oFFs + png_get_pCAL + png_set_pCAL + png_get_pHYs + png_set_pHYs + png_get_PLTE + png_set_PLTE + png_get_sBIT + png_set_sBIT + png_get_sRGB + png_set_sRGB + png_set_sRGB_gAMA_and_cHRM + png_get_text + png_set_text + png_get_tIME + png_set_tIME + png_get_tRNS + png_set_tRNS + + png_create_struct + png_destroy_struct + png_info_destroy + png_zalloc + png_zfree + png_reset_crc + png_write_data + png_read_data + png_crc_read + png_crc_finish + png_crc_error + png_calculate_crc + png_flush + png_save_uint_32 + png_save_int_32 + png_save_uint_16 + png_write_sig + png_write_IHDR + png_write_PLTE + png_write_IDAT + png_write_IEND + png_write_gAMA + png_write_sBIT + png_write_cHRM + png_write_sRGB + png_write_tRNS + png_write_bKGD + png_write_hIST + png_check_keyword + png_write_tEXt + png_write_zTXt + png_write_oFFs + png_write_pCAL + png_write_pHYs + png_write_tIME + png_write_finish_row + png_write_start_row + png_build_gamma_table + png_combine_row + png_do_read_interlace + png_do_write_interlace + png_read_filter_row + png_write_find_filter + png_write_filtered_row + png_read_finish_row + png_read_start_row + png_read_transform_info + png_do_read_filler + png_do_read_swap_alpha + png_do_write_swap_alpha + png_do_read_invert_alpha + png_do_write_invert_alpha + png_do_strip_filler + png_do_swap + png_do_packswap +; png_do_rgb_to_gray + png_do_gray_to_rgb + png_do_unpack + png_do_unshift + png_do_invert + png_do_chop + png_do_dither +; png_correct_palette + png_do_bgr + png_do_pack + png_do_shift + png_do_background + png_do_gamma + png_do_expand_palette + png_do_expand + png_handle_IHDR + png_handle_PLTE + png_handle_IEND + png_handle_gAMA + png_handle_sBIT + png_handle_cHRM + png_handle_sRGB + png_handle_tRNS + png_handle_bKGD + png_handle_hIST + png_handle_oFFs + png_handle_pCAL + png_handle_pHYs + png_handle_tIME + png_handle_tEXt + png_handle_zTXt + png_handle_unknown + png_check_chunk_name + png_do_read_transformations + png_do_write_transformations + png_init_read_transformations + png_push_read_chunk + png_push_read_sig +; png_push_check_crc + png_push_crc_skip + png_push_crc_finish + png_push_fill_buffer + png_push_save_buffer + png_push_restore_buffer + png_push_read_IDAT + png_process_IDAT_data + png_push_process_row + png_push_handle_unknown + png_push_have_info + png_push_have_end + png_push_have_row +; png_push_read_end + png_process_some_data + png_read_push_finish_row + png_push_handle_tEXt + png_push_read_tEXt + png_push_handle_zTXt + png_push_read_zTXt + + png_libpng_ver + png_pass_start + png_pass_inc + png_pass_ystart + png_pass_yinc + png_pass_mask + png_pass_dsp_mask +; png_pass_width +; png_pass_height + + png_IHDR + png_IDAT + png_IEND + png_PLTE + png_bKGD + png_cHRM + png_gAMA + png_hIST + png_oFFs + png_pCAL + png_pHYs + png_sBIT + png_sRGB + png_tEXt + png_tIME + png_tRNS + png_zTXt