diff -ru4NwbB libpng-1.2.40/png.c libpng-1.2.41beta05/png.c --- libpng-1.2.40/png.c 2009-09-10 06:38:50.146570290 -0500 +++ libpng-1.2.41beta05/png.c 2009-10-17 18:49:29.193532103 -0500 @@ -1,8 +1,8 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.2.39 [August 13, 2009] + * Last changed in libpng 1.2.41 [October 17, 2009] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -18,9 +18,10 @@ /* Generate a compiler error if there is an old png.h in the search path. */ typedef version_%_VER_% Your_png_h_is_not_version_%_VER_%; /* Version information for C files. This had better match the version - * string defined in png.h. */ + * string defined in png.h. + */ #ifdef PNG_USE_GLOBAL_ARRAYS /* png_libpng_ver was changed to a function in version 1.0.5c */ PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; @@ -94,11 +95,13 @@ #ifdef PNG_READ_SUPPORTED void PNGAPI png_set_sig_bytes(png_structp png_ptr, int num_bytes) { + png_debug(1, "in png_set_sig_bytes"); + if (png_ptr == NULL) return; - png_debug(1, "in png_set_sig_bytes"); + if (num_bytes > 8) png_error(png_ptr, "Too many bytes for PNG signature."); png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); @@ -268,12 +273,14 @@ void PNGAPI png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) { png_infop info_ptr = NULL; + + png_debug(1, "in png_destroy_info_struct"); + if (png_ptr == NULL) return; - png_debug(1, "in png_destroy_info_struct"); if (info_ptr_ptr != NULL) info_ptr = *info_ptr_ptr; if (info_ptr != NULL) @@ -308,13 +315,13 @@ png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) { png_infop info_ptr = *ptr_ptr; + png_debug(1, "in png_info_init_3"); + if (info_ptr == NULL) return; - png_debug(1, "in png_info_init_3"); - if (png_sizeof(png_info) > png_info_struct_size) { png_destroy_struct(info_ptr); info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); @@ -347,12 +356,13 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num) { png_debug(1, "in png_free_data"); + if (png_ptr == NULL || info_ptr == NULL) return; -#if defined(PNG_TEXT_SUPPORTED) +#ifdef PNG_TEXT_SUPPORTED /* Free text item num or (if num == -1) all text items */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) #else @@ -378,9 +388,9 @@ } } #endif -#if defined(PNG_tRNS_SUPPORTED) +#ifdef PNG_tRNS_SUPPORTED /* Free any tRNS entry */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) #else @@ -395,9 +405,9 @@ #endif } #endif -#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_sCAL_SUPPORTED /* Free any sCAL entry */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) #else @@ -413,9 +423,9 @@ info_ptr->valid &= ~PNG_INFO_sCAL; } #endif -#if defined(PNG_pCAL_SUPPORTED) +#ifdef PNG_pCAL_SUPPORTED /* Free any pCAL entry */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) #else @@ -440,9 +450,9 @@ info_ptr->valid &= ~PNG_INFO_pCAL; } #endif -#if defined(PNG_iCCP_SUPPORTED) +#ifdef PNG_iCCP_SUPPORTED /* Free any iCCP entry */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) #else @@ -456,9 +466,9 @@ info_ptr->valid &= ~PNG_INFO_iCCP; } #endif -#if defined(PNG_sPLT_SUPPORTED) +#ifdef PNG_sPLT_SUPPORTED /* Free a given sPLT entry, or (if num == -1) all sPLT entries */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) #else @@ -491,9 +501,9 @@ } } #endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED if (png_ptr->unknown_chunk.data) { png_free(png_ptr, png_ptr->unknown_chunk.data); png_ptr->unknown_chunk.data = NULL; @@ -529,9 +539,9 @@ } } #endif -#if defined(PNG_hIST_SUPPORTED) +#ifdef PNG_hIST_SUPPORTED /* Free any hIST entry */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_HIST) & info_ptr->free_me) #else @@ -562,9 +572,9 @@ #endif info_ptr->num_palette = 0; } -#if defined(PNG_INFO_IMAGE_SUPPORTED) +#ifdef PNG_INFO_IMAGE_SUPPORTED /* Free any image bits attached to the info structure */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) #else @@ -604,9 +614,9 @@ png_debug(1, "in png_info_destroy"); png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); -#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED if (png_ptr->num_chunk_list) { png_free(png_ptr, png_ptr->chunk_list); png_ptr->chunk_list=NULL; @@ -630,9 +640,9 @@ return (png_ptr->io_ptr); } #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#if !defined(PNG_NO_STDIO) +#ifndef PNG_NO_STDIO /* Initialize the default input/output functions for the PNG file. If you * use your own read or write routines, you can call either png_set_read_fn() * or png_set_write_fn() instead of png_init_io(). If you have defined * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't @@ -647,9 +659,9 @@ png_ptr->io_ptr = (png_voidp)fp; } #endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) +#ifdef PNG_TIME_RFC1123_SUPPORTED /* Convert the supplied time into an RFC 1123 string suitable for use in * a "Creation Time" or other text-based time string. */ png_charp PNGAPI @@ -666,9 +678,9 @@ png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* png_sizeof(char))); } -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE { wchar_t time_buf[29]; wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), ptime->day % 32, short_months[(ptime->month - 1) % 12], @@ -784,9 +796,9 @@ } #if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) +#ifndef PNG_1_0_X /* This function was added to libpng 1.2.0 */ int PNGAPI png_mmx_support(void) { @@ -809,10 +821,10 @@ } #endif /* PNG_SIZE_T */ /* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ -#if defined(PNG_cHRM_SUPPORTED) -#if !defined(PNG_NO_CHECK_cHRM) +#ifdef PNG_cHRM_SUPPORTED +#ifndef PNG_NO_CHECK_cHRM /* * Multiply two 32-bit numbers, V1 and V2, using 32-bit * arithmetic, to produce a 64 bit result in the HI/LO words. @@ -920,7 +933,149 @@ } return ret; } -#endif /* NO_PNG_CHECK_cHRM */ +#endif /* PNG_NO_CHECK_cHRM */ #endif /* PNG_cHRM_SUPPORTED */ + +void /* PRIVATE */ +png_check_IHDR(png_structp png_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type) +{ + int error = 0; + + /* Check for width and height valid values */ + if (width == 0) + { + png_warning(png_ptr, "Image width is zero in IHDR"); + error = 1; + } + + if (height == 0) + { + png_warning(png_ptr, "Image height is zero in IHDR"); + error = 1; + } + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (width > png_ptr->user_width_max || width > PNG_USER_WIDTH_MAX) +#else + if (width > PNG_USER_WIDTH_MAX) +#endif + { + png_warning(png_ptr, "Image width exceeds user limit in IHDR"); + error = 1; + } + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (height > png_ptr->user_height_max || height > PNG_USER_HEIGHT_MAX) +#else + if (height > PNG_USER_HEIGHT_MAX) +#endif + { + png_warning(png_ptr, "Image height exceeds user limit in IHDR"); + error = 1; + } + + if (width > PNG_UINT_31_MAX) + { + png_warning(png_ptr, "Invalid image width in IHDR"); + error = 1; + } + + if ( height > PNG_UINT_31_MAX) + { + png_warning(png_ptr, "Invalid image height in IHDR"); + error = 1; + } + + if ( width > (PNG_UINT_32_MAX + >> 3) /* 8-byte RGBA pixels */ + - 64 /* bigrowbuf hack */ + - 1 /* filter byte */ + - 7*8 /* rounding of width to multiple of 8 pixels */ + - 8) /* extra max_pixel_depth pad */ + png_warning(png_ptr, "Width is too large for libpng to process pixels"); + + /* Check other values */ + if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && + bit_depth != 8 && bit_depth != 16) + { + png_warning(png_ptr, "Invalid bit depth in IHDR"); + error = 1; + } + + if (color_type < 0 || color_type == 1 || + color_type == 5 || color_type > 6) + { + png_warning(png_ptr, "Invalid color type in IHDR"); + error = 1; + } + + if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || + ((color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) + { + png_warning(png_ptr, "Invalid color type/bit depth combination in IHDR"); + error = 1; + } + + if (interlace_type >= PNG_INTERLACE_LAST) + { + png_warning(png_ptr, "Unknown interlace method in IHDR"); + error = 1; + } + + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + { + png_warning(png_ptr, "Unknown compression method in IHDR"); + error = 1; + } + +#ifdef PNG_MNG_FEATURES_SUPPORTED + /* Accept filter_method 64 (intrapixel differencing) only if + * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and + * 2. Libpng did not read a PNG signature (this filter_method is only + * used in PNG datastreams that are embedded in MNG datastreams) and + * 3. The application called png_permit_mng_features with a mask that + * included PNG_FLAG_MNG_FILTER_64 and + * 4. The filter_method is 64 and + * 5. The color_type is RGB or RGBA + */ + if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) && + png_ptr->mng_features_permitted) + png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); + + if (filter_type != PNG_FILTER_TYPE_BASE) + { + if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && + ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA))) + { + png_warning(png_ptr, "Unknown filter method in IHDR"); + error = 1; + } + + if (png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) + { + png_warning(png_ptr, "Invalid filter method in IHDR"); + error = 1; + } + } + +#else + if (filter_type != PNG_FILTER_TYPE_BASE) + { + png_warning(png_ptr, "Unknown filter method in IHDR"); + error = 1; + } +#endif + + if (error == 1) + png_error(png_ptr, "Invalid IHDR data"); +} #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ diff -ru4NwbB libpng-1.2.40/png.h libpng-1.2.41beta05/png.h --- libpng-1.2.40/png.h 2009-09-10 06:38:50.123684056 -0500 +++ libpng-1.2.41beta05/png.h 2009-10-17 18:49:29.165619377 -0500 @@ -244,8 +244,9 @@ * 1.2.40beta01 13 10240 12.so.0.40[.0] * 1.2.40rc01 13 10240 12.so.0.40[.0] * 1.0.49 10 10049 10.so.0.49[.0] * 1.2.40 13 10240 12.so.0.40[.0] + * 1.2.41beta01-05 13 10241 12.so.0.41[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be * used for changes in backward compatibility, as it is intended. The @@ -3707,13 +3708,19 @@ #if defined(PNG_cHRM_SUPPORTED) #if !defined(PNG_NO_CHECK_cHRM) /* Added at libpng version 1.2.34 */ -PNG_EXTERN void png_64bit_product (long v1, long v2, unsigned long *hi_product, - unsigned long *lo_product); +PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2, + unsigned long *hi_product, unsigned long *lo_product)); #endif #endif +/* Added at libpng version 1.2.41 */ +PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type)); + /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ #endif /* PNG_INTERNAL */ diff -ru4NwbB libpng-1.2.40/pngconf.h libpng-1.2.41beta05/pngconf.h --- libpng-1.2.40/pngconf.h 2009-09-10 06:38:50.132156034 -0500 +++ libpng-1.2.41beta05/pngconf.h 2009-10-17 18:49:29.176413560 -0500 @@ -493,8 +493,9 @@ * will be turned on by default in libpng-1.4.0. */ #if defined(PNG_1_0_X) || defined (PNG_1_2_X) +# ifndef PNG_iTXt_SUPPORTED # ifndef PNG_NO_iTXt_SUPPORTED # define PNG_NO_iTXt_SUPPORTED # endif # ifndef PNG_NO_READ_iTXt @@ -503,8 +504,9 @@ # ifndef PNG_NO_WRITE_iTXt # define PNG_NO_WRITE_iTXt # endif #endif +#endif #if !defined(PNG_NO_iTXt_SUPPORTED) # if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) # define PNG_READ_iTXt @@ -786,18 +788,19 @@ #endif /* end of obsolete code to be removed from libpng-1.4.0 */ +/* Added at libpng-1.2.0 */ #if !defined(PNG_1_0_X) #if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) # define PNG_USER_MEM_SUPPORTED #endif #endif /* PNG_1_0_X */ /* Added at libpng-1.2.6 */ -#if !defined(PNG_1_0_X) +#ifndef PNG_1_0_X #ifndef PNG_SET_USER_LIMITS_SUPPORTED -#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) +# ifndef PNG_NO_SET_USER_LIMITS # define PNG_SET_USER_LIMITS_SUPPORTED #endif #endif #endif /* PNG_1_0_X */ diff -ru4NwbB libpng-1.2.40/pngerror.c libpng-1.2.41beta05/pngerror.c --- libpng-1.2.40/pngerror.c 2009-09-10 06:38:50.151989566 -0500 +++ libpng-1.2.41beta05/pngerror.c 2009-10-17 18:49:29.199295554 -0500 @@ -26,9 +26,9 @@ #ifndef PNG_NO_WARNINGS static void /* PRIVATE */ png_default_warning PNGARG((png_structp png_ptr, png_const_charp warning_message)); -#endif /* PNG_NO_WARNINGS */ +#endif /* PNG_WARNINGS_SUPPORTED */ /* This function is called whenever there is a fatal error. This function * should not be changed. If there is a need to handle errors differently, * you should supply a replacement error function and use png_set_error_fn() @@ -92,9 +92,9 @@ /* If the custom handler doesn't exist, or if it returns, use the default handler, which will not return. */ png_default_error(png_ptr, '\0'); } -#endif /* PNG_NO_ERROR_TEXT */ +#endif /* PNG_ERROR_TEXT_SUPPORTED */ #ifndef PNG_NO_WARNINGS /* This function is called whenever there is a non-fatal error. This function * should not be changed. If there is a need to handle warnings differently, @@ -124,9 +124,9 @@ (*(png_ptr->warning_fn))(png_ptr, warning_message + offset); else png_default_warning(png_ptr, warning_message + offset); } -#endif /* PNG_NO_WARNINGS */ +#endif /* PNG_WARNINGS_SUPPORTED */ /* These utilities are used internally to build an error message that relates * to the current chunk. The chunk name comes from png_ptr->chunk_name, @@ -189,9 +188,9 @@ png_error(png_ptr, msg); } } #endif /* PNG_READ_SUPPORTED */ -#endif /* !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) */ +#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */ #ifndef PNG_NO_WARNINGS void PNGAPI png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) @@ -204,9 +203,9 @@ png_format_buffer(png_ptr, msg, warning_message); png_warning(png_ptr, msg); } } -#endif /* PNG_NO_WARNINGS */ +#endif /* PNG_WARNINGS_SUPPORTED */ /* This is the default error handling function. Note that replacements for * this function MUST NOT RETURN, or the program will likely crash. This @@ -317,9 +316,9 @@ warning_message = warning_message; /* Make compiler happy */ #endif png_ptr = png_ptr; /* Make compiler happy */ } -#endif /* PNG_NO_WARNINGS */ +#endif /* PNG_WARNINGS_SUPPORTED */ /* This function is called when the application wants to use another method * of handling errors and warnings. Note that the error function MUST NOT * return to the calling routine or serious problems will occur. The return diff -ru4NwbB libpng-1.2.40/pnggccrd.c libpng-1.2.41beta05/pnggccrd.c --- libpng-1.2.40/pnggccrd.c 2009-09-10 06:38:50.156909811 -0500 +++ libpng-1.2.41beta05/pnggccrd.c 2009-10-17 18:49:29.203997169 -0500 @@ -16,11 +16,11 @@ int PNGAPI png_dummy_mmx_support(void) { int result; -#if defined(PNG_MMX_CODE_SUPPORTED) // superfluous, but what the heck +#ifdef PNG_MMX_CODE_SUPPORTED // superfluous, but what the heck __asm__ __volatile__ ( -#if defined(__x86_64__) +#ifdef __x86_64__ "pushq %%rbx \n\t" // rbx gets clobbered by CPUID instruction "pushq %%rcx \n\t" // so does rcx... "pushq %%rdx \n\t" // ...and rdx (but rcx & rdx safe on Linux) "pushfq \n\t" // save Eflag to stack @@ -70,9 +70,9 @@ "0: \n\t" // .NOT_SUPPORTED: target label for jump instructions "movl $0, %%eax \n\t" // set return value to 0 "1: \n\t" // .RETURN: target label for jump instructions -#if defined(__x86_64__) +#ifdef __x86_64__ "popq %%rdx \n\t" // restore rdx "popq %%rcx \n\t" // restore rcx "popq %%rbx \n\t" // restore rbx #else diff -ru4NwbB libpng-1.2.40/pngget.c libpng-1.2.41beta05/pngget.c --- libpng-1.2.40/pngget.c 2009-09-10 06:38:50.163801426 -0500 +++ libpng-1.2.41beta05/pngget.c 2009-10-17 18:49:29.210650826 -0500 @@ -1,8 +1,8 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.2.37 [June 4, 2009] + * Last changed in libpng 1.2.41 [October 17, 2009] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -35,9 +35,9 @@ else return(0); } -#if defined(PNG_INFO_IMAGE_SUPPORTED) +#ifdef PNG_INFO_IMAGE_SUPPORTED png_bytepp PNGAPI png_get_rows(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) @@ -116,9 +116,9 @@ png_uint_32 PNGAPI png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) +#ifdef PNG_pHYs_SUPPORTED if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter"); @@ -137,9 +137,9 @@ png_uint_32 PNGAPI png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) +#ifdef PNG_pHYs_SUPPORTED if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter"); @@ -158,9 +158,9 @@ png_uint_32 PNGAPI png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) +#ifdef PNG_pHYs_SUPPORTED if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); @@ -181,9 +181,9 @@ float PNGAPI png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_pHYs_SUPPORTED) +#ifdef PNG_pHYs_SUPPORTED if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); @@ -203,9 +205,9 @@ png_int_32 PNGAPI png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) +#ifdef PNG_oFFs_SUPPORTED if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); @@ -226,9 +228,9 @@ png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) +#ifdef PNG_oFFs_SUPPORTED if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); @@ -248,9 +250,9 @@ png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) +#ifdef PNG_oFFs_SUPPORTED if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); @@ -270,9 +272,9 @@ png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) -#if defined(PNG_oFFs_SUPPORTED) +#ifdef PNG_oFFs_SUPPORTED if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); @@ -323,9 +325,9 @@ return ((float)png_get_y_offset_microns(png_ptr, info_ptr) *.00003937); } -#if defined(PNG_pHYs_SUPPORTED) +#ifdef PNG_pHYs_SUPPORTED png_uint_32 PNGAPI png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) { @@ -381,9 +384,9 @@ else return (NULL); } -#if defined(PNG_bKGD_SUPPORTED) +#ifdef PNG_bKGD_SUPPORTED png_uint_32 PNGAPI png_get_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p *background) { @@ -397,9 +401,9 @@ return (0); } #endif -#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_cHRM_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI png_get_cHRM(png_structp png_ptr, png_infop info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, @@ -435,11 +440,12 @@ png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, png_fixed_point *blue_x, png_fixed_point *blue_y) { + png_debug1(1, "in %s retrieval function", "cHRM"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) { - png_debug1(1, "in %s retrieval function", "cHRM"); if (white_x != NULL) *white_x = info_ptr->int_x_white; if (white_y != NULL) *white_y = info_ptr->int_y_white; @@ -461,17 +467,18 @@ } #endif #endif -#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_gAMA_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) { + png_debug1(1, "in %s retrieval function", "gAMA"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) && file_gamma != NULL) { - png_debug1(1, "in %s retrieval function", "gAMA"); *file_gamma = (double)info_ptr->gamma; return (PNG_INFO_gAMA); } return (0); @@ -481,45 +488,48 @@ png_uint_32 PNGAPI png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point *int_file_gamma) { + png_debug1(1, "in %s retrieval function", "gAMA"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) && int_file_gamma != NULL) { - png_debug1(1, "in %s retrieval function", "gAMA"); *int_file_gamma = info_ptr->int_gamma; return (PNG_INFO_gAMA); } return (0); } #endif #endif -#if defined(PNG_sRGB_SUPPORTED) +#ifdef PNG_sRGB_SUPPORTED png_uint_32 PNGAPI png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) { + png_debug1(1, "in %s retrieval function", "sRGB"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) && file_srgb_intent != NULL) { - png_debug1(1, "in %s retrieval function", "sRGB"); *file_srgb_intent = (int)info_ptr->srgb_intent; return (PNG_INFO_sRGB); } return (0); } #endif -#if defined(PNG_iCCP_SUPPORTED) +#ifdef PNG_iCCP_SUPPORTED png_uint_32 PNGAPI png_get_iCCP(png_structp png_ptr, png_infop info_ptr, png_charpp name, int *compression_type, png_charpp profile, png_uint_32 *proflen) { + png_debug1(1, "in %s retrieval function", "iCCP"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) && name != NULL && profile != NULL && proflen != NULL) { - png_debug1(1, "in %s retrieval function", "iCCP"); *name = info_ptr->iccp_name; *profile = info_ptr->iccp_profile; /* Compression_type is a dummy so the API won't have to change * if we introduce multiple compression types later. @@ -531,9 +541,9 @@ return (0); } #endif -#if defined(PNG_sPLT_SUPPORTED) +#ifdef PNG_sPLT_SUPPORTED png_uint_32 PNGAPI png_get_sPLT(png_structp png_ptr, png_infop info_ptr, png_sPLT_tpp spalettes) { @@ -545,16 +555,17 @@ return (0); } #endif -#if defined(PNG_hIST_SUPPORTED) +#ifdef PNG_hIST_SUPPORTED png_uint_32 PNGAPI png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) { + png_debug1(1, "in %s retrieval function", "hIST"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) && hist != NULL) { - png_debug1(1, "in %s retrieval function", "hIST"); *hist = info_ptr->hist; return (PNG_INFO_hIST); } return (0); @@ -567,23 +578,19 @@ int *color_type, int *interlace_type, int *compression_type, int *filter_type) { - if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && - bit_depth != NULL && color_type != NULL) - { png_debug1(1, "in %s retrieval function", "IHDR"); + + if (png_ptr == NULL || info_ptr == NULL || width == NULL || + height == NULL || bit_depth == NULL || color_type == NULL) + return (0); + *width = info_ptr->width; *height = info_ptr->height; *bit_depth = info_ptr->bit_depth; - if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) - png_error(png_ptr, "Invalid bit depth"); - *color_type = info_ptr->color_type; - if (info_ptr->color_type > 6) - png_error(png_ptr, "Invalid color type"); - if (compression_type != NULL) *compression_type = info_ptr->compression_type; if (filter_type != NULL) @@ -591,40 +598,30 @@ if (interlace_type != NULL) *interlace_type = info_ptr->interlace_type; - /* Check for potential overflow of rowbytes */ - if (*width == 0 || *width > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image width"); - - if (*height == 0 || *height > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image height"); - - if (info_ptr->width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - { - png_warning(png_ptr, - "Width too large for libpng to process image data."); - } + /* This is redundant if we can be sure that the info_ptr values were all + * assigned in png_set_IHDR(). We do the check anyhow in case an + * application has ignored our advice not to mess with the members + * of info_ptr directly. + */ + png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height, + info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, + info_ptr->compression_type, info_ptr->filter_type); return (1); } - return (0); -} -#if defined(PNG_oFFs_SUPPORTED) +#ifdef PNG_oFFs_SUPPORTED png_uint_32 PNGAPI png_get_oFFs(png_structp png_ptr, png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) { + png_debug1(1, "in %s retrieval function", "oFFs"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) && offset_x != NULL && offset_y != NULL && unit_type != NULL) { - png_debug1(1, "in %s retrieval function", "oFFs"); *offset_x = info_ptr->x_offset; *offset_y = info_ptr->y_offset; *unit_type = (int)info_ptr->offset_unit_type; return (PNG_INFO_oFFs); @@ -632,19 +629,20 @@ return (0); } #endif -#if defined(PNG_pCAL_SUPPORTED) +#ifdef PNG_pCAL_SUPPORTED png_uint_32 PNGAPI png_get_pCAL(png_structp png_ptr, png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *units, png_charpp *params) { + png_debug1(1, "in %s retrieval function", "pCAL"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && nparams != NULL && units != NULL && params != NULL) { - png_debug1(1, "in %s retrieval function", "pCAL"); *purpose = info_ptr->pcal_purpose; *X0 = info_ptr->pcal_X0; *X1 = info_ptr->pcal_X1; *type = (int)info_ptr->pcal_type; @@ -656,9 +654,9 @@ return (0); } #endif -#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_sCAL_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI png_get_sCAL(png_structp png_ptr, png_infop info_ptr, int *unit, double *width, double *height) @@ -692,20 +690,20 @@ #endif #endif #endif -#if defined(PNG_pHYs_SUPPORTED) +#ifdef PNG_pHYs_SUPPORTED png_uint_32 PNGAPI png_get_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) { png_uint_32 retval = 0; + png_debug1(1, "in %s retrieval function", "pHYs"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { - png_debug1(1, "in %s retrieval function", "pHYs"); - if (res_x != NULL) { *res_x = info_ptr->x_pixels_per_unit; retval |= PNG_INFO_pHYs; @@ -730,36 +728,38 @@ png_uint_32 PNGAPI png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, int *num_palette) { + png_debug1(1, "in %s retrieval function", "PLTE"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) && palette != NULL) { - png_debug1(1, "in %s retrieval function", "PLTE"); *palette = info_ptr->palette; *num_palette = info_ptr->num_palette; png_debug1(3, "num_palette = %d", *num_palette); return (PNG_INFO_PLTE); } return (0); } -#if defined(PNG_sBIT_SUPPORTED) +#ifdef PNG_sBIT_SUPPORTED png_uint_32 PNGAPI png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) { + png_debug1(1, "in %s retrieval function", "sBIT"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) && sig_bit != NULL) { - png_debug1(1, "in %s retrieval function", "sBIT"); *sig_bit = &(info_ptr->sig_bit); return (PNG_INFO_sBIT); } return (0); } #endif -#if defined(PNG_TEXT_SUPPORTED) +#ifdef PNG_TEXT_SUPPORTED png_uint_32 PNGAPI png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, int *num_text) { @@ -782,24 +782,25 @@ return(0); } #endif -#if defined(PNG_tIME_SUPPORTED) +#ifdef PNG_tIME_SUPPORTED png_uint_32 PNGAPI png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) { + png_debug1(1, "in %s retrieval function", "tIME"); + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) && mod_time != NULL) { - png_debug1(1, "in %s retrieval function", "tIME"); *mod_time = &(info_ptr->mod_time); return (PNG_INFO_tIME); } return (0); } #endif -#if defined(PNG_tRNS_SUPPORTED) +#ifdef PNG_tRNS_SUPPORTED png_uint_32 PNGAPI png_get_tRNS(png_structp png_ptr, png_infop info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values) { @@ -838,9 +840,9 @@ return (retval); } #endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED png_uint_32 PNGAPI png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_unknown_chunkpp unknowns) { @@ -852,17 +854,17 @@ return (0); } #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED png_byte PNGAPI png_get_rgb_to_gray_status (png_structp png_ptr) { return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); } #endif -#if defined(PNG_USER_CHUNKS_SUPPORTED) +#ifdef PNG_USER_CHUNKS_SUPPORTED png_voidp PNGAPI png_get_user_chunk_ptr(png_structp png_ptr) { return (png_ptr? png_ptr->user_chunk_ptr : NULL); diff -ru4NwbB libpng-1.2.40/pngmem.c libpng-1.2.41beta05/pngmem.c --- libpng-1.2.40/pngmem.c 2009-09-10 06:38:50.170001040 -0500 +++ libpng-1.2.41beta05/pngmem.c 2009-10-17 18:49:29.216747409 -0500 @@ -537,9 +537,9 @@ } #endif /* Not Borland DOS special memory handler */ -#if defined(PNG_1_0_X) +#ifdef PNG_1_0_X # define png_malloc_warn png_malloc #else /* This function was added at libpng version 1.2.3. The png_malloc_warn() * function will set up png_malloc() to issue a png_warning and return NULL diff -ru4NwbB libpng-1.2.40/pngpread.c libpng-1.2.41beta05/pngpread.c --- libpng-1.2.40/pngpread.c 2009-09-10 06:38:50.177986362 -0500 +++ libpng-1.2.41beta05/pngpread.c 2009-10-17 18:49:29.224694612 -0500 @@ -69,25 +69,25 @@ png_push_read_IDAT(png_ptr); break; } -#if defined(PNG_READ_tEXt_SUPPORTED) +#ifdef PNG_READ_tEXt_SUPPORTED case PNG_READ_tEXt_MODE: { png_push_read_tEXt(png_ptr, info_ptr); break; } #endif -#if defined(PNG_READ_zTXt_SUPPORTED) +#ifdef PNG_READ_zTXt_SUPPORTED case PNG_READ_zTXt_MODE: { png_push_read_zTXt(png_ptr, info_ptr); break; } #endif -#if defined(PNG_READ_iTXt_SUPPORTED) +#ifdef PNG_READ_iTXt_SUPPORTED case PNG_READ_iTXt_MODE: { png_push_read_iTXt(png_ptr, info_ptr); break; @@ -153,60 +153,61 @@ PNG_CONST PNG_IHDR; PNG_CONST PNG_IDAT; PNG_CONST PNG_IEND; PNG_CONST PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) +#ifdef PNG_READ_bKGD_SUPPORTED PNG_CONST PNG_bKGD; #endif -#if defined(PNG_READ_cHRM_SUPPORTED) +#ifdef PNG_READ_cHRM_SUPPORTED PNG_CONST PNG_cHRM; #endif -#if defined(PNG_READ_gAMA_SUPPORTED) +#ifdef PNG_READ_gAMA_SUPPORTED PNG_CONST PNG_gAMA; #endif -#if defined(PNG_READ_hIST_SUPPORTED) +#ifdef PNG_READ_hIST_SUPPORTED PNG_CONST PNG_hIST; #endif -#if defined(PNG_READ_iCCP_SUPPORTED) +#ifdef PNG_READ_iCCP_SUPPORTED PNG_CONST PNG_iCCP; #endif -#if defined(PNG_READ_iTXt_SUPPORTED) +#ifdef PNG_READ_iTXt_SUPPORTED PNG_CONST PNG_iTXt; #endif -#if defined(PNG_READ_oFFs_SUPPORTED) +#ifdef PNG_READ_oFFs_SUPPORTED PNG_CONST PNG_oFFs; #endif -#if defined(PNG_READ_pCAL_SUPPORTED) +#ifdef PNG_READ_pCAL_SUPPORTED PNG_CONST PNG_pCAL; #endif -#if defined(PNG_READ_pHYs_SUPPORTED) +#ifdef PNG_READ_pHYs_SUPPORTED PNG_CONST PNG_pHYs; #endif -#if defined(PNG_READ_sBIT_SUPPORTED) +#ifdef PNG_READ_sBIT_SUPPORTED PNG_CONST PNG_sBIT; #endif -#if defined(PNG_READ_sCAL_SUPPORTED) +#ifdef PNG_READ_sCAL_SUPPORTED PNG_CONST PNG_sCAL; #endif -#if defined(PNG_READ_sRGB_SUPPORTED) +#ifdef PNG_READ_sRGB_SUPPORTED PNG_CONST PNG_sRGB; #endif -#if defined(PNG_READ_sPLT_SUPPORTED) +#ifdef PNG_READ_sPLT_SUPPORTED PNG_CONST PNG_sPLT; #endif -#if defined(PNG_READ_tEXt_SUPPORTED) +#ifdef PNG_READ_tEXt_SUPPORTED PNG_CONST PNG_tEXt; #endif -#if defined(PNG_READ_tIME_SUPPORTED) +#ifdef PNG_READ_tIME_SUPPORTED PNG_CONST PNG_tIME; #endif -#if defined(PNG_READ_tRNS_SUPPORTED) +#ifdef PNG_READ_tRNS_SUPPORTED PNG_CONST PNG_tRNS; #endif -#if defined(PNG_READ_zTXt_SUPPORTED) +#ifdef PNG_READ_zTXt_SUPPORTED PNG_CONST PNG_zTXt; #endif #endif /* PNG_USE_LOCAL_ARRAYS */ + /* First we make sure we have enough data for the 4 byte chunk name * and the 4 byte chunk length before proceeding with decoding the * chunk data. To fully decode each of these chunks, we also make * sure we have enough data in the buffer for the 4 byte CRC at the @@ -333,9 +334,9 @@ png_ptr->zstream.next_out = png_ptr->row_buf; return; } -#if defined(PNG_READ_gAMA_SUPPORTED) +#ifdef PNG_READ_gAMA_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -346,9 +347,9 @@ png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_sBIT_SUPPORTED) +#ifdef PNG_READ_sBIT_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -359,9 +360,9 @@ png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_cHRM_SUPPORTED) +#ifdef PNG_READ_cHRM_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -372,9 +373,9 @@ png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_sRGB_SUPPORTED) +#ifdef PNG_READ_sRGB_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -385,9 +386,9 @@ png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_iCCP_SUPPORTED) +#ifdef PNG_READ_iCCP_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -398,9 +399,9 @@ png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_sPLT_SUPPORTED) +#ifdef PNG_READ_sPLT_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -411,9 +412,9 @@ png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_tRNS_SUPPORTED) +#ifdef PNG_READ_tRNS_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -424,9 +425,9 @@ png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_bKGD_SUPPORTED) +#ifdef PNG_READ_bKGD_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -437,9 +438,9 @@ png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_hIST_SUPPORTED) +#ifdef PNG_READ_hIST_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -450,9 +451,9 @@ png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_pHYs_SUPPORTED) +#ifdef PNG_READ_pHYs_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -463,9 +464,9 @@ png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_oFFs_SUPPORTED) +#ifdef PNG_READ_oFFs_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -476,9 +477,9 @@ png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_pCAL_SUPPORTED) +#ifdef PNG_READ_pCAL_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -489,9 +490,9 @@ png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_sCAL_SUPPORTED) +#ifdef PNG_READ_sCAL_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -502,9 +503,9 @@ png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_tIME_SUPPORTED) +#ifdef PNG_READ_tIME_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -515,9 +516,9 @@ png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_tEXt_SUPPORTED) +#ifdef PNG_READ_tEXt_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -528,9 +529,9 @@ png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_zTXt_SUPPORTED) +#ifdef PNG_READ_zTXt_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -541,9 +542,9 @@ png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); } #endif -#if defined(PNG_READ_iTXt_SUPPORTED) +#ifdef PNG_READ_iTXt_SUPPORTED else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { @@ -858,9 +859,9 @@ } if (!(png_ptr->zstream.avail_out)) { if (( -#if defined(PNG_READ_INTERLACING_SUPPORTED) +#ifdef PNG_READ_INTERLACING_SUPPORTED png_ptr->interlaced && png_ptr->pass > 6) || (!png_ptr->interlaced && #endif png_ptr->row_number == png_ptr->num_rows)) @@ -901,9 +902,9 @@ if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) png_do_read_transformations(png_ptr); -#if defined(PNG_READ_INTERLACING_SUPPORTED) +#ifdef PNG_READ_INTERLACING_SUPPORTED /* Blow up interlaced rows to full size */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { if (png_ptr->pass < 6) @@ -1113,9 +1114,9 @@ png_ptr->row_number++; if (png_ptr->row_number < png_ptr->num_rows) return; -#if defined(PNG_READ_INTERLACING_SUPPORTED) +#ifdef PNG_READ_INTERLACING_SUPPORTED if (png_ptr->interlaced) { png_ptr->row_number = 0; png_memset_check(png_ptr, png_ptr->prev_row, 0, @@ -1154,9 +1155,9 @@ } #endif /* PNG_READ_INTERLACING_SUPPORTED */ } -#if defined(PNG_READ_tEXt_SUPPORTED) +#ifdef PNG_READ_tEXt_SUPPORTED void /* PRIVATE */ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { @@ -1217,9 +1218,9 @@ } png_push_crc_finish(png_ptr); -#if defined(PNG_MAX_MALLOC_64K) +#ifdef PNG_MAX_MALLOC_64K if (png_ptr->skip_length) return; #endif @@ -1252,9 +1253,9 @@ } } #endif -#if defined(PNG_READ_zTXt_SUPPORTED) +#ifdef PNG_READ_zTXt_SUPPORTED void /* PRIVATE */ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { @@ -1453,9 +1454,9 @@ } } #endif -#if defined(PNG_READ_iTXt_SUPPORTED) +#ifdef PNG_READ_iTXt_SUPPORTED void /* PRIVATE */ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { @@ -1520,9 +1521,9 @@ } png_push_crc_finish(png_ptr); -#if defined(PNG_MAX_MALLOC_64K) +#ifdef PNG_MAX_MALLOC_64K if (png_ptr->skip_length) return; #endif @@ -1586,12 +1587,12 @@ png_uint_32 skip = 0; if (!(png_ptr->chunk_name[0] & 0x20)) { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != PNG_HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED && png_ptr->read_user_chunk_fn == NULL #endif ) #endif @@ -1599,9 +1600,9 @@ info_ptr = info_ptr; /* To quiet some compiler warnings */ } -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) { #ifdef PNG_MAX_MALLOC_64K if (length > (png_uint_32)65535L) @@ -1628,9 +1629,9 @@ (png_uint_32)length); png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); } -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED if (png_ptr->read_user_chunk_fn != NULL) { /* Callback to user unknown chunk handler */ int ret; diff -ru4NwbB libpng-1.2.40/pngread.c libpng-1.2.41beta05/pngread.c --- libpng-1.2.40/pngread.c 2009-09-10 06:38:50.186045489 -0500 +++ libpng-1.2.41beta05/pngread.c 2009-10-17 18:49:29.233202792 -0500 @@ -1,8 +1,8 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.2.37 [June 4, 2009] + * Last changed in libpng 1.2.41 [October 17, 2009] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -15,9 +15,10 @@ */ #define PNG_INTERNAL #include "png.h" -#if defined(PNG_READ_SUPPORTED) +#ifdef PNG_READ_SUPPORTED + /* Create a PNG structure for reading, and allocate any memory needed. */ png_structp PNGAPI png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, @@ -85,9 +87,9 @@ } #ifdef USE_FAR_KEYWORD png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); #endif -#endif +#endif /* PNG_SETJMP_SUPPORTED */ #ifdef PNG_USER_MEM_SUPPORTED png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); #endif @@ -151,13 +153,16 @@ switch (inflateInit(&png_ptr->zstream)) { case Z_OK: /* Do nothing */ break; case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; + case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); + break; + case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); + break; default: png_error(png_ptr, "Unknown zlib error"); } + png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); @@ -162,27 +167,29 @@ png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); #ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ +/* Applications that neglect to set up their own setjmp() and then + encounter a png_error() will longjmp here. Since the jmpbuf is + then meaningless we abort instead of returning. */ #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) PNG_ABORT(); png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); #else if (setjmp(png_ptr->jmpbuf)) PNG_ABORT(); #endif -#endif +#endif /* PNG_SETJMP_SUPPORTED */ + return (png_ptr); } #if defined(PNG_1_0_X) || defined(PNG_1_2_X) /* Initialize PNG structure for reading, and allocate any memory needed. - This interface is deprecated in favour of the png_create_read_struct(), - and it will disappear as of libpng-1.3.0. */ + * This interface is deprecated in favour of the png_create_read_struct(), + * and it will disappear as of libpng-1.3.0. + */ #undef png_read_init void PNGAPI png_read_init(png_structp png_ptr) { @@ -297,8 +304,9 @@ #endif /* Initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; + png_ptr->zstream.zalloc = png_zalloc; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); png_ptr->zstream.zalloc = png_zalloc; png_ptr->zstream.zfree = png_zfree; @@ -306,11 +314,10 @@ switch (inflateInit(&png_ptr->zstream)) { case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; + case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; + case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; default: png_error(png_ptr, "Unknown zlib error"); } png_ptr->zstream.next_out = png_ptr->zbuf; @@ -318,9 +325,9 @@ png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); } -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ /* Read the information before the actual image data. This has been * changed in v0.90 to allow reading a file that already has the magic * bytes read from the stream. You can tell libpng how many bytes have * been read from the beginning of the stream (up to the maximum of 8) @@ -330,11 +337,13 @@ */ void PNGAPI png_read_info(png_structp png_ptr, png_infop info_ptr) { + png_debug(1, "in png_read_info"); + if (png_ptr == NULL || info_ptr == NULL) return; - png_debug(1, "in png_read_info"); + /* If we haven't checked all of the PNG signature bytes, do so now. */ if (png_ptr->sig_bytes < 8) { png_size_t num_checked = png_ptr->sig_bytes, @@ -356,65 +365,63 @@ } for (;;) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_CONST PNG_IHDR; - PNG_CONST PNG_IDAT; - PNG_CONST PNG_IEND; - PNG_CONST PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_CONST PNG_bKGD; + PNG_IHDR; + PNG_IDAT; + PNG_IEND; + PNG_PLTE; +#ifdef PNG_READ_bKGD_SUPPORTED + PNG_bKGD; #endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_CONST PNG_cHRM; +#ifdef PNG_READ_cHRM_SUPPORTED + PNG_cHRM; #endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_CONST PNG_gAMA; +#ifdef PNG_READ_gAMA_SUPPORTED + PNG_gAMA; #endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_CONST PNG_hIST; +#ifdef PNG_READ_hIST_SUPPORTED + PNG_hIST; #endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_CONST PNG_iCCP; +#ifdef PNG_READ_iCCP_SUPPORTED + PNG_iCCP; #endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_CONST PNG_iTXt; +#ifdef PNG_READ_iTXt_SUPPORTED + PNG_iTXt; #endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_CONST PNG_oFFs; +#ifdef PNG_READ_oFFs_SUPPORTED + PNG_oFFs; #endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_CONST PNG_pCAL; +#ifdef PNG_READ_pCAL_SUPPORTED + PNG_pCAL; #endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_CONST PNG_pHYs; +#ifdef PNG_READ_pHYs_SUPPORTED + PNG_pHYs; #endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_CONST PNG_sBIT; +#ifdef PNG_READ_sBIT_SUPPORTED + PNG_sBIT; #endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_CONST PNG_sCAL; +#ifdef PNG_READ_sCAL_SUPPORTED + PNG_sCAL; #endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_CONST PNG_sPLT; +#ifdef PNG_READ_sPLT_SUPPORTED + PNG_sPLT; #endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_CONST PNG_sRGB; +#ifdef PNG_READ_sRGB_SUPPORTED + PNG_sRGB; #endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_CONST PNG_tEXt; +#ifdef PNG_READ_tEXt_SUPPORTED + PNG_tEXt; #endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_CONST PNG_tIME; +#ifdef PNG_READ_tIME_SUPPORTED + PNG_tIME; #endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_CONST PNG_tRNS; +#ifdef PNG_READ_tRNS_SUPPORTED + PNG_tRNS; #endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_CONST PNG_zTXt; +#ifdef PNG_READ_zTXt_SUPPORTED + PNG_zTXt; #endif -#endif /* PNG_USE_LOCAL_ARRAYS */ png_uint_32 length = png_read_chunk_header(png_ptr); PNG_CONST png_bytep chunk_name = png_ptr->chunk_name; /* This should be a binary subdivision search or a hash for @@ -460,81 +467,81 @@ png_ptr->idat_size = length; png_ptr->mode |= PNG_HAVE_IDAT; break; } -#if defined(PNG_READ_bKGD_SUPPORTED) +#ifdef PNG_READ_bKGD_SUPPORTED else if (!png_memcmp(chunk_name, png_bKGD, 4)) png_handle_bKGD(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_cHRM_SUPPORTED) +#ifdef PNG_READ_cHRM_SUPPORTED else if (!png_memcmp(chunk_name, png_cHRM, 4)) png_handle_cHRM(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_gAMA_SUPPORTED) +#ifdef PNG_READ_gAMA_SUPPORTED else if (!png_memcmp(chunk_name, png_gAMA, 4)) png_handle_gAMA(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_hIST_SUPPORTED) +#ifdef PNG_READ_hIST_SUPPORTED else if (!png_memcmp(chunk_name, png_hIST, 4)) png_handle_hIST(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_oFFs_SUPPORTED) +#ifdef PNG_READ_oFFs_SUPPORTED else if (!png_memcmp(chunk_name, png_oFFs, 4)) png_handle_oFFs(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_pCAL_SUPPORTED) +#ifdef PNG_READ_pCAL_SUPPORTED else if (!png_memcmp(chunk_name, png_pCAL, 4)) png_handle_pCAL(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sCAL_SUPPORTED) +#ifdef PNG_READ_sCAL_SUPPORTED else if (!png_memcmp(chunk_name, png_sCAL, 4)) png_handle_sCAL(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_pHYs_SUPPORTED) +#ifdef PNG_READ_pHYs_SUPPORTED else if (!png_memcmp(chunk_name, png_pHYs, 4)) png_handle_pHYs(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sBIT_SUPPORTED) +#ifdef PNG_READ_sBIT_SUPPORTED else if (!png_memcmp(chunk_name, png_sBIT, 4)) png_handle_sBIT(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sRGB_SUPPORTED) +#ifdef PNG_READ_sRGB_SUPPORTED else if (!png_memcmp(chunk_name, png_sRGB, 4)) png_handle_sRGB(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_iCCP_SUPPORTED) +#ifdef PNG_READ_iCCP_SUPPORTED else if (!png_memcmp(chunk_name, png_iCCP, 4)) png_handle_iCCP(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sPLT_SUPPORTED) +#ifdef PNG_READ_sPLT_SUPPORTED else if (!png_memcmp(chunk_name, png_sPLT, 4)) png_handle_sPLT(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tEXt_SUPPORTED) +#ifdef PNG_READ_tEXt_SUPPORTED else if (!png_memcmp(chunk_name, png_tEXt, 4)) png_handle_tEXt(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tIME_SUPPORTED) +#ifdef PNG_READ_tIME_SUPPORTED else if (!png_memcmp(chunk_name, png_tIME, 4)) png_handle_tIME(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tRNS_SUPPORTED) +#ifdef PNG_READ_tRNS_SUPPORTED else if (!png_memcmp(chunk_name, png_tRNS, 4)) png_handle_tRNS(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_zTXt_SUPPORTED) +#ifdef PNG_READ_zTXt_SUPPORTED else if (!png_memcmp(chunk_name, png_zTXt, 4)) png_handle_zTXt(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_iTXt_SUPPORTED) +#ifdef PNG_READ_iTXt_SUPPORTED else if (!png_memcmp(chunk_name, png_iTXt, 4)) png_handle_iTXt(png_ptr, info_ptr, length); #endif else png_handle_unknown(png_ptr, info_ptr, length); } } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ /* Optional call to update the users info_ptr structure */ void PNGAPI png_read_update_info(png_structp png_ptr, png_infop info_ptr) @@ -549,9 +557,9 @@ "Ignoring extra png_read_update_info() call; row buffer not reallocated"); png_read_transform_info(png_ptr, info_ptr); } -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ /* Initialize palette, background, etc, after transformations * are set, but before any reading takes place. This allows * the user to obtain a gamma-corrected palette, for example. * If the user doesn't call this, we will do it ourselves. @@ -564,25 +573,26 @@ return; if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ void PNGAPI png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_CONST PNG_IDAT; + PNG_IDAT; PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; -#endif int ret; + if (png_ptr == NULL) return; + png_debug2(1, "in png_read_row (row %lu, pass %d)", png_ptr->row_number, png_ptr->pass); + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); if (png_ptr->row_number == 0 && png_ptr->pass == 0) { @@ -616,9 +626,9 @@ png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); #endif } -#if defined(PNG_READ_INTERLACING_SUPPORTED) +#ifdef PNG_READ_INTERLACING_SUPPORTED /* If interlaced and we do not need a new row, combine row and return */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { switch (png_ptr->pass) @@ -750,9 +760,9 @@ png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1); -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) { /* Intrapixel differencing */ @@ -763,9 +773,9 @@ if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) png_do_read_transformations(png_ptr); -#if defined(PNG_READ_INTERLACING_SUPPORTED) +#ifdef PNG_READ_INTERLACING_SUPPORTED /* Blow up interlaced rows to full size */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { @@ -795,11 +805,11 @@ if (png_ptr->read_row_fn != NULL) (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ /* Read one or more rows of image data. If the image is interlaced, * and png_set_interlace_handling() has been called, the rows need to * contain the contents of the rows from the previous pass. If the * image has alpha or transparency, and png_handle_alpha()[*] has been @@ -858,11 +869,11 @@ png_read_row(png_ptr, png_bytep_NULL, dptr); dp++; } } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ /* Read the entire image. If the image has an alpha channel or a tRNS * chunk, and you have called png_handle_alpha()[*], you will need to * initialize the image to the current image that PNG will be overlaying. * We set the num_rows again here, in case it was incorrectly set in @@ -907,11 +919,11 @@ rp++; } } } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ /* Read the end of the PNG file. Will not read past the end of the * file, will verify the end is accurate, and will read any comments * or time information at the end of the file, if info is not NULL. */ @@ -924,65 +937,63 @@ png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ do { -#ifdef PNG_USE_LOCAL_ARRAYS - PNG_CONST PNG_IHDR; - PNG_CONST PNG_IDAT; - PNG_CONST PNG_IEND; - PNG_CONST PNG_PLTE; -#if defined(PNG_READ_bKGD_SUPPORTED) - PNG_CONST PNG_bKGD; + PNG_IHDR; + PNG_IDAT; + PNG_IEND; + PNG_PLTE; +#ifdef PNG_READ_bKGD_SUPPORTED + PNG_bKGD; #endif -#if defined(PNG_READ_cHRM_SUPPORTED) - PNG_CONST PNG_cHRM; +#ifdef PNG_READ_cHRM_SUPPORTED + PNG_cHRM; #endif -#if defined(PNG_READ_gAMA_SUPPORTED) - PNG_CONST PNG_gAMA; +#ifdef PNG_READ_gAMA_SUPPORTED + PNG_gAMA; #endif -#if defined(PNG_READ_hIST_SUPPORTED) - PNG_CONST PNG_hIST; +#ifdef PNG_READ_hIST_SUPPORTED + PNG_hIST; #endif -#if defined(PNG_READ_iCCP_SUPPORTED) - PNG_CONST PNG_iCCP; +#ifdef PNG_READ_iCCP_SUPPORTED + PNG_iCCP; #endif -#if defined(PNG_READ_iTXt_SUPPORTED) - PNG_CONST PNG_iTXt; +#ifdef PNG_READ_iTXt_SUPPORTED + PNG_iTXt; #endif -#if defined(PNG_READ_oFFs_SUPPORTED) - PNG_CONST PNG_oFFs; +#ifdef PNG_READ_oFFs_SUPPORTED + PNG_oFFs; #endif -#if defined(PNG_READ_pCAL_SUPPORTED) - PNG_CONST PNG_pCAL; +#ifdef PNG_READ_pCAL_SUPPORTED + PNG_pCAL; #endif -#if defined(PNG_READ_pHYs_SUPPORTED) - PNG_CONST PNG_pHYs; +#ifdef PNG_READ_pHYs_SUPPORTED + PNG_pHYs; #endif -#if defined(PNG_READ_sBIT_SUPPORTED) - PNG_CONST PNG_sBIT; +#ifdef PNG_READ_sBIT_SUPPORTED + PNG_sBIT; #endif -#if defined(PNG_READ_sCAL_SUPPORTED) - PNG_CONST PNG_sCAL; +#ifdef PNG_READ_sCAL_SUPPORTED + PNG_sCAL; #endif -#if defined(PNG_READ_sPLT_SUPPORTED) - PNG_CONST PNG_sPLT; +#ifdef PNG_READ_sPLT_SUPPORTED + PNG_sPLT; #endif -#if defined(PNG_READ_sRGB_SUPPORTED) - PNG_CONST PNG_sRGB; +#ifdef PNG_READ_sRGB_SUPPORTED + PNG_sRGB; #endif -#if defined(PNG_READ_tEXt_SUPPORTED) - PNG_CONST PNG_tEXt; +#ifdef PNG_READ_tEXt_SUPPORTED + PNG_tEXt; #endif -#if defined(PNG_READ_tIME_SUPPORTED) - PNG_CONST PNG_tIME; +#ifdef PNG_READ_tIME_SUPPORTED + PNG_tIME; #endif -#if defined(PNG_READ_tRNS_SUPPORTED) - PNG_CONST PNG_tRNS; +#ifdef PNG_READ_tRNS_SUPPORTED + PNG_tRNS; #endif -#if defined(PNG_READ_zTXt_SUPPORTED) - PNG_CONST PNG_zTXt; +#ifdef PNG_READ_zTXt_SUPPORTED + PNG_zTXt; #endif -#endif /* PNG_USE_LOCAL_ARRAYS */ png_uint_32 length = png_read_chunk_header(png_ptr); PNG_CONST png_bytep chunk_name = png_ptr->chunk_name; if (!png_memcmp(chunk_name, png_IHDR, 4)) @@ -1012,81 +1023,81 @@ png_crc_finish(png_ptr, length); } else if (!png_memcmp(chunk_name, png_PLTE, 4)) png_handle_PLTE(png_ptr, info_ptr, length); -#if defined(PNG_READ_bKGD_SUPPORTED) +#ifdef PNG_READ_bKGD_SUPPORTED else if (!png_memcmp(chunk_name, png_bKGD, 4)) png_handle_bKGD(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_cHRM_SUPPORTED) +#ifdef PNG_READ_cHRM_SUPPORTED else if (!png_memcmp(chunk_name, png_cHRM, 4)) png_handle_cHRM(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_gAMA_SUPPORTED) +#ifdef PNG_READ_gAMA_SUPPORTED else if (!png_memcmp(chunk_name, png_gAMA, 4)) png_handle_gAMA(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_hIST_SUPPORTED) +#ifdef PNG_READ_hIST_SUPPORTED else if (!png_memcmp(chunk_name, png_hIST, 4)) png_handle_hIST(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_oFFs_SUPPORTED) +#ifdef PNG_READ_oFFs_SUPPORTED else if (!png_memcmp(chunk_name, png_oFFs, 4)) png_handle_oFFs(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_pCAL_SUPPORTED) +#ifdef PNG_READ_pCAL_SUPPORTED else if (!png_memcmp(chunk_name, png_pCAL, 4)) png_handle_pCAL(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sCAL_SUPPORTED) +#ifdef PNG_READ_sCAL_SUPPORTED else if (!png_memcmp(chunk_name, png_sCAL, 4)) png_handle_sCAL(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_pHYs_SUPPORTED) +#ifdef PNG_READ_pHYs_SUPPORTED else if (!png_memcmp(chunk_name, png_pHYs, 4)) png_handle_pHYs(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sBIT_SUPPORTED) +#ifdef PNG_READ_sBIT_SUPPORTED else if (!png_memcmp(chunk_name, png_sBIT, 4)) png_handle_sBIT(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sRGB_SUPPORTED) +#ifdef PNG_READ_sRGB_SUPPORTED else if (!png_memcmp(chunk_name, png_sRGB, 4)) png_handle_sRGB(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_iCCP_SUPPORTED) +#ifdef PNG_READ_iCCP_SUPPORTED else if (!png_memcmp(chunk_name, png_iCCP, 4)) png_handle_iCCP(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_sPLT_SUPPORTED) +#ifdef PNG_READ_sPLT_SUPPORTED else if (!png_memcmp(chunk_name, png_sPLT, 4)) png_handle_sPLT(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tEXt_SUPPORTED) +#ifdef PNG_READ_tEXt_SUPPORTED else if (!png_memcmp(chunk_name, png_tEXt, 4)) png_handle_tEXt(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tIME_SUPPORTED) +#ifdef PNG_READ_tIME_SUPPORTED else if (!png_memcmp(chunk_name, png_tIME, 4)) png_handle_tIME(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_tRNS_SUPPORTED) +#ifdef PNG_READ_tRNS_SUPPORTED else if (!png_memcmp(chunk_name, png_tRNS, 4)) png_handle_tRNS(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_zTXt_SUPPORTED) +#ifdef PNG_READ_zTXt_SUPPORTED else if (!png_memcmp(chunk_name, png_zTXt, 4)) png_handle_zTXt(png_ptr, info_ptr, length); #endif -#if defined(PNG_READ_iTXt_SUPPORTED) +#ifdef PNG_READ_iTXt_SUPPORTED else if (!png_memcmp(chunk_name, png_iTXt, 4)) png_handle_iTXt(png_ptr, info_ptr, length); #endif else png_handle_unknown(png_ptr, info_ptr, length); } while (!(png_ptr->mode & PNG_HAVE_IEND)); } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ /* Free all memory used by the read */ void PNGAPI png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, @@ -1119,9 +1131,9 @@ png_read_destroy(png_ptr, info_ptr, end_info_ptr); if (info_ptr != NULL) { -#if defined(PNG_TEXT_SUPPORTED) +#ifdef PNG_TEXT_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); #endif #ifdef PNG_USER_MEM_SUPPORTED @@ -1134,9 +1146,9 @@ } if (end_info_ptr != NULL) { -#if defined(PNG_READ_TEXT_SUPPORTED) +#ifdef PNG_READ_TEXT_SUPPORTED png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); #endif #ifdef PNG_USER_MEM_SUPPORTED png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, @@ -1183,16 +1196,16 @@ png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->big_row_buf); png_free(png_ptr, png_ptr->prev_row); png_free(png_ptr, png_ptr->chunkdata); -#if defined(PNG_READ_DITHER_SUPPORTED) +#ifdef PNG_READ_DITHER_SUPPORTED png_free(png_ptr, png_ptr->palette_lookup); png_free(png_ptr, png_ptr->dither_index); #endif -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED png_free(png_ptr, png_ptr->gamma_table); #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED png_free(png_ptr, png_ptr->gamma_from_1); png_free(png_ptr, png_ptr->gamma_to_1); #endif #ifdef PNG_FREE_ME_SUPPORTED @@ -1215,9 +1228,9 @@ png_free(png_ptr, png_ptr->trans); png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; #endif #endif -#if defined(PNG_READ_hIST_SUPPORTED) +#ifdef PNG_READ_hIST_SUPPORTED #ifdef PNG_FREE_ME_SUPPORTED if (png_ptr->free_me & PNG_FREE_HIST) png_free(png_ptr, png_ptr->hist); png_ptr->free_me &= ~PNG_FREE_HIST; @@ -1226,9 +1239,9 @@ png_free(png_ptr, png_ptr->hist); png_ptr->flags &= ~PNG_FLAG_FREE_HIST; #endif #endif -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (png_ptr->gamma_16_table != NULL) { int i; int istop = (1 << (8 - png_ptr->gamma_shift)); @@ -1237,9 +1250,9 @@ png_free(png_ptr, png_ptr->gamma_16_table[i]); } png_free(png_ptr, png_ptr->gamma_16_table); } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED if (png_ptr->gamma_16_from_1 != NULL) { int i; int istop = (1 << (8 - png_ptr->gamma_shift)); @@ -1260,9 +1273,9 @@ png_free(png_ptr, png_ptr->gamma_16_to_1); } #endif #endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) +#ifdef PNG_TIME_RFC1123_SUPPORTED png_free(png_ptr, png_ptr->time_buffer); #endif inflateEnd(&png_ptr->zstream); @@ -1313,10 +1326,10 @@ png_ptr->read_row_fn = read_row_fn; } -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -#if defined(PNG_INFO_IMAGE_SUPPORTED) +#ifndef PNG_NO_SEQUENTIAL_READ +#ifdef PNG_INFO_IMAGE_SUPPORTED void PNGAPI png_read_png(png_structp png_ptr, png_infop info_ptr, int transforms, voidp params) @@ -1324,9 +1337,9 @@ int row; if (png_ptr == NULL) return; -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED /* Invert the alpha channel from opacity to transparency */ if (transforms & PNG_TRANSFORM_INVERT_ALPHA) png_set_invert_alpha(png_ptr); @@ -1340,16 +1353,16 @@ png_error(png_ptr, "Image is too high to process with png_read_png()"); /* -------------- image transformations start here ------------------- */ -#if defined(PNG_READ_16_TO_8_SUPPORTED) +#ifdef PNG_READ_16_TO_8_SUPPORTED /* Tell libpng to strip 16 bit/color files down to 8 bits per color. */ if (transforms & PNG_TRANSFORM_STRIP_16) png_set_strip_16(png_ptr); #endif -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED /* Strip alpha bytes from the input data without combining with * the background (not recommended). */ if (transforms & PNG_TRANSFORM_STRIP_ALPHA) @@ -1363,17 +1376,17 @@ if (transforms & PNG_TRANSFORM_PACKING) png_set_packing(png_ptr); #endif -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED /* Change the order of packed pixels to least significant bit first * (not useful if you are using png_set_packing). */ if (transforms & PNG_TRANSFORM_PACKSWAP) png_set_packswap(png_ptr); #endif -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED /* Expand paletted colors into true RGB triplets * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel * Expand paletted or RGB images with transparency to full alpha * channels so the data will be available as RGBA quartets. @@ -1387,16 +1400,16 @@ /* We don't handle background color or gamma transformation or dithering. */ -#if defined(PNG_READ_INVERT_SUPPORTED) +#ifdef PNG_READ_INVERT_SUPPORTED /* Invert monochrome files to have 0 as white and 1 as black */ if (transforms & PNG_TRANSFORM_INVERT_MONO) png_set_invert_mono(png_ptr); #endif -#if defined(PNG_READ_SHIFT_SUPPORTED) +#ifdef PNG_READ_SHIFT_SUPPORTED /* If you want to shift the pixel values from the range [0,255] or * [0,65535] to the original [0,7] or [0,31], or whatever range the * colors were originally in: */ @@ -1409,23 +1422,23 @@ png_set_shift(png_ptr, sig_bit); } #endif -#if defined(PNG_READ_BGR_SUPPORTED) +#ifdef PNG_READ_BGR_SUPPORTED /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ if (transforms & PNG_TRANSFORM_BGR) png_set_bgr(png_ptr); #endif -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ if (transforms & PNG_TRANSFORM_SWAP_ALPHA) png_set_swap_alpha(png_ptr); #endif -#if defined(PNG_READ_SWAP_SUPPORTED) +#ifdef PNG_READ_SWAP_SUPPORTED /* Swap bytes of 16 bit files to least significant byte first */ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) png_set_swap(png_ptr); @@ -1468,6 +1483,6 @@ params = params; } #endif /* PNG_INFO_IMAGE_SUPPORTED */ -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ #endif /* PNG_READ_SUPPORTED */ diff -ru4NwbB libpng-1.2.40/pngrio.c libpng-1.2.41beta05/pngrio.c --- libpng-1.2.40/pngrio.c 2009-09-10 06:38:50.190978815 -0500 +++ libpng-1.2.41beta05/pngrio.c 2009-10-17 18:49:29.238093961 -0500 @@ -1,8 +1,8 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.2.37 [June 4, 2009] + * Last changed in libpng 1.2.41 [October 17, 2009] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -19,9 +19,9 @@ */ #define PNG_INTERNAL #include "png.h" -#if defined(PNG_READ_SUPPORTED) +#ifdef PNG_READ_SUPPORTED /* 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 @@ -37,9 +38,9 @@ else png_error(png_ptr, "Call to NULL read function"); } -#if !defined(PNG_NO_STDIO) +#ifndef PNG_NO_STDIO /* 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 * read_data function and use it at run time with png_set_read_fn(), rather * than changing the library. @@ -54,9 +55,9 @@ return; /* fread() returns 0 on error, so it is OK to store this in a png_size_t * instead of an int, which is what fread() actually returns. */ -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) check = 0; #else check = (png_size_t)fread(data, (png_size_t)1, length, @@ -88,9 +89,9 @@ n_data = (png_byte *)CVT_PTR_NOCHECK(data); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); if ((png_bytep)n_data == data) { -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) check = 0; #else check = fread(n_data, 1, length, io_ptr); @@ -104,9 +105,9 @@ remaining = length; do { read = MIN(NEAR_BUF_SIZE, remaining); -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) err = 0; #else err = fread(buf, (png_size_t)1, read, io_ptr); @@ -150,9 +151,9 @@ if (png_ptr == NULL) return; png_ptr->io_ptr = io_ptr; -#if !defined(PNG_NO_STDIO) +#ifndef PNG_NO_STDIO if (read_data_fn != NULL) png_ptr->read_data_fn = read_data_fn; else png_ptr->read_data_fn = png_default_read_data; @@ -169,9 +170,9 @@ png_warning(png_ptr, "same structure. Resetting write_data_fn to NULL."); } -#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#ifdef PNG_WRITE_FLUSH_SUPPORTED png_ptr->output_flush_fn = NULL; #endif } #endif /* PNG_READ_SUPPORTED */ diff -ru4NwbB libpng-1.2.40/pngrtran.c libpng-1.2.41beta05/pngrtran.c --- libpng-1.2.40/pngrtran.c 2009-09-10 06:38:50.205628517 -0500 +++ libpng-1.2.41beta05/pngrtran.c 2009-10-17 18:49:29.252899805 -0500 @@ -1,8 +1,8 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.2.38 [July 16, 2009] + * Last changed in libpng 1.2.41 [%DATE] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -17,18 +17,20 @@ */ #define PNG_INTERNAL #include "png.h" -#if defined(PNG_READ_SUPPORTED) +#ifdef PNG_READ_SUPPORTED /* 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) { png_debug(1, "in png_set_crc_action"); - /* Tell libpng how we react to CRC errors in critical chunks */ + if (png_ptr == NULL) return; + + /* Tell libpng how we react to CRC errors in critical chunks */ switch (crit_action) { case PNG_CRC_NO_CHANGE: /* Leave setting as is */ break; @@ -54,8 +56,9 @@ png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; break; } + /* Tell libpng how we react to CRC errors in ancillary chunks */ switch (ancil_action) { case PNG_CRC_NO_CHANGE: /* Leave setting as is */ break; @@ -110,9 +114,9 @@ png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); } #endif -#if defined(PNG_READ_16_TO_8_SUPPORTED) +#ifdef PNG_READ_16_TO_8_SUPPORTED /* Strip 16 bit depth files to 8 bit depth */ void PNGAPI png_set_strip_16(png_structp png_ptr) { @@ -122,9 +127,9 @@ png_ptr->transformations |= PNG_16_TO_8; } #endif -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED void PNGAPI png_set_strip_alpha(png_structp png_ptr) { png_debug(1, "in png_set_strip_alpha"); @@ -133,9 +139,9 @@ png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; } #endif -#if defined(PNG_READ_DITHER_SUPPORTED) +#ifdef PNG_READ_DITHER_SUPPORTED /* Dither file to 8 bit. Supply a palette, the current number * of elements in the palette, the maximum number of elements * allowed, and a histogram if possible. If the current number * of colors is greater then the maximum number, the palette will be @@ -554,9 +562,9 @@ png_ptr->screen_gamma = (float)scrn_gamma; } #endif -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED /* Expand paletted images to RGB, expand grayscale images of * less than 8-bit depth to 8-bit depth, and expand tRNS chunks * to alpha channels. */ @@ -597,9 +609,9 @@ png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } -#if !defined(PNG_1_0_X) +#ifndef PNG_1_0_X /* Expand grayscale images of less than 8-bit depth to 8 bits. */ void PNGAPI png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) { @@ -634,9 +651,9 @@ png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } #endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED void PNGAPI png_set_gray_to_rgb(png_structp png_ptr) { png_debug(1, "in png_set_gray_to_rgb"); @@ -644,10 +662,10 @@ png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +#ifdef PNG_FLOATING_POINT_SUPPORTED /* Convert a RGB image to a grayscale of the same width. This allows us, * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. */ @@ -680,9 +700,9 @@ case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; } if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED png_ptr->transformations |= PNG_EXPAND; #else { png_warning(png_ptr, @@ -723,11 +743,13 @@ 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"); + if (png_ptr == NULL) return; -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED png_ptr->transformations |= PNG_USER_TRANSFORM; png_ptr->read_user_transform_fn = read_user_transform_fn; #endif #ifdef PNG_LEGACY_SUPPORTED @@ -744,9 +766,10 @@ void /* PRIVATE */ png_init_read_transformations(png_structp png_ptr) { png_debug(1, "in png_init_read_transformations"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) + +#ifdef PNG_USELESS_TESTS_SUPPORTED if (png_ptr != NULL) #endif { #if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ @@ -755,9 +778,9 @@ #endif #if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED /* Detect gray background and attempt to enable optimization * for gray --> RGB case * * Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or @@ -842,12 +865,12 @@ png_ptr->palette[png_ptr->background.index].green; png_ptr->background.blue = png_ptr->palette[png_ptr->background.index].blue; -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_INVERT_ALPHA) { -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) #endif { /* Invert the alpha channel (in tRNS) unless the pixels are @@ -888,9 +911,9 @@ if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) && png_ptr->gamma != 0.0) { png_build_gamma_table(png_ptr); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED if (png_ptr->transformations & PNG_BACKGROUND) { if (color_type == PNG_COLOR_TYPE_PALETTE) { @@ -1078,13 +1101,13 @@ /* Done the gamma correction. */ png_ptr->transformations &= ~PNG_GAMMA; } } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED else #endif #endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED /* No GAMMA transformation */ if ((png_ptr->transformations & PNG_BACKGROUND) && (color_type == PNG_COLOR_TYPE_PALETTE)) { @@ -1120,9 +1143,9 @@ png_ptr->transformations |= PNG_STRIP_ALPHA; } #endif /* PNG_READ_BACKGROUND_SUPPORTED */ -#if defined(PNG_READ_SHIFT_SUPPORTED) +#ifdef PNG_READ_SHIFT_SUPPORTED if ((png_ptr->transformations & PNG_SHIFT) && (color_type == PNG_COLOR_TYPE_PALETTE)) { png_uint_16 i; @@ -1160,9 +1183,10 @@ void /* PRIVATE */ png_read_transform_info(png_structp png_ptr, png_infop info_ptr) { png_debug(1, "in png_read_transform_info"); -#if defined(PNG_READ_EXPAND_SUPPORTED) + +#ifdef PNG_READ_EXPAND_SUPPORTED if (png_ptr->transformations & PNG_EXPAND) { if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { @@ -1187,18 +1211,18 @@ } } #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED if (png_ptr->transformations & PNG_BACKGROUND) { info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; info_ptr->num_trans = 0; info_ptr->background = png_ptr->background; } #endif -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (png_ptr->transformations & PNG_GAMMA) { #ifdef PNG_FLOATING_POINT_SUPPORTED info_ptr->gamma = png_ptr->gamma; @@ -1208,24 +1232,24 @@ #endif } #endif -#if defined(PNG_READ_16_TO_8_SUPPORTED) +#ifdef PNG_READ_16_TO_8_SUPPORTED if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) info_ptr->bit_depth = 8; #endif -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED if (png_ptr->transformations & PNG_GRAY_TO_RGB) info_ptr->color_type |= PNG_COLOR_MASK_COLOR; #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED if (png_ptr->transformations & PNG_RGB_TO_GRAY) info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR; #endif -#if defined(PNG_READ_DITHER_SUPPORTED) +#ifdef PNG_READ_DITHER_SUPPORTED if (png_ptr->transformations & PNG_DITHER) { if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && @@ -1235,9 +1259,9 @@ } } #endif -#if defined(PNG_READ_PACK_SUPPORTED) +#ifdef PNG_READ_PACK_SUPPORTED if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) info_ptr->bit_depth = 8; #endif @@ -1247,25 +1271,25 @@ info_ptr->channels = 3; else info_ptr->channels = 1; -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; #endif if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) info_ptr->channels++; -#if defined(PNG_READ_FILLER_SUPPORTED) +#ifdef PNG_READ_FILLER_SUPPORTED /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ if ((png_ptr->transformations & PNG_FILLER) && ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) { info_ptr->channels++; /* If adding a true alpha channel not just filler */ -#if !defined(PNG_1_0_X) +#ifndef PNG_1_0_X if (png_ptr->transformations & PNG_ADD_ALPHA) info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; #endif } @@ -1286,9 +1310,9 @@ info_ptr->bit_depth); info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width); -#if !defined(PNG_READ_EXPAND_SUPPORTED) +#ifndef PNG_READ_EXPAND_SUPPORTED if (png_ptr) return; #endif } @@ -1300,11 +1324,12 @@ void /* PRIVATE */ png_do_read_transformations(png_structp png_ptr) { png_debug(1, "in png_do_read_transformations"); + if (png_ptr->row_buf == NULL) { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) +#if defined(PNG_STDIO_SUPPORTED) && !defined(_WIN32_WCE) char msg[50]; png_snprintf2(msg, 50, "NULL row buffer for row %ld, pass %d", (long)png_ptr->row_number, @@ -1326,9 +1351,9 @@ png_warning(png_ptr, "Uninitialized row"); #endif #endif -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED if (png_ptr->transformations & PNG_EXPAND) { if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) { @@ -1347,15 +1372,15 @@ } } #endif -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)); #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED if (png_ptr->transformations & PNG_RGB_TO_GRAY) { int rgb_error = png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); @@ -1402,24 +1427,24 @@ * in advance if the background was gray or RGB, and position the gray-to-RGB * transform appropriately, then it would save a lot of work/time. */ -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED /* If gray -> RGB, do so now only if background is non-gray; else do later * for performance reasons */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED if ((png_ptr->transformations & PNG_BACKGROUND) && ((png_ptr->num_trans != 0 ) || (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, &(png_ptr->trans_values), &(png_ptr->background) -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED , &(png_ptr->background_1), png_ptr->gamma_table, png_ptr->gamma_from_1, png_ptr->gamma_to_1, png_ptr->gamma_16_table, png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, @@ -1427,11 +1452,11 @@ #endif ); #endif -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if ((png_ptr->transformations & PNG_GAMMA) && -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED !((png_ptr->transformations & PNG_BACKGROUND) && ((png_ptr->num_trans != 0) || (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && #endif @@ -1440,14 +1465,14 @@ png_ptr->gamma_table, png_ptr->gamma_16_table, png_ptr->gamma_shift); #endif -#if defined(PNG_READ_16_TO_8_SUPPORTED) +#ifdef PNG_READ_16_TO_8_SUPPORTED if (png_ptr->transformations & PNG_16_TO_8) png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_DITHER_SUPPORTED) +#ifdef PNG_READ_DITHER_SUPPORTED if (png_ptr->transformations & PNG_DITHER) { png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->palette_lookup, png_ptr->dither_index); @@ -1455,63 +1480,63 @@ png_error(png_ptr, "png_do_dither returned rowbytes=0"); } #endif -#if defined(PNG_READ_INVERT_SUPPORTED) +#ifdef PNG_READ_INVERT_SUPPORTED if (png_ptr->transformations & PNG_INVERT_MONO) png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_SHIFT_SUPPORTED) +#ifdef PNG_READ_SHIFT_SUPPORTED if (png_ptr->transformations & PNG_SHIFT) png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, &(png_ptr->shift)); #endif -#if defined(PNG_READ_PACK_SUPPORTED) +#ifdef PNG_READ_PACK_SUPPORTED if (png_ptr->transformations & PNG_PACK) png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_BGR_SUPPORTED) +#ifdef PNG_READ_BGR_SUPPORTED if (png_ptr->transformations & PNG_BGR) png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED if (png_ptr->transformations & PNG_PACKSWAP) png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED /* If gray -> RGB, do so now only if we did not do so above */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_FILLER_SUPPORTED) +#ifdef PNG_READ_FILLER_SUPPORTED if (png_ptr->transformations & PNG_FILLER) png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, (png_uint_32)png_ptr->filler, png_ptr->flags); #endif -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_INVERT_ALPHA) png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_SWAP_ALPHA) png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_READ_SWAP_SUPPORTED) +#ifdef PNG_READ_SWAP_SUPPORTED 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) +#ifdef 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 */ @@ -1523,9 +1548,9 @@ /* 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 */ -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED if (png_ptr->user_transform_depth) png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; if (png_ptr->user_transform_channels) png_ptr->row_info.channels = png_ptr->user_transform_channels; @@ -1538,9 +1563,9 @@ #endif } -#if defined(PNG_READ_PACK_SUPPORTED) +#ifdef PNG_READ_PACK_SUPPORTED /* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, * without changing the actual values. Thus, if you had a row with * a bit depth of 1, you would end up with bytes that only contained * the numbers 0 or 1. If you would rather they contain 0 and 255, use @@ -1549,9 +1574,10 @@ void /* PRIVATE */ png_do_unpack(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_unpack"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) + +#ifdef PNG_USELESS_TESTS_SUPPORTED if (row != NULL && row_info != NULL && row_info->bit_depth < 8) #else if (row_info->bit_depth < 8) #endif @@ -1631,9 +1657,9 @@ } } #endif -#if defined(PNG_READ_SHIFT_SUPPORTED) +#ifdef PNG_READ_SHIFT_SUPPORTED /* Reverse the effects of png_do_shift. This routine merely shifts the * pixels back to their significant bits values. Thus, if you have * a row of bit depth 8, but only 5 are significant, this will shift * the values back to 0 through 31. @@ -1641,10 +1667,11 @@ void /* PRIVATE */ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) { png_debug(1, "in png_do_unshift"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && sig_bits != NULL && #endif row_info->color_type != PNG_COLOR_TYPE_PALETTE) { @@ -1744,15 +1771,16 @@ } } #endif -#if defined(PNG_READ_16_TO_8_SUPPORTED) +#ifdef PNG_READ_16_TO_8_SUPPORTED /* Chop rows of bit depth 16 down to 8 */ void /* PRIVATE */ png_do_chop(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_chop"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) + +#ifdef PNG_USELESS_TESTS_SUPPORTED if (row != NULL && row_info != NULL && row_info->bit_depth == 16) #else if (row_info->bit_depth == 16) #endif @@ -1763,9 +1791,9 @@ png_uint_32 istop = row_info->width * row_info->channels; for (i = 0; iwidth; @@ -1894,14 +1923,15 @@ } } #endif -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED void /* PRIVATE */ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_read_invert_alpha"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) + +#ifdef PNG_USELESS_TESTS_SUPPORTED if (row != NULL && row_info != NULL) #endif { png_uint_32 row_width = row_info->width; @@ -1992,9 +2022,9 @@ } } #endif -#if defined(PNG_READ_FILLER_SUPPORTED) +#ifdef PNG_READ_FILLER_SUPPORTED /* Add filler channel if we have RGB color */ void /* PRIVATE */ png_do_read_filler(png_row_infop row_info, png_bytep row, png_uint_32 filler, png_uint_32 flags) @@ -2005,10 +2035,11 @@ png_byte hi_filler = (png_byte)((filler>>8) & 0xff); png_byte lo_filler = (png_byte)(filler & 0xff); png_debug(1, "in png_do_read_filler"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif row_info->color_type == PNG_COLOR_TYPE_GRAY) { @@ -2168,9 +2199,9 @@ } /* COLOR_TYPE == RGB */ } #endif -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED /* Expand grayscale files to RGB, with or without alpha */ void /* PRIVATE */ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) { @@ -2177,10 +2208,11 @@ png_uint_32 i; png_uint_32 row_width = row_info->width; png_debug(1, "in png_do_gray_to_rgb"); + if (row_info->bit_depth >= 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif !(row_info->color_type & PNG_COLOR_MASK_COLOR)) { @@ -2251,9 +2283,9 @@ } } #endif -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED /* Reduce RGB files to grayscale, with or without alpha * using the equation given in Poynton's ColorFAQ at * (THIS LINK IS DEAD June 2008) * New link: @@ -2283,10 +2315,11 @@ png_uint_32 row_width = row_info->width; int rgb_error = 0; png_debug(1, "in png_do_rgb_to_gray"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { @@ -2677,9 +2712,9 @@ } } else #endif -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (png_ptr->transformations & PNG_GAMMA) { int i; @@ -2689,13 +2724,13 @@ palette[i].green = png_ptr->gamma_table[palette[i].green]; palette[i].blue = png_ptr->gamma_table[palette[i].blue]; } } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED else #endif #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED if (png_ptr->transformations & PNG_BACKGROUND) { if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { @@ -2742,17 +2777,17 @@ #endif } #endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED /* Replace any alpha or transparency with the supplied background color. * "background" is already in the screen gamma, while "background_1" is * at a gamma of 1.0. Paletted files have already been taken care of. */ void /* PRIVATE */ png_do_background(png_row_infop row_info, png_bytep row, png_color_16p trans_values, png_color_16p background -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED , png_color_16p background_1, png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16_to_1, int gamma_shift @@ -2764,10 +2799,11 @@ png_uint_32 row_width=row_info->width; int shift; png_debug(1, "in png_do_background"); + if (background != NULL && -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) @@ -2802,9 +2838,9 @@ } case 2: { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_table != NULL) { sp = row; shift = 6; @@ -2859,9 +2895,9 @@ } case 4: { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_table != NULL) { sp = row; shift = 4; @@ -2916,9 +2952,9 @@ } case 8: { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_table != NULL) { sp = row; for (i = 0; i < row_width; i++, sp++) @@ -2949,9 +2985,9 @@ } case 16: { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_16 != NULL) { sp = row; for (i = 0; i < row_width; i++, sp += 2) @@ -2998,9 +3034,9 @@ case PNG_COLOR_TYPE_RGB: { if (row_info->bit_depth == 8) { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_table != NULL) { sp = row; for (i = 0; i < row_width; i++, sp += 3) @@ -3039,9 +3075,9 @@ } } else /* if (row_info->bit_depth == 16) */ { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_16 != NULL) { sp = row; for (i = 0; i < row_width; i++, sp += 6) @@ -3103,9 +3139,9 @@ case PNG_COLOR_TYPE_GRAY_ALPHA: { if (row_info->bit_depth == 8) { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_to_1 != NULL && gamma_from_1 != NULL && gamma_table != NULL) { sp = row; @@ -3145,9 +3181,9 @@ if (a == 0xff) { *dp = *sp; } -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED else if (a == 0) { *dp = (png_byte)background->gray; } @@ -3162,9 +3198,9 @@ } } else /* if (png_ptr->bit_depth == 16) */ { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_16 != NULL && gamma_16_from_1 != NULL && gamma_16_to_1 != NULL) { sp = row; @@ -3180,9 +3216,9 @@ v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; *dp = (png_byte)((v >> 8) & 0xff); *(dp + 1) = (png_byte)(v & 0xff); } -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED else if (a == 0) #else else #endif @@ -3190,9 +3226,9 @@ /* Background is already in screen gamma */ *dp = (png_byte)((background->gray >> 8) & 0xff); *(dp + 1) = (png_byte)(background->gray & 0xff); } -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED else { png_uint_16 g, v, w; @@ -3216,18 +3252,18 @@ if (a == (png_uint_16)0xffff) { png_memcpy(dp, sp, 2); } -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED else if (a == 0) #else else #endif { *dp = (png_byte)((background->gray >> 8) & 0xff); *(dp + 1) = (png_byte)(background->gray & 0xff); } -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED else { png_uint_16 g, v; @@ -3246,9 +3282,9 @@ case PNG_COLOR_TYPE_RGB_ALPHA: { if (row_info->bit_depth == 8) { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_to_1 != NULL && gamma_from_1 != NULL && gamma_table != NULL) { sp = row; @@ -3319,9 +3355,9 @@ } } else /* if (row_info->bit_depth == 16) */ { -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if (gamma_16 != NULL && gamma_16_from_1 != NULL && gamma_16_to_1 != NULL) { sp = row; @@ -3436,9 +3472,9 @@ } } #endif -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED /* Gamma correct the image, avoiding the alpha channel. Make sure * you do this after you deal with the transparency issue on grayscale * or RGB images. If your bit depth is 8, use gamma_table, if it * is 16, use gamma_16_table and gamma_shift. Build these with @@ -3453,10 +3489,11 @@ png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_gamma"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif ((row_info->bit_depth <= 8 && gamma_table != NULL) || (row_info->bit_depth == 16 && gamma_16_table != NULL))) @@ -3627,9 +3664,9 @@ } } #endif -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED /* Expands a palette row to an RGB or RGBA row depending * upon whether you supply trans and num_trans. */ void /* PRIVATE */ @@ -3641,10 +3678,11 @@ png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_expand_palette"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif row_info->color_type == PNG_COLOR_TYPE_PALETTE) { @@ -3787,9 +3825,10 @@ png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_expand"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) + +#ifdef PNG_USELESS_TESTS_SUPPORTED if (row != NULL && row_info != NULL) #endif { if (row_info->color_type == PNG_COLOR_TYPE_GRAY) @@ -3988,9 +4027,9 @@ } } #endif -#if defined(PNG_READ_DITHER_SUPPORTED) +#ifdef PNG_READ_DITHER_SUPPORTED void /* PRIVATE */ png_do_dither(png_row_infop row_info, png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup) { @@ -3998,9 +4037,10 @@ png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_dither"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) + +#ifdef PNG_USELESS_TESTS_SUPPORTED if (row != NULL && row_info != NULL) #endif { if (row_info->color_type == PNG_COLOR_TYPE_RGB && @@ -4080,9 +4120,9 @@ } #endif #ifdef PNG_FLOATING_POINT_SUPPORTED -#if defined(PNG_READ_GAMMA_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED static PNG_CONST int png_gamma_shift[] = {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00}; /* We build the 8- or 16-bit gamma tables here. Note that for 16-bit @@ -4313,9 +4354,9 @@ #endif /* To do: install integer version of png_build_gamma_table here */ #endif -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED /* Undoes intrapixel differencing */ void /* PRIVATE */ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) { @@ -4319,10 +4360,11 @@ void /* PRIVATE */ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_read_intrapixel"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { diff -ru4NwbB libpng-1.2.40/pngrutil.c libpng-1.2.41beta05/pngrutil.c --- libpng-1.2.40/pngrutil.c 2009-09-10 06:38:50.218208431 -0500 +++ libpng-1.2.41beta05/pngrutil.c 2009-10-17 18:49:29.265726565 -0500 @@ -1,8 +1,8 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.2.38 [July 16, 2009] + * Last changed in libpng 1.2.41 [October 17, 2009] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -15,16 +15,16 @@ */ #define PNG_INTERNAL #include "png.h" -#if defined(PNG_READ_SUPPORTED) +#ifdef PNG_READ_SUPPORTED #if defined(_WIN32_WCE) && (_WIN32_WCE<0x500) # define WIN32_WCE_OLD #endif #ifdef PNG_FLOATING_POINT_SUPPORTED -# if defined(WIN32_WCE_OLD) +# ifdef WIN32_WCE_OLD /* The strtod() function is not supported on WindowsCE */ __inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **endptr) { double result = 0; @@ -227,9 +227,9 @@ png_decompress_chunk(png_structp png_ptr, int comp_type, png_size_t chunklength, png_size_t prefix_size, png_size_t *newlength) { - static PNG_CONST char msg[] = "Error decoding compressed text"; + static PNG_CONST char msg[] = "Error decoding compressed chunk"; png_charp text; png_size_t text_size; if (comp_type == PNG_COMPRESSION_TYPE_BASE) @@ -429,9 +429,9 @@ png_ptr->height = height; png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->interlaced = (png_byte)interlace_type; png_ptr->color_type = (png_byte)color_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED png_ptr->filter_type = (png_byte)filter_type; #endif png_ptr->compression_type = (png_byte)compression_type; @@ -500,9 +500,9 @@ "Ignoring PLTE chunk in grayscale PNG"); png_crc_finish(png_ptr, length); return; } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) +#ifndef PNG_READ_OPT_PLTE_SUPPORTED if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) { png_crc_finish(png_ptr, length); return; @@ -553,15 +553,15 @@ * whatever the normal CRC configuration tells us. However, if we * have an RGB image, the PLTE can be considered ancillary, so * we will act as though it is. */ -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) +#ifndef PNG_READ_OPT_PLTE_SUPPORTED if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) #endif { png_crc_finish(png_ptr, 0); } -#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) +#ifndef PNG_READ_OPT_PLTE_SUPPORTED else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ { /* If we don't want to use the data from an ancillary chunk, we have two options: an error abort, or a warning and we @@ -588,9 +588,9 @@ #endif png_set_PLTE(png_ptr, info_ptr, palette, num); -#if defined(PNG_READ_tRNS_SUPPORTED) +#ifdef PNG_READ_tRNS_SUPPORTED if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { @@ -630,9 +630,9 @@ info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */ } -#if defined(PNG_READ_gAMA_SUPPORTED) +#ifdef PNG_READ_gAMA_SUPPORTED void /* PRIVATE */ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_fixed_point igamma; @@ -655,9 +655,9 @@ /* Should be an error, but we can cope with it */ png_warning(png_ptr, "Out of place gAMA chunk"); if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) -#if defined(PNG_READ_sRGB_SUPPORTED) +#ifdef PNG_READ_sRGB_SUPPORTED && !(info_ptr->valid & PNG_INFO_sRGB) #endif ) { @@ -685,9 +685,9 @@ "Ignoring gAMA chunk with gamma=0"); return; } -#if defined(PNG_READ_sRGB_SUPPORTED) +#ifdef PNG_READ_sRGB_SUPPORTED if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) { png_warning(png_ptr, @@ -711,9 +711,9 @@ #endif } #endif -#if defined(PNG_READ_sBIT_SUPPORTED) +#ifdef PNG_READ_sBIT_SUPPORTED void /* PRIVATE */ png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_size_t truelen; @@ -777,9 +777,9 @@ png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); } #endif -#if defined(PNG_READ_cHRM_SUPPORTED) +#ifdef PNG_READ_cHRM_SUPPORTED void /* PRIVATE */ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[32]; @@ -805,9 +805,9 @@ /* Should be an error, but we can cope with it */ png_warning(png_ptr, "Missing PLTE before cHRM"); if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM) -#if defined(PNG_READ_sRGB_SUPPORTED) +#ifdef PNG_READ_sRGB_SUPPORTED && !(info_ptr->valid & PNG_INFO_sRGB) #endif ) { @@ -857,9 +857,9 @@ blue_x = (float)int_x_blue / (float)100000.0; blue_y = (float)int_y_blue / (float)100000.0; #endif -#if defined(PNG_READ_sRGB_SUPPORTED) +#ifdef PNG_READ_sRGB_SUPPORTED if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB)) { if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) || PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) || @@ -883,9 +883,9 @@ int_x_white, int_y_white, int_x_red, int_y_red); fprintf(stderr, "gx=%ld, gy=%ld, bx=%ld, by=%ld\n", int_x_green, int_y_green, int_x_blue, int_y_blue); #endif -#endif /* PNG_NO_CONSOLE_IO */ +#endif /* PNG_CONSOLE_IO_SUPPORTED */ } return; } #endif /* PNG_READ_sRGB_SUPPORTED */ @@ -901,9 +901,9 @@ #endif } #endif -#if defined(PNG_READ_sRGB_SUPPORTED) +#ifdef PNG_READ_sRGB_SUPPORTED void /* PRIVATE */ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { int intent; @@ -999,9 +999,9 @@ png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); } #endif /* PNG_READ_sRGB_SUPPORTED */ -#if defined(PNG_READ_iCCP_SUPPORTED) +#ifdef PNG_READ_iCCP_SUPPORTED void /* PRIVATE */ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) /* Note: this does not properly handle chunks that are > 64K under DOS */ { @@ -1119,16 +1119,16 @@ png_ptr->chunkdata = NULL; } #endif /* PNG_READ_iCCP_SUPPORTED */ -#if defined(PNG_READ_sPLT_SUPPORTED) +#ifdef PNG_READ_sPLT_SUPPORTED void /* PRIVATE */ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) /* Note: this does not properly handle chunks that are > 64K under DOS */ { png_bytep entry_start; png_sPLT_t new_palette; -#ifdef PNG_NO_POINTER_INDEXING +#ifndef PNG_NO_POINTER_INDEXING png_sPLT_entryp pp; #endif int data_length, entry_size, i; png_uint_32 skip = 0; @@ -1212,9 +1212,9 @@ #ifndef PNG_NO_POINTER_INDEXING for (i = 0; i < new_palette.nentries; i++) { - png_sPLT_entryp pp = new_palette.entries + i; + pp = new_palette.entries + i; if (new_palette.depth == 8) { pp->red = *entry_start++; @@ -1264,9 +1264,9 @@ png_free(png_ptr, new_palette.entries); } #endif /* PNG_READ_sPLT_SUPPORTED */ -#if defined(PNG_READ_tRNS_SUPPORTED) +#ifdef PNG_READ_tRNS_SUPPORTED void /* PRIVATE */ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; @@ -1359,9 +1359,9 @@ &(png_ptr->trans_values)); } #endif -#if defined(PNG_READ_bKGD_SUPPORTED) +#ifdef PNG_READ_bKGD_SUPPORTED void /* PRIVATE */ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_size_t truelen; @@ -1448,9 +1448,9 @@ png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); } #endif -#if defined(PNG_READ_hIST_SUPPORTED) +#ifdef PNG_READ_hIST_SUPPORTED void /* PRIVATE */ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { unsigned int num, i; @@ -1502,9 +1502,9 @@ png_set_hIST(png_ptr, info_ptr, readbuf); } #endif -#if defined(PNG_READ_pHYs_SUPPORTED) +#ifdef PNG_READ_pHYs_SUPPORTED void /* PRIVATE */ png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[9]; @@ -1545,9 +1545,9 @@ png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); } #endif -#if defined(PNG_READ_oFFs_SUPPORTED) +#ifdef PNG_READ_oFFs_SUPPORTED void /* PRIVATE */ png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[9]; @@ -1588,9 +1588,9 @@ png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); } #endif -#if defined(PNG_READ_pCAL_SUPPORTED) +#ifdef PNG_READ_pCAL_SUPPORTED /* Read the pCAL chunk (described in the PNG Extensions document) */ void /* PRIVATE */ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { @@ -1722,9 +1722,9 @@ png_free(png_ptr, params); } #endif -#if defined(PNG_READ_sCAL_SUPPORTED) +#ifdef PNG_READ_sCAL_SUPPORTED /* Read the sCAL chunk */ void /* PRIVATE */ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { @@ -1865,9 +1865,9 @@ #endif } #endif -#if defined(PNG_READ_tIME_SUPPORTED) +#ifdef PNG_READ_tIME_SUPPORTED void /* PRIVATE */ png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[7]; @@ -1908,9 +1908,9 @@ png_set_tIME(png_ptr, info_ptr, &mod_time); } #endif -#if defined(PNG_READ_tEXt_SUPPORTED) +#ifdef PNG_READ_tEXt_SUPPORTED /* Note: this does not properly handle chunks that are > 64K under DOS */ void /* PRIVATE */ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { @@ -1995,9 +1995,9 @@ png_warning(png_ptr, "Insufficient memory to process text chunk."); } #endif -#if defined(PNG_READ_zTXt_SUPPORTED) +#ifdef PNG_READ_zTXt_SUPPORTED /* Note: this does not correctly handle chunks that are > 64K under DOS */ void /* PRIVATE */ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { @@ -2099,9 +2099,9 @@ png_error(png_ptr, "Insufficient memory to store zTXt chunk."); } #endif -#if defined(PNG_READ_iTXt_SUPPORTED) +#ifdef PNG_READ_iTXt_SUPPORTED /* Note: this does not correctly handle chunks that are > 64K under DOS */ void /* PRIVATE */ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { @@ -2253,22 +2253,22 @@ } if (!(png_ptr->chunk_name[0] & 0x20)) { -#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != PNG_HANDLE_CHUNK_ALWAYS -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED && png_ptr->read_user_chunk_fn == NULL #endif ) #endif png_chunk_error(png_ptr, "unknown critical chunk"); } -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED || (png_ptr->read_user_chunk_fn != NULL) #endif ) { @@ -2291,9 +2291,9 @@ { png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); } -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED if (png_ptr->read_user_chunk_fn != NULL) { /* Callback to user unknown chunk handler */ int ret; @@ -2303,9 +2303,9 @@ png_chunk_error(png_ptr, "error in user chunk"); if (ret == 0) { if (!(png_ptr->chunk_name[0] & 0x20)) -#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != PNG_HANDLE_CHUNK_ALWAYS) #endif png_chunk_error(png_ptr, "unknown critical chunk"); @@ -2324,9 +2324,9 @@ skip = length; png_crc_finish(png_ptr, skip); -#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) +#ifndef PNG_READ_USER_CHUNKS_SUPPORTED info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */ #endif } @@ -2382,9 +2382,9 @@ int shift; png_uint_32 i; png_uint_32 row_width = png_ptr->width; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED if (png_ptr->transformations & PNG_PACKSWAP) { s_start = 0; s_end = 7; @@ -2437,9 +2437,9 @@ png_uint_32 i; png_uint_32 row_width = png_ptr->width; int value; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED if (png_ptr->transformations & PNG_PACKSWAP) { s_start = 0; s_end = 6; @@ -2489,9 +2489,9 @@ png_uint_32 i; png_uint_32 row_width = png_ptr->width; int value; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED if (png_ptr->transformations & PNG_PACKSWAP) { s_start = 0; s_end = 4; @@ -2572,13 +2572,11 @@ png_row_infop row_info = &(png_ptr->row_info); png_bytep row = png_ptr->row_buf + 1; int pass = png_ptr->pass; png_uint_32 transformations = png_ptr->transformations; -#ifdef PNG_USE_LOCAL_ARRAYS /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Offset to next interlace block */ PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif png_debug(1, "in png_do_read_interlace"); if (row != NULL && row_info != NULL) { @@ -2598,9 +2596,9 @@ png_byte v; png_uint_32 i; int j; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED if (transformations & PNG_PACKSWAP) { sshift = (int)((row_info->width + 7) & 0x07); dshift = (int)((final_width + 7) & 0x07); @@ -2651,9 +2649,9 @@ int s_start, s_end, s_inc; int jstop = png_pass_inc[pass]; png_uint_32 i; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED if (transformations & PNG_PACKSWAP) { sshift = (int)(((row_info->width + 3) & 0x03) << 1); dshift = (int)(((final_width + 3) & 0x03) << 1); @@ -2707,9 +2705,9 @@ int s_start, s_end, s_inc; png_uint_32 i; int jstop = png_pass_inc[pass]; -#if defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifdef PNG_READ_PACKSWAP_SUPPORTED if (transformations & PNG_PACKSWAP) { sshift = (int)(((row_info->width + 1) & 0x01) << 2); dshift = (int)(((final_width + 1) & 0x01) << 2); @@ -2781,9 +2779,9 @@ } row_info->width = final_width; row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width); } -#if !defined(PNG_READ_PACKSWAP_SUPPORTED) +#ifndef PNG_READ_PACKSWAP_SUPPORTED transformations = transformations; /* Silence compiler warning */ #endif } #endif /* PNG_READ_INTERLACING_SUPPORTED */ @@ -2910,13 +2908,12 @@ break; } } -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +#ifndef PNG_NO_SEQUENTIAL_READ void /* PRIVATE */ png_read_finish_row(png_structp png_ptr) { -#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_READ_INTERLACING_SUPPORTED /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Start of interlace block */ @@ -2930,9 +2927,8 @@ /* Offset to next interlace block in the y direction */ PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif /* PNG_READ_INTERLACING_SUPPORTED */ -#endif png_debug(1, "in png_read_finish_row"); png_ptr->row_number++; if (png_ptr->row_number < png_ptr->num_rows) @@ -3042,14 +3038,13 @@ inflateReset(&png_ptr->zstream); png_ptr->mode |= PNG_AFTER_IDAT; } -#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ +#endif /* PNG_NO_SEQUENTIAL_READ */ void /* PRIVATE */ png_read_start_row(png_structp png_ptr) { -#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_READ_INTERLACING_SUPPORTED /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Start of interlace block */ @@ -3063,9 +3058,8 @@ /* Offset to next interlace block in the y direction */ PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif -#endif int max_pixel_depth; png_size_t row_bytes; @@ -3097,14 +3091,14 @@ png_ptr->irowbytes = png_ptr->rowbytes + 1; } max_pixel_depth = png_ptr->pixel_depth; -#if defined(PNG_READ_PACK_SUPPORTED) +#ifdef PNG_READ_PACK_SUPPORTED if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) max_pixel_depth = 8; #endif -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED if (png_ptr->transformations & PNG_EXPAND) { if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { @@ -3130,9 +3124,9 @@ } } #endif -#if defined(PNG_READ_FILLER_SUPPORTED) +#ifdef PNG_READ_FILLER_SUPPORTED if (png_ptr->transformations & (PNG_FILLER)) { if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) max_pixel_depth = 32; @@ -3152,16 +3146,16 @@ } } #endif -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED if (png_ptr->transformations & PNG_GRAY_TO_RGB) { if ( -#if defined(PNG_READ_EXPAND_SUPPORTED) +#ifdef PNG_READ_EXPAND_SUPPORTED (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || #endif -#if defined(PNG_READ_FILLER_SUPPORTED) +#ifdef PNG_READ_FILLER_SUPPORTED (png_ptr->transformations & (PNG_FILLER)) || #endif png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { diff -ru4NwbB libpng-1.2.40/pngset.c libpng-1.2.41beta05/pngset.c --- libpng-1.2.40/pngset.c 2009-09-10 06:38:50.226299947 -0500 +++ libpng-1.2.41beta05/pngset.c 2009-10-17 18:49:29.273894601 -0500 @@ -1,8 +1,8 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.2.40 [October 17, 2009] + * Last changed in libpng 1.2.41 [October 17, 2009] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -19,9 +19,9 @@ #define PNG_INTERNAL #include "png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#if defined(PNG_bKGD_SUPPORTED) +#ifdef PNG_bKGD_SUPPORTED void PNGAPI png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) { png_debug1(1, "in %s storage function", "bKGD"); @@ -33,9 +33,9 @@ info_ptr->valid |= PNG_INFO_bKGD; } #endif -#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_cHRM_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI png_set_cHRM(png_structp png_ptr, png_infop info_ptr, double white_x, double white_y, double red_x, double red_y, @@ -79,9 +79,9 @@ if (png_ptr == NULL || info_ptr == NULL) return; -#if !defined(PNG_NO_CHECK_cHRM) +#ifndef PNG_NO_CHECK_cHRM if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)) #endif { @@ -108,9 +108,9 @@ } #endif /* PNG_FIXED_POINT_SUPPORTED */ #endif /* PNG_cHRM_SUPPORTED */ -#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_gAMA_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) { @@ -175,9 +175,9 @@ png_warning(png_ptr, "Setting gamma=0"); } #endif -#if defined(PNG_hIST_SUPPORTED) +#ifdef PNG_hIST_SUPPORTED void PNGAPI png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) { int i; @@ -232,84 +232,20 @@ if (png_ptr == NULL || info_ptr == NULL) return; - /* Check for width and height valid values */ - if (width == 0 || height == 0) - png_error(png_ptr, "Image width or height is zero in IHDR"); -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (width > png_ptr->user_width_max || height > png_ptr->user_height_max) - png_error(png_ptr, "image size exceeds user limits in IHDR"); -#else - if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX) - png_error(png_ptr, "image size exceeds user limits in IHDR"); -#endif - if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX) - png_error(png_ptr, "Invalid image size in IHDR"); - if ( width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ - - 64 /* bigrowbuf hack */ - - 1 /* filter byte */ - - 7*8 /* rounding of width to multiple of 8 pixels */ - - 8) /* extra max_pixel_depth pad */ - png_warning(png_ptr, "Width is too large for libpng to process pixels"); - - /* Check other values */ - if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && - bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth in IHDR"); - - if (color_type < 0 || color_type == 1 || - color_type == 5 || color_type > 6) - png_error(png_ptr, "Invalid color type in IHDR"); - - if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || - ((color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) - png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); - - if (interlace_type >= PNG_INTERLACE_LAST) - png_error(png_ptr, "Unknown interlace method in IHDR"); - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_error(png_ptr, "Unknown compression method in IHDR"); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Accept filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not read a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) - png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); - if (filter_type != PNG_FILTER_TYPE_BASE) - { - if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - png_error(png_ptr, "Unknown filter method in IHDR"); - if (png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) - png_warning(png_ptr, "Invalid filter method in IHDR"); - } -#else - if (filter_type != PNG_FILTER_TYPE_BASE) - png_error(png_ptr, "Unknown filter method in IHDR"); -#endif - info_ptr->width = width; info_ptr->height = height; info_ptr->bit_depth = (png_byte)bit_depth; info_ptr->color_type =(png_byte) color_type; info_ptr->compression_type = (png_byte)compression_type; info_ptr->filter_type = (png_byte)filter_type; info_ptr->interlace_type = (png_byte)interlace_type; + + png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height, + info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, + info_ptr->compression_type, info_ptr->filter_type); + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) info_ptr->channels = 1; else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) info_ptr->channels = 3; @@ -330,9 +266,9 @@ else info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); } -#if defined(PNG_oFFs_SUPPORTED) +#ifdef PNG_oFFs_SUPPORTED void PNGAPI png_set_oFFs(png_structp png_ptr, png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type) { @@ -347,9 +283,9 @@ info_ptr->valid |= PNG_INFO_oFFs; } #endif -#if defined(PNG_pCAL_SUPPORTED) +#ifdef PNG_pCAL_SUPPORTED void PNGAPI png_set_pCAL(png_structp png_ptr, png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) @@ -486,9 +422,9 @@ #endif #endif #endif -#if defined(PNG_pHYs_SUPPORTED) +#ifdef PNG_pHYs_SUPPORTED void PNGAPI png_set_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type) { @@ -554,9 +490,9 @@ info_ptr->valid |= PNG_INFO_PLTE; } -#if defined(PNG_sBIT_SUPPORTED) +#ifdef PNG_sBIT_SUPPORTED void PNGAPI png_set_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p sig_bit) { @@ -569,9 +505,9 @@ info_ptr->valid |= PNG_INFO_sBIT; } #endif -#if defined(PNG_sRGB_SUPPORTED) +#ifdef PNG_sRGB_SUPPORTED void PNGAPI png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) { png_debug1(1, "in %s storage function", "sRGB"); @@ -586,17 +522,17 @@ void PNGAPI png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, int intent) { -#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_gAMA_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED float file_gamma; #endif #ifdef PNG_FIXED_POINT_SUPPORTED png_fixed_point int_file_gamma; #endif #endif -#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_cHRM_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; #endif png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, @@ -608,9 +544,9 @@ return; png_set_sRGB(png_ptr, info_ptr, intent); -#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_gAMA_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED file_gamma = (float).45455; png_set_gAMA(png_ptr, info_ptr, file_gamma); #endif @@ -619,9 +555,9 @@ png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); #endif #endif -#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_cHRM_SUPPORTED int_white_x = 31270L; int_white_y = 32900L; int_red_x = 64000L; int_red_y = 33000L; @@ -640,14 +576,8 @@ blue_x = (float).15; blue_y = (float).06; #endif -#if !defined(PNG_NO_CHECK_cHRM) - if (png_check_cHRM_fixed(png_ptr, - int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, - int_green_y, int_blue_x, int_blue_y)) -#endif - { #ifdef PNG_FIXED_POINT_SUPPORTED png_set_cHRM_fixed(png_ptr, info_ptr, int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y); @@ -655,15 +585,14 @@ #ifdef PNG_FLOATING_POINT_SUPPORTED png_set_cHRM(png_ptr, info_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); #endif - } #endif /* cHRM */ } #endif /* sRGB */ -#if defined(PNG_iCCP_SUPPORTED) +#ifdef PNG_iCCP_SUPPORTED void PNGAPI png_set_iCCP(png_structp png_ptr, png_infop info_ptr, png_charp name, int compression_type, png_charp profile, png_uint_32 proflen) @@ -709,9 +638,9 @@ info_ptr->valid |= PNG_INFO_iCCP; } #endif -#if defined(PNG_TEXT_SUPPORTED) +#ifdef PNG_TEXT_SUPPORTED void PNGAPI png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, int num_text) { @@ -882,9 +811,9 @@ return(0); } #endif -#if defined(PNG_tIME_SUPPORTED) +#ifdef PNG_tIME_SUPPORTED void PNGAPI png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) { png_debug1(1, "in %s storage function", "tIME"); @@ -897,9 +826,9 @@ info_ptr->valid |= PNG_INFO_tIME; } #endif -#if defined(PNG_tRNS_SUPPORTED) +#ifdef PNG_tRNS_SUPPORTED void PNGAPI png_set_tRNS(png_structp png_ptr, png_infop info_ptr, png_bytep trans, int num_trans, png_color_16p trans_values) { @@ -956,9 +885,9 @@ } } #endif -#if defined(PNG_sPLT_SUPPORTED) +#ifdef PNG_sPLT_SUPPORTED void PNGAPI png_set_sPLT(png_structp png_ptr, png_infop info_ptr, png_sPLT_tp entries, int nentries) /* @@ -1120,9 +1049,9 @@ } #endif #endif -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED png_uint_32 PNGAPI png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) { png_debug(1, "in png_permit_mng_features"); @@ -1134,9 +1063,9 @@ return (png_uint_32)png_ptr->mng_features_permitted; } #endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED void PNGAPI png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep chunk_list, int num_chunks) { @@ -1181,9 +1110,9 @@ #endif } #endif -#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED void PNGAPI png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn) { @@ -1196,9 +1125,9 @@ png_ptr->user_chunk_ptr = user_chunk_ptr; } #endif -#if defined(PNG_INFO_IMAGE_SUPPORTED) +#ifdef PNG_INFO_IMAGE_SUPPORTED void PNGAPI png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) { png_debug1(1, "in %s storage function", "rows"); diff -ru4NwbB libpng-1.2.40/pngtest.c libpng-1.2.41beta05/pngtest.c --- libpng-1.2.40/pngtest.c 2009-09-10 06:38:50.235070149 -0500 +++ libpng-1.2.41beta05/pngtest.c 2009-10-17 18:49:29.282427465 -0500 @@ -1,8 +1,8 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.2.37 [June 4, 2009] + * Last changed in libpng 1.2.41 [October 17, 2009] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -32,9 +32,9 @@ */ #include "png.h" -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE # if _WIN32_WCE < 211 __error__ (f|w)printf functions are not supported on old WindowsCE.; # endif # include @@ -53,10 +53,10 @@ check=(png_size_t)fwrite(data, (png_size_t)1, length, file) # define FCLOSE(file) fclose(file) #endif -#if defined(PNG_NO_STDIO) -# if defined(_WIN32_WCE) +#ifdef PNG_NO_STDIO +# ifdef _WIN32_WCE typedef HANDLE png_FILE_p; # else typedef FILE * png_FILE_p; # endif @@ -74,18 +74,18 @@ /* Turn on CPU timing #define PNGTEST_TIMING */ -#ifdef PNG_NO_FLOATING_POINT_SUPPORTED +#ifndef PNG_FLOATING_POINT_SUPPORTED #undef PNGTEST_TIMING #endif #ifdef PNGTEST_TIMING static float t_start, t_stop, t_decode, t_encode, t_misc; #include #endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) +#ifdef PNG_TIME_RFC1123_SUPPORTED #define PNG_tIME_STRING_LENGTH 29 static int tIME_chunk_present = 0; static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present"; #endif @@ -161,9 +161,9 @@ fprintf(stdout, "w"); } -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED /* Example of using user transform callback (we don't transform anything, * but merely examine the row filters. We set this to 256 rather than * 5 in case illegal filter values are present.) */ @@ -183,9 +183,9 @@ ++filters_used[*(data - 1)]; } #endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED /* Example of using user transform callback (we don't transform anything, * but merely count the zero samples) */ @@ -296,9 +296,9 @@ #endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */ static int wrote_question = 0; -#if defined(PNG_NO_STDIO) +#ifdef PNG_NO_STDIO /* START of code to validate stdio-free compilation */ /* These copies of the default read/write functions come from pngrio.c and * pngwio.c. They allow "don't include stdio" testing of the library. * This is the function that does the actual reading of data. If you are @@ -370,9 +370,9 @@ png_error(png_ptr, "read Error"); } #endif /* USE_FAR_KEYWORD */ -#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#ifdef PNG_WRITE_FLUSH_SUPPORTED static void pngtest_flush(png_structp png_ptr) { /* Do nothing; fflush() is said to be just a waste of energy. */ @@ -473,9 +473,9 @@ /* We can return because png_error calls the default handler, which is * actually OK in this case. */ } -#endif /* PNG_NO_STDIO */ +#endif /* !PNG_STDIO_SUPPORTED */ /* END of code to validate stdio-free compilation */ /* START of code to validate memory allocation and deallocation */ #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG @@ -606,9 +606,9 @@ /* END of code to test memory allocation/deallocation */ /* Demonstration of user chunk support of the sTER and vpAg chunks */ -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED /* (sTER is a public chunk not yet known by libpng. vpAg is a private chunk used in ImageMagick to store "virtual page" size). */ @@ -700,16 +700,16 @@ jmp_buf jmpbuf; #endif #endif -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE TCHAR path[MAX_PATH]; #endif char inbuf[256], outbuf[256]; row_buf = NULL; -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) #else if ((fpin = fopen(inname, "rb")) == NULL) @@ -718,9 +718,9 @@ fprintf(STDERR, "Could not find input file %s\n", inname); return (1); } -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); if ((fpout = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE) #else if ((fpout = fopen(outname, "wb")) == NULL) @@ -741,14 +741,14 @@ read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, png_error_ptr_NULL, png_error_ptr_NULL); #endif -#if defined(PNG_NO_STDIO) +#ifdef PNG_NO_STDIO png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); #endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED user_chunk_data[0] = 0; user_chunk_data[1] = 0; user_chunk_data[2] = 0; user_chunk_data[3] = 0; @@ -766,9 +766,9 @@ write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, png_error_ptr_NULL, png_error_ptr_NULL); #endif -#if defined(PNG_NO_STDIO) +#ifdef PNG_NO_STDIO png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); #endif #endif @@ -828,18 +828,18 @@ #endif #endif png_debug(0, "Initializing input and output streams"); -#if !defined(PNG_NO_STDIO) +#ifndef PNG_NO_STDIO png_init_io(read_ptr, fpin); # ifdef PNG_WRITE_SUPPORTED png_init_io(write_ptr, fpout); # endif #else png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); # ifdef PNG_WRITE_SUPPORTED png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data, -# if defined(PNG_WRITE_FLUSH_SUPPORTED) +# ifdef PNG_WRITE_FLUSH_SUPPORTED pngtest_flush); # else NULL); # endif @@ -859,29 +859,29 @@ #endif png_set_read_status_fn(read_ptr, png_read_status_ptr_NULL); } -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED { int i; for (i = 0; i<256; i++) filters_used[i] = 0; png_set_read_user_transform_fn(read_ptr, count_filters); } #endif -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED zero_samples = 0; png_set_write_user_transform_fn(write_ptr, count_zero_samples); #endif -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED # ifndef PNG_HANDLE_CHUNK_ALWAYS # define PNG_HANDLE_CHUNK_ALWAYS 3 # endif png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS, png_bytep_NULL, 0); #endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED # ifndef PNG_HANDLE_CHUNK_IF_SAFE # define PNG_HANDLE_CHUNK_IF_SAFE 2 # endif png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE, @@ -898,17 +898,17 @@ if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_type)) { png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +#ifdef PNG_WRITE_INTERLACING_SUPPORTED color_type, interlace_type, compression_type, filter_type); #else color_type, PNG_INTERLACE_NONE, compression_type, filter_type); #endif } } -#if defined(PNG_FIXED_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FIXED_POINT_SUPPORTED +#ifdef PNG_cHRM_SUPPORTED { png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, @@ -918,19 +918,19 @@ red_y, green_x, green_y, blue_x, blue_y); } } #endif -#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_gAMA_SUPPORTED { png_fixed_point gamma; if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); } #endif #else /* Use floating point versions */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) -#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +#ifdef PNG_cHRM_SUPPORTED { double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, @@ -940,9 +940,9 @@ red_y, green_x, green_y, blue_x, blue_y); } } #endif -#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_gAMA_SUPPORTED { double gamma; if (png_get_gAMA(read_ptr, read_info_ptr, &gamma)) @@ -950,9 +950,9 @@ } #endif #endif /* Floating point */ #endif /* Fixed point */ -#if defined(PNG_iCCP_SUPPORTED) +#ifdef PNG_iCCP_SUPPORTED { png_charp name; png_charp profile; png_uint_32 proflen; @@ -965,9 +965,9 @@ profile, proflen); } } #endif -#if defined(PNG_sRGB_SUPPORTED) +#ifdef PNG_sRGB_SUPPORTED { int intent; if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) @@ -980,9 +980,9 @@ if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); } -#if defined(PNG_bKGD_SUPPORTED) +#ifdef PNG_bKGD_SUPPORTED { png_color_16p background; if (png_get_bKGD(read_ptr, read_info_ptr, &background)) @@ -990,17 +990,17 @@ png_set_bKGD(write_ptr, write_info_ptr, background); } } #endif -#if defined(PNG_hIST_SUPPORTED) +#ifdef PNG_hIST_SUPPORTED { png_uint_16p hist; if (png_get_hIST(read_ptr, read_info_ptr, &hist)) png_set_hIST(write_ptr, write_info_ptr, hist); } #endif -#if defined(PNG_oFFs_SUPPORTED) +#ifdef PNG_oFFs_SUPPORTED { png_int_32 offset_x, offset_y; int unit_type; @@ -1010,9 +1010,9 @@ png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); } } #endif -#if defined(PNG_pCAL_SUPPORTED) +#ifdef PNG_pCAL_SUPPORTED { png_charp purpose, units; png_charpp params; png_int_32 X0, X1; @@ -1025,26 +1025,26 @@ nparams, units, params); } } #endif -#if defined(PNG_pHYs_SUPPORTED) +#ifdef PNG_pHYs_SUPPORTED { png_uint_32 res_x, res_y; int unit_type; if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); } #endif -#if defined(PNG_sBIT_SUPPORTED) +#ifdef PNG_sBIT_SUPPORTED { png_color_8p sig_bit; if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) png_set_sBIT(write_ptr, write_info_ptr, sig_bit); } #endif -#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_sCAL_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED { int unit; double scal_width, scal_height; @@ -1069,9 +1069,9 @@ } #endif #endif #endif -#if defined(PNG_TEXT_SUPPORTED) +#ifdef PNG_TEXT_SUPPORTED { png_textp text_ptr; int num_text; @@ -1081,16 +1081,16 @@ png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); } } #endif -#if defined(PNG_tIME_SUPPORTED) +#ifdef PNG_tIME_SUPPORTED { png_timep mod_time; if (png_get_tIME(read_ptr, read_info_ptr, &mod_time)) { png_set_tIME(write_ptr, write_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) +#ifdef PNG_TIME_RFC1123_SUPPORTED /* We have to use png_memcpy instead of "=" because the string * pointed to by png_convert_to_rfc1123() gets free'ed before * we use it. */ @@ -1102,9 +1102,9 @@ #endif /* PNG_TIME_RFC1123_SUPPORTED */ } } #endif -#if defined(PNG_tRNS_SUPPORTED) +#ifdef PNG_tRNS_SUPPORTED { png_bytep trans; int num_trans; png_color_16p trans_values; @@ -1124,9 +1124,9 @@ trans_values); } } #endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED { png_unknown_chunkp unknowns; int num_unknowns = (int)png_get_unknown_chunks(read_ptr, read_info_ptr, &unknowns); @@ -1153,9 +1153,9 @@ * png_write_info_before_PLTE(write_ptr, write_info_ptr); */ png_write_info(write_ptr, write_info_ptr); -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED if (user_chunk_data[0] != 0) { png_byte png_sTER[5] = {115, 84, 69, 82, '\0'}; @@ -1247,19 +1247,19 @@ #endif /* !SINGLE_ROWBUF_ALLOC */ } } -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1); #endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); #endif png_debug(0, "Reading and writing end_info data"); png_read_end(read_ptr, end_info_ptr); -#if defined(PNG_TEXT_SUPPORTED) +#ifdef PNG_TEXT_SUPPORTED { png_textp text_ptr; int num_text; @@ -1269,16 +1269,16 @@ png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); } } #endif -#if defined(PNG_tIME_SUPPORTED) +#ifdef PNG_tIME_SUPPORTED { png_timep mod_time; if (png_get_tIME(read_ptr, end_info_ptr, &mod_time)) { png_set_tIME(write_ptr, write_end_info_ptr, mod_time); -#if defined(PNG_TIME_RFC1123_SUPPORTED) +#ifdef PNG_TIME_RFC1123_SUPPORTED /* We have to use png_memcpy instead of "=" because the string pointed to by png_convert_to_rfc1123() gets free'ed before we use it */ png_memcpy(tIME_string, @@ -1289,9 +1289,9 @@ #endif /* PNG_TIME_RFC1123_SUPPORTED */ } } #endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED { png_unknown_chunkp unknowns; int num_unknowns; num_unknowns = (int)png_get_unknown_chunks(read_ptr, end_info_ptr, @@ -1345,9 +1345,9 @@ FCLOSE(fpin); FCLOSE(fpout); png_debug(0, "Opening files for comparison"); -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) #else if ((fpin = fopen(inname, "rb")) == NULL) @@ -1356,9 +1356,9 @@ fprintf(STDERR, "Could not find file %s\n", inname); return (1); } -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); if ((fpout = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) #else if ((fpout = fopen(outname, "rb")) == NULL) @@ -1526,29 +1526,29 @@ int allocation_now = current_allocation; #endif for (i=2; itransformations |= PNG_FILLER; +#ifdef PNG_LEGACY_SUPPORTED png_ptr->filler = (png_byte)filler; +#else + png_ptr->filler = (png_uint_16)filler; +#endif if (filler_loc == PNG_FILLER_AFTER) png_ptr->flags |= PNG_FLAG_FILLER_AFTER; else png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; @@ -134,9 +145,9 @@ png_ptr->usr_channels = 2; } } -#if !defined(PNG_1_0_X) +#ifndef PNG_1_0_X /* Added to libpng-1.2.7 */ void PNGAPI png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) { @@ -188,12 +203,13 @@ void /* PRIVATE */ png_do_invert(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_invert"); + /* This test removed from libpng version 1.0.13 and 1.2.0: * if (row_info->bit_depth == 1 && */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED if (row == NULL || row_info == NULL) return; #endif if (row_info->color_type == PNG_COLOR_TYPE_GRAY) @@ -243,10 +259,11 @@ void /* PRIVATE */ png_do_swap(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_swap"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif row_info->bit_depth == 16) { @@ -374,10 +391,11 @@ void /* PRIVATE */ png_do_packswap(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_packswap"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif row_info->bit_depth < 8) { @@ -406,9 +424,10 @@ void /* PRIVATE */ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) { png_debug(1, "in png_do_strip_filler"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) + +#ifdef PNG_USELESS_TESTS_SUPPORTED if (row != NULL && row_info != NULL) #endif { png_bytep sp=row; @@ -564,10 +583,11 @@ void /* PRIVATE */ png_do_bgr(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_bgr"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { @@ -643,11 +663,12 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels) { png_debug(1, "in png_set_user_transform_info"); + if (png_ptr == NULL) return; -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED png_ptr->user_transform_ptr = user_transform_ptr; png_ptr->user_transform_depth = (png_byte)user_transform_depth; png_ptr->user_transform_channels = (png_byte)user_transform_channels; #else @@ -667,9 +688,9 @@ png_get_user_transform_ptr(png_structp png_ptr) { if (png_ptr == NULL) return (NULL); -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED return ((png_voidp)png_ptr->user_transform_ptr); #else return (NULL); #endif diff -ru4NwbB libpng-1.2.40/pngwio.c libpng-1.2.41beta05/pngwio.c --- libpng-1.2.40/pngwio.c 2009-09-10 06:38:50.250863102 -0500 +++ libpng-1.2.41beta05/pngwio.c 2009-10-17 18:49:29.298248660 -0500 @@ -1,8 +1,8 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.2.37 [June 4, 2009] + * Last changed in libpng 1.2.41 [October 17, 2009] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -37,9 +37,9 @@ else png_error(png_ptr, "Call to NULL write function"); } -#if !defined(PNG_NO_STDIO) +#ifndef PNG_NO_STDIO /* This is the function that does the actual writing of data. If you are * not writing to a standard C stream, you should create a replacement * write_data function and use it at run time with png_set_write_fn(), rather * than changing the library. @@ -51,9 +51,9 @@ png_uint_32 check; if (png_ptr == NULL) return; -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) check = 0; #else check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); @@ -83,9 +83,9 @@ near_data = (png_byte *)CVT_PTR_NOCHECK(data); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); if ((png_bytep)near_data == data) { -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE if ( !WriteFile(io_ptr, near_data, length, &check, NULL) ) check = 0; #else check = fwrite(near_data, 1, length, io_ptr); @@ -100,9 +100,9 @@ do { written = MIN(NEAR_BUF_SIZE, remaining); png_memcpy(buf, data, written); /* Copy far buffer to near buffer */ -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) err = 0; #else err = fwrite(buf, 1, written, io_ptr); @@ -128,26 +128,26 @@ /* This function is called to output any data pending writing (normally * to disk). After png_flush is called, there should be no data pending * writing in any buffers. */ -#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#ifdef PNG_WRITE_FLUSH_SUPPORTED void /* PRIVATE */ png_flush(png_structp png_ptr) { if (png_ptr->output_flush_fn != NULL) (*(png_ptr->output_flush_fn))(png_ptr); } -#if !defined(PNG_NO_STDIO) +#ifndef PNG_NO_STDIO void PNGAPI png_default_flush(png_structp png_ptr) { -#if !defined(_WIN32_WCE) +#ifndef _WIN32_WCE png_FILE_p io_ptr; #endif if (png_ptr == NULL) return; -#if !defined(_WIN32_WCE) +#ifndef _WIN32_WCE io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); fflush(io_ptr); #endif } @@ -191,9 +191,9 @@ return; png_ptr->io_ptr = io_ptr; -#if !defined(PNG_NO_STDIO) +#ifndef PNG_NO_STDIO if (write_data_fn != NULL) png_ptr->write_data_fn = write_data_fn; else @@ -201,10 +201,10 @@ #else png_ptr->write_data_fn = write_data_fn; #endif -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) +#ifdef PNG_WRITE_FLUSH_SUPPORTED +#ifndef PNG_NO_STDIO if (output_flush_fn != NULL) png_ptr->output_flush_fn = output_flush_fn; else @@ -224,10 +224,10 @@ "the same structure. Resetting read_data_fn to NULL."); } } -#if defined(USE_FAR_KEYWORD) -#if defined(_MSC_VER) +#ifdef USE_FAR_KEYWORD +#ifdef _MSC_VER void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) { void *near_ptr; void FAR *far_ptr; diff -ru4NwbB libpng-1.2.40/pngwrite.c libpng-1.2.41beta05/pngwrite.c --- libpng-1.2.40/pngwrite.c 2009-09-10 06:38:50.259154403 -0500 +++ libpng-1.2.41beta05/pngwrite.c 2009-10-17 18:49:29.306744614 -0500 @@ -1,8 +1,8 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.2.37 [June 4, 2009] + * Last changed in libpng 1.2.41 [October 17, 2009] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -32,10 +33,11 @@ if (png_ptr == NULL || info_ptr == NULL) return; if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) { - png_write_sig(png_ptr); /* Write PNG signature */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) + /* Write PNG signature */ + png_write_sig(png_ptr); +#ifdef PNG_MNG_FEATURES_SUPPORTED if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted)) { png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); png_ptr->mng_features_permitted=0; @@ -44,17 +46,17 @@ /* Write IHDR information. */ png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, info_ptr->filter_type, -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +#ifdef PNG_WRITE_INTERLACING_SUPPORTED info_ptr->interlace_type); #else 0); #endif /* The rest of these check to see if the valid field has the appropriate * flag set, and if it does, writes the chunk. */ -#if defined(PNG_WRITE_gAMA_SUPPORTED) +#ifdef PNG_WRITE_gAMA_SUPPORTED if (info_ptr->valid & PNG_INFO_gAMA) { # ifdef PNG_FLOATING_POINT_SUPPORTED png_write_gAMA(png_ptr, info_ptr->gamma); @@ -64,22 +66,22 @@ # endif #endif } #endif -#if defined(PNG_WRITE_sRGB_SUPPORTED) +#ifdef PNG_WRITE_sRGB_SUPPORTED if (info_ptr->valid & PNG_INFO_sRGB) png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent); #endif -#if defined(PNG_WRITE_iCCP_SUPPORTED) +#ifdef PNG_WRITE_iCCP_SUPPORTED if (info_ptr->valid & PNG_INFO_iCCP) png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE, info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); #endif -#if defined(PNG_WRITE_sBIT_SUPPORTED) +#ifdef PNG_WRITE_sBIT_SUPPORTED if (info_ptr->valid & PNG_INFO_sBIT) png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); #endif -#if defined(PNG_WRITE_cHRM_SUPPORTED) +#ifdef PNG_WRITE_cHRM_SUPPORTED if (info_ptr->valid & PNG_INFO_cHRM) { #ifdef PNG_FLOATING_POINT_SUPPORTED png_write_cHRM(png_ptr, @@ -97,9 +99,9 @@ # endif #endif } #endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED if (info_ptr->unknown_chunks_num) { png_unknown_chunk *up; @@ -146,12 +148,12 @@ (png_uint_32)info_ptr->num_palette); else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) png_error(png_ptr, "Valid palette required for paletted images"); -#if defined(PNG_WRITE_tRNS_SUPPORTED) +#ifdef PNG_WRITE_tRNS_SUPPORTED if (info_ptr->valid & PNG_INFO_tRNS) { -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED /* Invert the alpha channel (in tRNS) */ if ((png_ptr->transformations & PNG_INVERT_ALPHA) && info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { @@ -163,31 +165,31 @@ png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), info_ptr->num_trans, info_ptr->color_type); } #endif -#if defined(PNG_WRITE_bKGD_SUPPORTED) +#ifdef PNG_WRITE_bKGD_SUPPORTED if (info_ptr->valid & PNG_INFO_bKGD) png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); #endif -#if defined(PNG_WRITE_hIST_SUPPORTED) +#ifdef PNG_WRITE_hIST_SUPPORTED if (info_ptr->valid & PNG_INFO_hIST) png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); #endif -#if defined(PNG_WRITE_oFFs_SUPPORTED) +#ifdef PNG_WRITE_oFFs_SUPPORTED if (info_ptr->valid & PNG_INFO_oFFs) png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset, info_ptr->offset_unit_type); #endif -#if defined(PNG_WRITE_pCAL_SUPPORTED) +#ifdef PNG_WRITE_pCAL_SUPPORTED if (info_ptr->valid & PNG_INFO_pCAL) png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, info_ptr->pcal_units, info_ptr->pcal_params); #endif -#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_sCAL_SUPPORTED if (info_ptr->valid & PNG_INFO_sCAL) -#if defined(PNG_WRITE_sCAL_SUPPORTED) +#ifdef PNG_WRITE_sCAL_SUPPORTED #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); #else /* !FLOATING_POINT */ @@ -201,38 +203,38 @@ "png_write_sCAL not supported; sCAL chunk not written."); #endif /* WRITE_sCAL */ #endif /* sCAL */ -#if defined(PNG_WRITE_pHYs_SUPPORTED) +#ifdef PNG_WRITE_pHYs_SUPPORTED if (info_ptr->valid & PNG_INFO_pHYs) png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); #endif /* pHYs */ -#if defined(PNG_WRITE_tIME_SUPPORTED) +#ifdef PNG_WRITE_tIME_SUPPORTED if (info_ptr->valid & PNG_INFO_tIME) { png_write_tIME(png_ptr, &(info_ptr->mod_time)); png_ptr->mode |= PNG_WROTE_tIME; } #endif /* tIME */ -#if defined(PNG_WRITE_sPLT_SUPPORTED) +#ifdef PNG_WRITE_sPLT_SUPPORTED if (info_ptr->valid & PNG_INFO_sPLT) for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); #endif /* sPLT */ -#if defined(PNG_WRITE_TEXT_SUPPORTED) +#ifdef PNG_WRITE_TEXT_SUPPORTED /* Check to see if we need to write text chunks */ for (i = 0; i < info_ptr->num_text; i++) { png_debug2(2, "Writing header text chunk %d, type %d", i, info_ptr->text[i].compression); /* An internationalized chunk? */ if (info_ptr->text[i].compression > 0) { -#if defined(PNG_WRITE_iTXt_SUPPORTED) +#ifdef PNG_WRITE_iTXt_SUPPORTED /* Write international chunk */ png_write_iTXt(png_ptr, info_ptr->text[i].compression, info_ptr->text[i].key, @@ -247,9 +249,9 @@ } /* If we want a compressed text chunk */ else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) { -#if defined(PNG_WRITE_zTXt_SUPPORTED) +#ifdef PNG_WRITE_zTXt_SUPPORTED /* Write compressed chunk */ png_write_zTXt(png_ptr, info_ptr->text[i].key, info_ptr->text[i].text, 0, info_ptr->text[i].compression); @@ -260,9 +262,9 @@ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; } else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) { -#if defined(PNG_WRITE_tEXt_SUPPORTED) +#ifdef PNG_WRITE_tEXt_SUPPORTED /* Write uncompressed chunk */ png_write_tEXt(png_ptr, info_ptr->text[i].key, info_ptr->text[i].text, 0); @@ -275,9 +277,9 @@ } } #endif /* tEXt */ -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED if (info_ptr->unknown_chunks_num) { png_unknown_chunk *up; @@ -317,27 +320,27 @@ /* See if user wants us to write information chunks */ if (info_ptr != NULL) { -#if defined(PNG_WRITE_TEXT_SUPPORTED) - int i; /* Local index variable */ +#ifdef PNG_WRITE_TEXT_SUPPORTED + int i; /* local index variable */ #endif -#if defined(PNG_WRITE_tIME_SUPPORTED) +#ifdef PNG_WRITE_tIME_SUPPORTED /* Check to see if user has supplied a time chunk */ if ((info_ptr->valid & PNG_INFO_tIME) && !(png_ptr->mode & PNG_WROTE_tIME)) png_write_tIME(png_ptr, &(info_ptr->mod_time)); #endif -#if defined(PNG_WRITE_TEXT_SUPPORTED) +#ifdef PNG_WRITE_TEXT_SUPPORTED /* Loop through comment chunks */ for (i = 0; i < info_ptr->num_text; i++) { png_debug2(2, "Writing trailer text chunk %d, type %d", i, info_ptr->text[i].compression); /* An internationalized chunk? */ if (info_ptr->text[i].compression > 0) { -#if defined(PNG_WRITE_iTXt_SUPPORTED) +#ifdef PNG_WRITE_iTXt_SUPPORTED /* Write international chunk */ png_write_iTXt(png_ptr, info_ptr->text[i].compression, info_ptr->text[i].key, @@ -351,9 +354,9 @@ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; } else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) { -#if defined(PNG_WRITE_zTXt_SUPPORTED) +#ifdef PNG_WRITE_zTXt_SUPPORTED /* Write compressed chunk */ png_write_zTXt(png_ptr, info_ptr->text[i].key, info_ptr->text[i].text, 0, info_ptr->text[i].compression); @@ -364,9 +367,9 @@ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; } else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) { -#if defined(PNG_WRITE_tEXt_SUPPORTED) +#ifdef PNG_WRITE_tEXt_SUPPORTED /* Write uncompressed chunk */ png_write_tEXt(png_ptr, info_ptr->text[i].key, info_ptr->text[i].text, 0); #else @@ -377,9 +380,9 @@ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; } } #endif -#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED if (info_ptr->unknown_chunks_num) { png_unknown_chunk *up; @@ -419,10 +422,10 @@ png_flush(png_ptr); #endif } -#if defined(PNG_WRITE_tIME_SUPPORTED) -#if !defined(_WIN32_WCE) +#ifdef PNG_WRITE_tIME_SUPPORTED +#ifndef _WIN32_WCE /* "time.h" functions are not supported on WindowsCE */ void PNGAPI png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) { @@ -498,9 +506,14 @@ #endif { png_free(png_ptr, png_ptr->zbuf); png_ptr->zbuf=NULL; - png_destroy_struct(png_ptr); +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)png_ptr, + (png_free_ptr)free_fn, (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)png_ptr); +#endif return (NULL); } #ifdef USE_FAR_KEYWORD png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); @@ -562,17 +575,18 @@ png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, png_flush_ptr_NULL); -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, 1, png_doublep_NULL, png_doublep_NULL); #endif #ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ + /* Applications that neglect to set up their own setjmp() and then + * encounter a png_error() will longjmp here. Since the jmpbuf is + * then meaningless we abort instead of returning. + */ #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) PNG_ABORT(); png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); @@ -648,9 +662,9 @@ png_size_t png_struct_size) { png_structp png_ptr=*ptr_ptr; #ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* To save current jump buffer */ + jmp_buf tmp_jmp; /* to save current jump buffer */ #endif int i = 0; @@ -666,9 +680,8 @@ #else png_ptr->warning_fn=NULL; png_warning(png_ptr, "Application uses deprecated png_write_init() and should be recompiled."); - break; #endif } } while (png_libpng_ver[i++]); @@ -706,10 +719,9 @@ /* Initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, 1, png_doublep_NULL, png_doublep_NULL); #endif } @@ -722,10 +734,10 @@ void PNGAPI png_write_rows(png_structp png_ptr, png_bytepp row, png_uint_32 num_rows) { - png_uint_32 i; /* Row counter */ - png_bytepp rp; /* Row pointer */ + png_uint_32 i; /* row counter */ + png_bytepp rp; /* row pointer */ png_debug(1, "in png_write_rows"); if (png_ptr == NULL) @@ -743,17 +755,18 @@ */ void PNGAPI png_write_image(png_structp png_ptr, png_bytepp image) { - png_uint_32 i; /* Row index */ - int pass, num_pass; /* Pass variables */ - png_bytepp rp; /* Points to current row */ + png_uint_32 i; /* row index */ + int pass, num_pass; /* pass variables */ + png_bytepp rp; /* points to current row */ if (png_ptr == NULL) return; png_debug(1, "in png_write_image"); -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) + +#ifdef PNG_WRITE_INTERLACING_SUPPORTED /* Initialize interlace handling. If image is not interlaced, * this will set pass to 1 */ num_pass = png_set_interlace_handling(png_ptr); @@ -820,9 +834,9 @@ png_write_start_row(png_ptr); } -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +#ifdef PNG_WRITE_INTERLACING_SUPPORTED /* If interlaced and not interested in row, return */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { switch (png_ptr->pass) @@ -901,9 +915,9 @@ /* Copy user's row into buffer, leaving room for filter byte. */ png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes); -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +#ifdef PNG_WRITE_INTERLACING_SUPPORTED /* Handle interlacing */ if (png_ptr->interlaced && png_ptr->pass < 6 && (png_ptr->transformations & PNG_INTERLACE)) { @@ -921,9 +935,9 @@ /* Handle other transformations */ if (png_ptr->transformations) png_do_write_transformations(png_ptr); -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED /* Write filter_method 64 (intrapixel differencing) only if * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and * 2. Libpng did not write a PNG signature (this filter_method is only * used in PNG datastreams that are embedded in MNG datastreams) and @@ -946,9 +960,9 @@ 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) +#ifdef PNG_WRITE_FLUSH_SUPPORTED /* Set the automatic flush interval or 0 to turn flushing off */ void PNGAPI png_set_flush(png_structp png_ptr, int nrows) { @@ -1050,9 +1067,9 @@ if (png_ptr != NULL) { png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED if (png_ptr->num_chunk_list) { png_free(png_ptr, png_ptr->chunk_list); png_ptr->chunk_list=NULL; @@ -1112,13 +1130,13 @@ png_free(png_ptr, png_ptr->avg_row); png_free(png_ptr, png_ptr->paeth_row); #endif -#if defined(PNG_TIME_RFC1123_SUPPORTED) +#ifdef PNG_TIME_RFC1123_SUPPORTED png_free(png_ptr, png_ptr->time_buffer); #endif -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED png_free(png_ptr, png_ptr->prev_filters); png_free(png_ptr, png_ptr->filter_weights); png_free(png_ptr, png_ptr->inv_filter_weights); png_free(png_ptr, png_ptr->filter_costs); @@ -1155,11 +1173,12 @@ void PNGAPI png_set_filter(png_structp png_ptr, int method, int filters) { png_debug(1, "in png_set_filter"); + if (png_ptr == NULL) return; -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && (method == PNG_INTRAPIXEL_DIFFERENCING)) method = PNG_FILTER_TYPE_BASE; #endif @@ -1170,9 +1189,9 @@ #ifndef PNG_NO_WRITE_FILTER case 5: case 6: case 7: png_warning(png_ptr, "Unknown row filter for method 0"); -#endif /* PNG_NO_WRITE_FILTER */ +#endif /* PNG_WRITE_FILTER_SUPPORTED */ case PNG_FILTER_VALUE_NONE: png_ptr->do_filter=PNG_FILTER_NONE; break; #ifndef PNG_NO_WRITE_FILTER case PNG_FILTER_VALUE_SUB: @@ -1185,9 +1204,9 @@ png_ptr->do_filter=PNG_FILTER_PAETH; break; default: png_ptr->do_filter = (png_byte)filters; break; #else default: png_warning(png_ptr, "Unknown row filter for method 0"); -#endif /* PNG_NO_WRITE_FILTER */ +#endif /* PNG_WRITE_FILTER_SUPPORTED */ } /* If we have allocated the row_buf, this means we have already started * with the image and we should have allocated all of the filter buffers @@ -1254,9 +1273,9 @@ } } if (png_ptr->do_filter == PNG_NO_FILTERS) -#endif /* PNG_NO_WRITE_FILTER */ +#endif /* PNG_WRITE_FILTER_SUPPORTED */ png_ptr->do_filter = PNG_FILTER_NONE; } } else @@ -1269,9 +1288,9 @@ * question as to whether it can be improved upon by trying to keep the * filtered data going to zlib more consistent, hopefully resulting in * better compression. */ -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */ +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* GRR 970116 */ void PNGAPI png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, int num_weights, png_doublep filter_weights, png_doublep filter_costs) @@ -1459,9 +1483,9 @@ return; png_ptr->write_row_fn = write_row_fn; } -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED void PNGAPI png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr write_user_transform_fn) { @@ -1473,16 +1498,16 @@ } #endif -#if defined(PNG_INFO_IMAGE_SUPPORTED) +#ifdef PNG_INFO_IMAGE_SUPPORTED void PNGAPI png_write_png(png_structp png_ptr, png_infop info_ptr, int transforms, voidp params) { if (png_ptr == NULL || info_ptr == NULL) return; -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED /* Invert the alpha channel from opacity to transparency */ if (transforms & PNG_TRANSFORM_INVERT_ALPHA) png_set_invert_alpha(png_ptr); #endif @@ -1491,56 +1516,56 @@ png_write_info(png_ptr, info_ptr); /* ------ these transformations don't touch the info structure ------- */ -#if defined(PNG_WRITE_INVERT_SUPPORTED) +#ifdef PNG_WRITE_INVERT_SUPPORTED /* Invert monochrome pixels */ if (transforms & PNG_TRANSFORM_INVERT_MONO) png_set_invert_mono(png_ptr); #endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) +#ifdef PNG_WRITE_SHIFT_SUPPORTED /* Shift the pixels up to a legal bit depth and fill in * as appropriate to correctly scale the image. */ if ((transforms & PNG_TRANSFORM_SHIFT) && (info_ptr->valid & PNG_INFO_sBIT)) png_set_shift(png_ptr, &info_ptr->sig_bit); #endif -#if defined(PNG_WRITE_PACK_SUPPORTED) +#ifdef PNG_WRITE_PACK_SUPPORTED /* Pack pixels into bytes */ if (transforms & PNG_TRANSFORM_PACKING) png_set_packing(png_ptr); #endif -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED /* Swap location of alpha bytes from ARGB to RGBA */ if (transforms & PNG_TRANSFORM_SWAP_ALPHA) png_set_swap_alpha(png_ptr); #endif -#if defined(PNG_WRITE_FILLER_SUPPORTED) +#ifdef PNG_WRITE_FILLER_SUPPORTED /* Pack XRGB/RGBX/ARGB/RGBA into * RGB (4 channels -> 3 channels) */ if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) png_set_filler(png_ptr, 0, PNG_FILLER_AFTER); else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); #endif -#if defined(PNG_WRITE_BGR_SUPPORTED) +#ifdef PNG_WRITE_BGR_SUPPORTED /* Flip BGR pixels to RGB */ if (transforms & PNG_TRANSFORM_BGR) png_set_bgr(png_ptr); #endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) +#ifdef PNG_WRITE_SWAP_SUPPORTED /* Swap bytes of 16-bit files to most significant byte first */ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) png_set_swap(png_ptr); #endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) +#ifdef PNG_WRITE_PACKSWAP_SUPPORTED /* Swap bits of 1, 2, 4 bit packed pixel formats */ if (transforms & PNG_TRANSFORM_PACKSWAP) png_set_packswap(png_ptr); #endif diff -ru4NwbB libpng-1.2.40/pngwtran.c libpng-1.2.41beta05/pngwtran.c --- libpng-1.2.40/pngwtran.c 2009-09-10 06:38:50.265308866 -0500 +++ libpng-1.2.41beta05/pngwtran.c 2009-10-17 18:49:29.312756152 -0500 @@ -1,8 +1,8 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.2.37 [June 4, 2009] + * Last changed in libpng 1.2.41 [October 17, 2009] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -25,9 +25,9 @@ if (png_ptr == NULL) return; -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +#ifdef 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 */ @@ -39,50 +39,50 @@ /* 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) +#ifdef PNG_WRITE_FILLER_SUPPORTED if (png_ptr->transformations & PNG_FILLER) png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->flags); #endif -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) +#ifdef PNG_WRITE_PACKSWAP_SUPPORTED if (png_ptr->transformations & PNG_PACKSWAP) png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_WRITE_PACK_SUPPORTED) +#ifdef PNG_WRITE_PACK_SUPPORTED if (png_ptr->transformations & PNG_PACK) png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, (png_uint_32)png_ptr->bit_depth); #endif -#if defined(PNG_WRITE_SWAP_SUPPORTED) +#ifdef PNG_WRITE_SWAP_SUPPORTED if (png_ptr->transformations & PNG_SWAP_BYTES) png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) +#ifdef PNG_WRITE_SHIFT_SUPPORTED if (png_ptr->transformations & PNG_SHIFT) png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, &(png_ptr->shift)); #endif -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_SWAP_ALPHA) png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED if (png_ptr->transformations & PNG_INVERT_ALPHA) png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_WRITE_BGR_SUPPORTED) +#ifdef PNG_WRITE_BGR_SUPPORTED if (png_ptr->transformations & PNG_BGR) png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif -#if defined(PNG_WRITE_INVERT_SUPPORTED) +#ifdef PNG_WRITE_INVERT_SUPPORTED if (png_ptr->transformations & PNG_INVERT_MONO) png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif } -#if defined(PNG_WRITE_PACK_SUPPORTED) +#ifdef PNG_WRITE_PACK_SUPPORTED /* Pack pixels into bytes. Pass the true bit depth in bit_depth. The * row_info bit depth should be 8 (one pixel per byte). The channels * should be 1 (this only happens on grayscale and paletted images). */ @@ -89,10 +89,11 @@ void /* PRIVATE */ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) { png_debug(1, "in png_do_pack"); + if (row_info->bit_depth == 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif row_info->channels == 1) { @@ -203,9 +204,9 @@ } } #endif -#if defined(PNG_WRITE_SHIFT_SUPPORTED) +#ifdef PNG_WRITE_SHIFT_SUPPORTED /* Shift pixel values to take advantage of whole range. Pass the * true number of bits in bit_depth. The row should be packed * according to row_info->bit_depth. Thus, if you had a row of * bit depth 4, but the pixels only had values from 0 to 7, you @@ -215,9 +216,10 @@ void /* PRIVATE */ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) { png_debug(1, "in png_do_shift"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) + +#ifdef PNG_USELESS_TESTS_SUPPORTED if (row != NULL && row_info != NULL && #else if ( #endif @@ -334,14 +336,15 @@ } } #endif -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED void /* PRIVATE */ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_write_swap_alpha"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) + +#ifdef PNG_USELESS_TESTS_SUPPORTED if (row != NULL && row_info != NULL) #endif { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) @@ -422,14 +425,15 @@ } } #endif -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED void /* PRIVATE */ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_write_invert_alpha"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) + +#ifdef PNG_USELESS_TESTS_SUPPORTED if (row != NULL && row_info != NULL) #endif { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) @@ -511,9 +515,9 @@ } } #endif -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED /* Undoes intrapixel differencing */ void /* PRIVATE */ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) { @@ -517,10 +521,11 @@ void /* PRIVATE */ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_write_intrapixel"); + if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED row != NULL && row_info != NULL && #endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { diff -ru4NwbB libpng-1.2.40/pngwutil.c libpng-1.2.41beta05/pngwutil.c --- libpng-1.2.40/pngwutil.c 2009-09-10 06:38:50.275883066 -0500 +++ libpng-1.2.41beta05/pngwutil.c 2009-10-17 18:49:29.323449052 -0500 @@ -1,8 +1,8 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.2.40 [October 17, 2009] + * Last changed in libpng 1.2.41 [October 17, 2009] * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -458,9 +458,9 @@ * 4. The filter_method is 64 and * 5. The color_type is RGB or RGBA */ if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA) && @@ -486,9 +486,9 @@ /* Save the relevent information */ png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->color_type = (png_byte)color_type; png_ptr->interlaced = (png_byte)interlace_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED png_ptr->filter_type = (png_byte)filter_type; #endif png_ptr->compression_type = (png_byte)compression_type; png_ptr->width = width; @@ -578,9 +578,9 @@ png_debug(1, "in png_write_PLTE"); if (( -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && #endif num_pal == 0) || num_pal > 256) { @@ -699,9 +699,9 @@ (png_size_t)0); png_ptr->mode |= PNG_HAVE_IEND; } -#if defined(PNG_WRITE_gAMA_SUPPORTED) +#ifdef PNG_WRITE_gAMA_SUPPORTED /* Write a gAMA chunk */ #ifdef PNG_FLOATING_POINT_SUPPORTED void /* PRIVATE */ png_write_gAMA(png_structp png_ptr, double file_gamma) @@ -737,9 +737,9 @@ } #endif #endif -#if defined(PNG_WRITE_sRGB_SUPPORTED) +#ifdef PNG_WRITE_sRGB_SUPPORTED /* Write a sRGB chunk */ void /* PRIVATE */ png_write_sRGB(png_structp png_ptr, int srgb_intent) { @@ -757,9 +757,9 @@ png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1); } #endif -#if defined(PNG_WRITE_iCCP_SUPPORTED) +#ifdef PNG_WRITE_iCCP_SUPPORTED /* Write an iCCP chunk */ void /* PRIVATE */ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, png_charp profile, int profile_len) @@ -838,9 +838,9 @@ png_free(png_ptr, new_name); } #endif -#if defined(PNG_WRITE_sPLT_SUPPORTED) +#ifdef PNG_WRITE_sPLT_SUPPORTED /* Write a sPLT chunk */ void /* PRIVATE */ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) { @@ -919,9 +919,9 @@ png_free(png_ptr, new_name); } #endif -#if defined(PNG_WRITE_sBIT_SUPPORTED) +#ifdef PNG_WRITE_sBIT_SUPPORTED /* Write the sBIT chunk */ void /* PRIVATE */ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) { @@ -976,9 +976,9 @@ png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); } #endif -#if defined(PNG_WRITE_cHRM_SUPPORTED) +#ifdef PNG_WRITE_cHRM_SUPPORTED /* Write the cHRM chunk */ #ifdef PNG_FLOATING_POINT_SUPPORTED void /* PRIVATE */ png_write_cHRM(png_structp png_ptr, double white_x, double white_y, @@ -1003,9 +1003,9 @@ int_green_y = (png_uint_32)(green_y * 100000.0 + 0.5); int_blue_x = (png_uint_32)(blue_x * 100000.0 + 0.5); int_blue_y = (png_uint_32)(blue_y * 100000.0 + 0.5); -#if !defined(PNG_NO_CHECK_cHRM) +#ifndef PNG_NO_CHECK_cHRM if (png_check_cHRM_fixed(png_ptr, int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y)) #endif { @@ -1041,9 +1041,9 @@ png_debug(1, "in png_write_cHRM"); /* Each value is saved in 1/100,000ths */ -#if !defined(PNG_NO_CHECK_cHRM) +#ifndef PNG_NO_CHECK_cHRM if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)) #endif { @@ -1064,9 +1064,9 @@ } #endif #endif -#if defined(PNG_WRITE_tRNS_SUPPORTED) +#ifdef PNG_WRITE_tRNS_SUPPORTED /* Write the tRNS chunk */ void /* PRIVATE */ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, int num_trans, int color_type) @@ -1121,9 +1121,9 @@ } } #endif -#if defined(PNG_WRITE_bKGD_SUPPORTED) +#ifdef PNG_WRITE_bKGD_SUPPORTED /* Write the background chunk */ void /* PRIVATE */ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) { @@ -1136,9 +1136,9 @@ if (color_type == PNG_COLOR_TYPE_PALETTE) { if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) +#ifdef PNG_MNG_FEATURES_SUPPORTED (png_ptr->num_palette || (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && #endif back->index >= png_ptr->num_palette) @@ -1175,9 +1175,9 @@ } } #endif -#if defined(PNG_WRITE_hIST_SUPPORTED) +#ifdef PNG_WRITE_hIST_SUPPORTED /* Write the histogram */ void /* PRIVATE */ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) { @@ -1339,9 +1339,9 @@ return (key_len); } #endif -#if defined(PNG_WRITE_tEXt_SUPPORTED) +#ifdef PNG_WRITE_tEXt_SUPPORTED /* Write a tEXt chunk */ void /* PRIVATE */ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, png_size_t text_len) @@ -1380,9 +1380,9 @@ png_free(png_ptr, new_key); } #endif -#if defined(PNG_WRITE_zTXt_SUPPORTED) +#ifdef PNG_WRITE_zTXt_SUPPORTED /* Write a compressed text chunk */ void /* PRIVATE */ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, png_size_t text_len, int compression) @@ -1440,9 +1440,9 @@ png_write_chunk_end(png_ptr); } #endif -#if defined(PNG_WRITE_iTXt_SUPPORTED) +#ifdef PNG_WRITE_iTXt_SUPPORTED /* Write an iTXt chunk */ void /* PRIVATE */ png_write_iTXt(png_structp png_ptr, int compression, png_charp key, png_charp lang, png_charp lang_key, png_charp text) @@ -1529,9 +1529,9 @@ png_free(png_ptr, new_lang); } #endif -#if defined(PNG_WRITE_oFFs_SUPPORTED) +#ifdef PNG_WRITE_oFFs_SUPPORTED /* Write the oFFs chunk */ void /* PRIVATE */ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, int unit_type) @@ -1552,9 +1552,9 @@ png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); } #endif -#if defined(PNG_WRITE_pCAL_SUPPORTED) +#ifdef PNG_WRITE_pCAL_SUPPORTED /* Write the pCAL chunk (described in the PNG extensions document) */ void /* PRIVATE */ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) @@ -1615,9 +1615,9 @@ png_write_chunk_end(png_ptr); } #endif -#if defined(PNG_WRITE_sCAL_SUPPORTED) +#ifdef PNG_WRITE_sCAL_SUPPORTED /* Write the sCAL chunk */ #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) void /* PRIVATE */ png_write_sCAL(png_structp png_ptr, int unit, double width, double height) @@ -1630,9 +1630,9 @@ png_debug(1, "in png_write_sCAL"); buf[0] = (char)unit; -#if defined(_WIN32_WCE) +#ifdef _WIN32_WCE /* sprintf() function is not supported on WindowsCE */ { wchar_t wc_buf[32]; size_t wc_len; @@ -1689,9 +1689,9 @@ #endif #endif #endif -#if defined(PNG_WRITE_pHYs_SUPPORTED) +#ifdef PNG_WRITE_pHYs_SUPPORTED /* Write the pHYs chunk */ void /* PRIVATE */ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, @@ -1714,9 +1714,9 @@ png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9); } #endif -#if defined(PNG_WRITE_tIME_SUPPORTED) +#ifdef PNG_WRITE_tIME_SUPPORTED /* Write the tIME chunk. Use either png_convert_from_struct_tm() * or png_convert_from_time_t(), or fill in the structure yourself. */ void /* PRIVATE */ @@ -1752,9 +1752,8 @@ void /* PRIVATE */ png_write_start_row(png_structp png_ptr) { #ifdef PNG_WRITE_INTERLACING_SUPPORTED -#ifdef PNG_USE_LOCAL_ARRAYS /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Start of interlace block */ int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; @@ -1767,9 +1766,8 @@ /* Offset to next interlace block in the y direction */ int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif -#endif png_size_t buf_size; png_debug(1, "in png_write_start_row"); @@ -1819,9 +1817,9 @@ (png_uint_32)(png_ptr->rowbytes + 1)); png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; } } -#endif /* PNG_NO_WRITE_FILTER */ +#endif /* PNG_WRITE_FILTER_SUPPORTED */ #ifdef PNG_WRITE_INTERLACING_SUPPORTED /* If interlaced, we need to set up width and height of pass */ if (png_ptr->interlaced) @@ -1853,9 +1851,8 @@ void /* PRIVATE */ png_write_finish_row(png_structp png_ptr) { #ifdef PNG_WRITE_INTERLACING_SUPPORTED -#ifdef PNG_USE_LOCAL_ARRAYS /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Start of interlace block */ int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; @@ -1868,9 +1865,8 @@ /* Offset to next interlace block in the y direction */ int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif -#endif int ret; png_debug(1, "in png_write_finish_row"); @@ -1961,9 +1957,9 @@ deflateReset(&png_ptr->zstream); png_ptr->zstream.data_type = Z_BINARY; } -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +#ifdef PNG_WRITE_INTERLACING_SUPPORTED /* Pick out the correct pixels for the interlace pass. * The basic idea here is to go through the row with a source * pointer and a destination pointer (sp and dp), and copy the * correct pixels for the pass. As the row gets compacted, @@ -1972,22 +1968,20 @@ */ void /* PRIVATE */ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) { -#ifdef PNG_USE_LOCAL_ARRAYS /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Start of interlace block */ int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; /* Offset to next interlace block */ int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; -#endif png_debug(1, "in png_do_write_interlace"); /* We don't have to do anything on the last pass (6) */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) +#ifdef PNG_USELESS_TESTS_SUPPORTED if (row != NULL && row_info != NULL && pass < 6) #else if (pass < 6) #endif @@ -2205,9 +2199,9 @@ v = *rp; sum += (v < 128) ? v : 256 - v; } -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { png_uint_32 sumhi, sumlo; int j; @@ -2269,9 +2263,9 @@ png_uint_32 sum = 0, lmins = mins; png_uint_32 i; int v; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* We temporarily increase the "minimum sum" by the factor we * would reduce the sum of this filter, so that we can do the * early exit comparison without scaling the sum each time. */ @@ -2322,9 +2316,9 @@ if (sum > lmins) /* We are already worse, don't continue. */ break; } -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; png_uint_32 sumhi, sumlo; @@ -2383,9 +2377,9 @@ png_uint_32 i; int v; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; png_uint_32 lmhi, lmlo; @@ -2425,9 +2419,9 @@ if (sum > lmins) /* We are already worse, don't continue. */ break; } -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; png_uint_32 sumhi, sumlo; @@ -2488,9 +2482,9 @@ png_uint_32 sum = 0, lmins = mins; png_uint_32 i; int v; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; png_uint_32 lmhi, lmlo; @@ -2537,9 +2531,9 @@ if (sum > lmins) /* We are already worse, don't continue. */ break; } -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; png_uint_32 sumhi, sumlo; @@ -2621,9 +2615,9 @@ png_uint_32 sum = 0, lmins = mins; png_uint_32 i; int v; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; png_uint_32 lmhi, lmlo; @@ -2702,9 +2696,9 @@ if (sum > lmins) /* We are already worse, don't continue. */ break; } -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { int j; png_uint_32 sumhi, sumlo; @@ -2738,15 +2732,15 @@ { best_row = png_ptr->paeth_row; } } -#endif /* PNG_NO_WRITE_FILTER */ +#endif /* PNG_WRITE_FILTER_SUPPORTED */ /* Do the actual writing of the filtered row data from the chosen filter. */ png_write_filtered_row(png_ptr, best_row); #ifndef PNG_NO_WRITE_FILTER -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* Save the type of filter we picked this time for future calculations */ if (png_ptr->num_prev_filters > 0) { int j; @@ -2756,9 +2750,9 @@ } png_ptr->prev_filters[j] = best_row[0]; } #endif -#endif /* PNG_NO_WRITE_FILTER */ +#endif /* PNG_WRITE_FILTER_SUPPORTED */ } /* Do the actual writing of a previously filtered row. */ @@ -2811,9 +2805,9 @@ /* Finish row - updates counters and flushes zlib if last row */ png_write_finish_row(png_ptr); -#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#ifdef PNG_WRITE_FLUSH_SUPPORTED png_ptr->flush_rows++; if (png_ptr->flush_dist > 0 && png_ptr->flush_rows >= png_ptr->flush_dist) diff -ru4NwbB libpng-1.2.40/projects/xcode/Info.plist libpng-1.2.41beta05/projects/xcode/Info.plist --- libpng-1.2.40/projects/xcode/Info.plist 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.2.41beta05/projects/xcode/Info.plist 2009-10-02 10:01:15.000000000 -0500 @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + libpng + CFBundleIconFile + + CFBundleIdentifier + com.apple.carbonframeworktemplate + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + 1.0 + CFBundleShortVersionString + 1.0 + CSResourcesFileMapped + + + diff -ru4NwbB libpng-1.2.40/projects/xcode/libpng.xcodeproj/.gitignore libpng-1.2.41beta05/projects/xcode/libpng.xcodeproj/.gitignore --- libpng-1.2.40/projects/xcode/libpng.xcodeproj/.gitignore 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.2.41beta05/projects/xcode/libpng.xcodeproj/.gitignore 2009-10-02 10:01:15.000000000 -0500 @@ -0,0 +1,2 @@ +*.mode1* +*.pbxuser diff -ru4NwbB libpng-1.2.40/projects/xcode/libpng.xcodeproj/project.pbxproj libpng-1.2.41beta05/projects/xcode/libpng.xcodeproj/project.pbxproj --- libpng-1.2.40/projects/xcode/libpng.xcodeproj/project.pbxproj 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.2.41beta05/projects/xcode/libpng.xcodeproj/project.pbxproj 2009-10-17 18:49:30.259565708 -0500 @@ -0,0 +1,349 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 44; + objects = { + +/* Begin PBXBuildFile section */ + 14461C7109C3C37F005840C0 /* png.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C5D09C3C37F005840C0 /* png.c */; }; + 14461C7209C3C37F005840C0 /* png.h in Headers */ = {isa = PBXBuildFile; fileRef = 14461C5E09C3C37F005840C0 /* png.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 14461C7309C3C37F005840C0 /* pngconf.h in Headers */ = {isa = PBXBuildFile; fileRef = 14461C5F09C3C37F005840C0 /* pngconf.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 14461C7409C3C37F005840C0 /* pngerror.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6009C3C37F005840C0 /* pngerror.c */; }; + 14461C7509C3C37F005840C0 /* pnggccrd.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6109C3C37F005840C0 /* pnggccrd.c */; }; + 14461C7609C3C37F005840C0 /* pngget.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6209C3C37F005840C0 /* pngget.c */; }; + 14461C7709C3C37F005840C0 /* pngmem.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6309C3C37F005840C0 /* pngmem.c */; }; + 14461C7809C3C37F005840C0 /* pngpread.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6409C3C37F005840C0 /* pngpread.c */; }; + 14461C7909C3C37F005840C0 /* pngread.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6509C3C37F005840C0 /* pngread.c */; }; + 14461C7A09C3C37F005840C0 /* pngrio.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6609C3C37F005840C0 /* pngrio.c */; }; + 14461C7B09C3C37F005840C0 /* pngrtran.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6709C3C37F005840C0 /* pngrtran.c */; }; + 14461C7C09C3C37F005840C0 /* pngrutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6809C3C37F005840C0 /* pngrutil.c */; }; + 14461C7D09C3C37F005840C0 /* pngset.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6909C3C37F005840C0 /* pngset.c */; }; + 14461C7F09C3C37F005840C0 /* pngtrans.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6B09C3C37F005840C0 /* pngtrans.c */; }; + 14461C8009C3C37F005840C0 /* pngvcrd.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6C09C3C37F005840C0 /* pngvcrd.c */; }; + 14461C8109C3C37F005840C0 /* pngwio.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6D09C3C37F005840C0 /* pngwio.c */; }; + 14461C8209C3C37F005840C0 /* pngwrite.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6E09C3C37F005840C0 /* pngwrite.c */; }; + 14461C8309C3C37F005840C0 /* pngwtran.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6F09C3C37F005840C0 /* pngwtran.c */; }; + 14461C8409C3C37F005840C0 /* pngwutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C7009C3C37F005840C0 /* pngwutil.c */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 14461C5D09C3C37F005840C0 /* png.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = png.c; path = ../../png.c; sourceTree = SOURCE_ROOT; }; + 14461C5E09C3C37F005840C0 /* png.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = png.h; path = ../../png.h; sourceTree = SOURCE_ROOT; }; + 14461C5F09C3C37F005840C0 /* pngconf.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pngconf.h; path = ../../pngconf.h; sourceTree = SOURCE_ROOT; }; + 14461C6009C3C37F005840C0 /* pngerror.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngerror.c; path = ../../pngerror.c; sourceTree = SOURCE_ROOT; }; + 14461C6109C3C37F005840C0 /* pnggccrd.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pnggccrd.c; path = ../../pnggccrd.c; sourceTree = SOURCE_ROOT; }; + 14461C6209C3C37F005840C0 /* pngget.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngget.c; path = ../../pngget.c; sourceTree = SOURCE_ROOT; }; + 14461C6309C3C37F005840C0 /* pngmem.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngmem.c; path = ../../pngmem.c; sourceTree = SOURCE_ROOT; }; + 14461C6409C3C37F005840C0 /* pngpread.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngpread.c; path = ../../pngpread.c; sourceTree = SOURCE_ROOT; }; + 14461C6509C3C37F005840C0 /* pngread.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngread.c; path = ../../pngread.c; sourceTree = SOURCE_ROOT; }; + 14461C6609C3C37F005840C0 /* pngrio.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngrio.c; path = ../../pngrio.c; sourceTree = SOURCE_ROOT; }; + 14461C6709C3C37F005840C0 /* pngrtran.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngrtran.c; path = ../../pngrtran.c; sourceTree = SOURCE_ROOT; }; + 14461C6809C3C37F005840C0 /* pngrutil.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngrutil.c; path = ../../pngrutil.c; sourceTree = SOURCE_ROOT; }; + 14461C6909C3C37F005840C0 /* pngset.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngset.c; path = ../../pngset.c; sourceTree = SOURCE_ROOT; }; + 14461C6B09C3C37F005840C0 /* pngtrans.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngtrans.c; path = ../../pngtrans.c; sourceTree = SOURCE_ROOT; }; + 14461C6C09C3C37F005840C0 /* pngvcrd.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngvcrd.c; path = ../../pngvcrd.c; sourceTree = SOURCE_ROOT; }; + 14461C6D09C3C37F005840C0 /* pngwio.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwio.c; path = ../../pngwio.c; sourceTree = SOURCE_ROOT; }; + 14461C6E09C3C37F005840C0 /* pngwrite.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwrite.c; path = ../../pngwrite.c; sourceTree = SOURCE_ROOT; }; + 14461C6F09C3C37F005840C0 /* pngwtran.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwtran.c; path = ../../pngwtran.c; sourceTree = SOURCE_ROOT; }; + 14461C7009C3C37F005840C0 /* pngwutil.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwutil.c; path = ../../pngwutil.c; sourceTree = SOURCE_ROOT; }; + 8D07F2C70486CC7A007CD1D0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; + 8D07F2C80486CC7A007CD1D0 /* libpng.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = libpng.framework; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D07F2C30486CC7A007CD1D0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 034768DDFF38A45A11DB9C8B /* Products */ = { + isa = PBXGroup; + children = ( + 8D07F2C80486CC7A007CD1D0 /* libpng.framework */, + ); + name = Products; + sourceTree = ""; + }; + 0867D691FE84028FC02AAC07 /* libpng */ = { + isa = PBXGroup; + children = ( + 08FB77ACFE841707C02AAC07 /* Source */, + 089C1665FE841158C02AAC07 /* Resources */, + 034768DDFF38A45A11DB9C8B /* Products */, + ); + name = libpng; + sourceTree = ""; + }; + 089C1665FE841158C02AAC07 /* Resources */ = { + isa = PBXGroup; + children = ( + 8D07F2C70486CC7A007CD1D0 /* Info.plist */, + ); + name = Resources; + sourceTree = ""; + }; + 08FB77ACFE841707C02AAC07 /* Source */ = { + isa = PBXGroup; + children = ( + 14461C5D09C3C37F005840C0 /* png.c */, + 14461C5E09C3C37F005840C0 /* png.h */, + 14461C5F09C3C37F005840C0 /* pngconf.h */, + 14461C6009C3C37F005840C0 /* pngerror.c */, + 14461C6109C3C37F005840C0 /* pnggccrd.c */, + 14461C6209C3C37F005840C0 /* pngget.c */, + 14461C6309C3C37F005840C0 /* pngmem.c */, + 14461C6409C3C37F005840C0 /* pngpread.c */, + 14461C6509C3C37F005840C0 /* pngread.c */, + 14461C6609C3C37F005840C0 /* pngrio.c */, + 14461C6709C3C37F005840C0 /* pngrtran.c */, + 14461C6809C3C37F005840C0 /* pngrutil.c */, + 14461C6909C3C37F005840C0 /* pngset.c */, + 14461C6B09C3C37F005840C0 /* pngtrans.c */, + 14461C6C09C3C37F005840C0 /* pngvcrd.c */, + 14461C6D09C3C37F005840C0 /* pngwio.c */, + 14461C6E09C3C37F005840C0 /* pngwrite.c */, + 14461C6F09C3C37F005840C0 /* pngwtran.c */, + 14461C7009C3C37F005840C0 /* pngwutil.c */, + ); + name = Source; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 8D07F2BD0486CC7A007CD1D0 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 14461C7209C3C37F005840C0 /* png.h in Headers */, + 14461C7309C3C37F005840C0 /* pngconf.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 8D07F2BC0486CC7A007CD1D0 /* libpng */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget "libpng" */; + buildPhases = ( + 8D07F2BD0486CC7A007CD1D0 /* Headers */, + 8D07F2BF0486CC7A007CD1D0 /* Resources */, + 8D07F2C10486CC7A007CD1D0 /* Sources */, + 8D07F2C30486CC7A007CD1D0 /* Frameworks */, + 8D07F2C50486CC7A007CD1D0 /* Rez */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = libpng; + productInstallPath = "$(HOME)/Library/Frameworks"; + productName = libpng; + productReference = 8D07F2C80486CC7A007CD1D0 /* libpng.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0867D690FE84028FC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject "libpng" */; + compatibilityVersion = "Xcode 2.4"; + hasScannedForEncodings = 1; + mainGroup = 0867D691FE84028FC02AAC07 /* libpng */; + productRefGroup = 034768DDFF38A45A11DB9C8B /* Products */; + projectDirPath = ""; + projectRoot = ../..; + targets = ( + 8D07F2BC0486CC7A007CD1D0 /* libpng */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D07F2BF0486CC7A007CD1D0 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXRezBuildPhase section */ + 8D07F2C50486CC7A007CD1D0 /* Rez */ = { + isa = PBXRezBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXRezBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D07F2C10486CC7A007CD1D0 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 14461C7109C3C37F005840C0 /* png.c in Sources */, + 14461C7409C3C37F005840C0 /* pngerror.c in Sources */, + 14461C7509C3C37F005840C0 /* pnggccrd.c in Sources */, + 14461C7609C3C37F005840C0 /* pngget.c in Sources */, + 14461C7709C3C37F005840C0 /* pngmem.c in Sources */, + 14461C7809C3C37F005840C0 /* pngpread.c in Sources */, + 14461C7909C3C37F005840C0 /* pngread.c in Sources */, + 14461C7A09C3C37F005840C0 /* pngrio.c in Sources */, + 14461C7B09C3C37F005840C0 /* pngrtran.c in Sources */, + 14461C7C09C3C37F005840C0 /* pngrutil.c in Sources */, + 14461C7D09C3C37F005840C0 /* pngset.c in Sources */, + 14461C7F09C3C37F005840C0 /* pngtrans.c in Sources */, + 14461C8009C3C37F005840C0 /* pngvcrd.c in Sources */, + 14461C8109C3C37F005840C0 /* pngwio.c in Sources */, + 14461C8209C3C37F005840C0 /* pngwrite.c in Sources */, + 14461C8309C3C37F005840C0 /* pngwtran.c in Sources */, + 14461C8409C3C37F005840C0 /* pngwutil.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 4FADC24308B4156D00ABE55E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + DYLIB_COMPATIBILITY_VERSION = 3; + DYLIB_CURRENT_VERSION = 3; + FRAMEWORK_VERSION = 1.2.41beta05; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "@executable_path/../Frameworks"; + LIBRARY_STYLE = DYNAMIC; + MACH_O_TYPE = mh_dylib; + OTHER_LDFLAGS = "-lz"; + PRODUCT_NAME = libpng; + WRAPPER_EXTENSION = framework; + }; + name = Debug; + }; + 4FADC24408B4156D00ABE55E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DYLIB_COMPATIBILITY_VERSION = 3; + DYLIB_CURRENT_VERSION = 3; + FRAMEWORK_VERSION = 1.2.41beta05; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "@executable_path/../Frameworks"; + LIBRARY_STYLE = DYNAMIC; + MACH_O_TYPE = mh_dylib; + OTHER_LDFLAGS = "-lz"; + PRODUCT_NAME = libpng; + WRAPPER_EXTENSION = framework; + }; + name = Release; + }; + 4FADC24708B4156D00ABE55E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + i386, + ppc, + ppc64, + x86_64, + ); + DEPLOYMENT_POSTPROCESSING = YES; + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_VERSION_i386 = 4.0; + GCC_VERSION_ppc = 3.3; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.5; + "MACOSX_DEPLOYMENT_TARGET[arch=i386]" = 10.4; + "MACOSX_DEPLOYMENT_TARGET[arch=ppc]" = 10.2; + MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; + MACOSX_DEPLOYMENT_TARGET_ppc = 10.2; + PREBINDING = NO; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; + "SDKROOT[arch=i386]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + "SDKROOT[arch=ppc]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; + SDKROOT_i386 = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + SDKROOT_ppc = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; + ZERO_LINK = NO; + }; + name = Debug; + }; + 4FADC24808B4156D00ABE55E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + i386, + ppc, + ppc64, + x86_64, + ); + GCC_ENABLE_CPP_EXCEPTIONS = NO; + GCC_ENABLE_CPP_RTTI = NO; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_OPTIMIZATION_LEVEL = 2; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_VERSION_i386 = 4.0; + GCC_VERSION_ppc = 3.3; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.5; + "MACOSX_DEPLOYMENT_TARGET[arch=i386]" = 10.4; + "MACOSX_DEPLOYMENT_TARGET[arch=ppc]" = 10.2; + MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; + MACOSX_DEPLOYMENT_TARGET_ppc = 10.2; + PREBINDING = NO; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; + "SDKROOT[arch=i386]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + "SDKROOT[arch=ppc]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; + SDKROOT_i386 = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; + SDKROOT_ppc = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; + ZERO_LINK = NO; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget "libpng" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4FADC24308B4156D00ABE55E /* Debug */, + 4FADC24408B4156D00ABE55E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject "libpng" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4FADC24708B4156D00ABE55E /* Debug */, + 4FADC24808B4156D00ABE55E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0867D690FE84028FC02AAC07 /* Project object */; +}