--- libpng-1.4.12.old/png.c +++ libpng-1.4.12/png.c @@ -19,6 +19,38 @@ /* Generate a compiler error if there is an old png.h in the search path. */ typedef version_1_4_12 Your_png_h_is_not_version_1_4_12; +//-------------------------------------------------------------------- + +#ifdef PNG_READ_SUPPORTED +#undef png_check_sig + +int PNGAPI +png_check_sig (png_bytep sig, int num) +{ + return ((int) !png_sig_cmp (sig, (png_size_t) 0, (png_size_t) num)); +} +#endif + +/* Read the data from whatever input you are using. The default routine + * reads from a file pointer. Note that this routine sometimes gets called + * with very small lengths, so you should implement some kind of simple + * buffering if you are using unbuffered reads. This should never be asked + * to read more then 64K on a 16 bit machine. + */ + +#ifdef PNG_READ_SUPPORTED +void PNGAPI +png_read_data (png_structp png_ptr, png_bytep data, png_size_t length) +{ + if (png_ptr->read_data_fn != NULL) + (*(png_ptr->read_data_fn)) (png_ptr, data, length); + else + png_error (png_ptr, "Call to NULL read function"); +} +#endif + +//-------------------------------------------------------------------- + /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another * stream we can set num_bytes = 8 so that libpng will not attempt to read --- libpng-1.4.12.old/png.h +++ libpng-1.4.12/png.h @@ -1520,6 +1520,14 @@ PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, int num_bytes)); +/* Replacement for legacy "libpng" 1.2.X functions */ +extern PNG_EXPORT (int, png_check_sig) + PNGARG ((png_bytep, int)); +extern PNG_EXPORT (void, png_set_gray_1_2_4_to_8) + PNGARG ((png_structp)); +extern PNG_EXPORT (void, png_read_data) + PNGARG ((png_structp, png_bytep, png_size_t)); + /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a * PNG file. Returns zero if the supplied bytes match the 8-byte PNG * signature, and non-zero otherwise. Having num_to_check == 0 or --- libpng-1.4.12.old/pngpriv.h +++ libpng-1.4.12/pngpriv.h @@ -305,10 +305,6 @@ /* Read the chunk header (length + type name) */ PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr)); -/* Read data from whatever input you are using into the "data" buffer */ -PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - /* Read bytes into buf, and update png_ptr->crc */ PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, png_size_t length)); --- libpng-1.4.12.old/pngrio.c +++ libpng-1.4.12/pngrio.c @@ -23,23 +23,6 @@ #ifdef PNG_READ_SUPPORTED #include "pngpriv.h" -/* Read the data from whatever input you are using. The default routine - * reads from a file pointer. Note that this routine sometimes gets called - * with very small lengths, so you should implement some kind of simple - * buffering if you are using unbuffered reads. This should never be asked - * to read more then 64K on a 16 bit machine. - */ -void /* PRIVATE */ -png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_debug1(4, "reading %d bytes", (int)length); - - if (png_ptr->read_data_fn != NULL) - (*(png_ptr->read_data_fn))(png_ptr, data, length); - else - png_error(png_ptr, "Call to NULL read function"); -} - #ifdef PNG_STDIO_SUPPORTED /* This is the function that does the actual reading of data. If you are * not reading from a standard C stream, you should create a replacement --- libpng-1.4.12.old/pngrtran.c +++ libpng-1.4.12/pngrtran.c @@ -21,6 +21,16 @@ #ifdef PNG_READ_SUPPORTED #include "pngpriv.h" +/* Expand grayscale images of less than 8-bit depth to 8 bits. */ +/* Deprecated as of libpng-1.2.9 */ + +void PNGAPI +png_set_gray_1_2_4_to_8 (png_structp png_ptr) +{ + if (png_ptr == NULL) return; + png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); +} + /* Set the action on getting a CRC error for an ancillary or critical chunk. */ void PNGAPI png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)