diff --git a/ANNOUNCE b/ANNOUNCE index 6943ee3f..5a2ef0b0 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.2.41beta04 - October 2, 2009 +Libpng 1.2.41beta04 - October 5, 2009 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -55,8 +55,9 @@ version 1.2.41beta03 [October 1, 2009] Revised png_check_IHDR() again, to check info_ptr members instead of the contents of the returned parameters. -version 1.2.41beta04 [October 2, 2009] +version 1.2.41beta04 [October 5, 2009] Added "xcode" project similar one already in libpng-1.4.0beta (Alam Arias). + Ported some cosmetic changes from libpng-1.4.0beta86. Send comments/corrections/commendations to png-mng-implement at lists.sf.net diff --git a/CHANGES b/CHANGES index 5ff0319c..8c01d138 100644 --- a/CHANGES +++ b/CHANGES @@ -2466,7 +2466,7 @@ version 1.2.40beta01 [August 20, 2009] version 1.2.40rc01 [September 2, 2009] Various bugfixes and improvements to CMakeLists.txt (Philip Lowman) -version 1.2.40 and 1.0.49 [October 2, 2009] +version 1.2.40 and 1.0.49 [October 5, 2009] No changes. version 1.0.50 [September 10, 2009] @@ -2485,8 +2485,9 @@ version 1.2.41beta03 [October 1, 2009] Revised png_check_IHDR() again, to check info_ptr members instead of the contents of the returned parameters. -version 1.2.41beta04 [October 2, 2009] +version 1.2.41beta04 [October 5, 2009] Added "xcode" project similar one already in libpng-1.4.0beta (Alam Arias). + Ported some cosmetic changes from libpng-1.4.0beta86. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pnggccrd.c b/pnggccrd.c index e61523e7..78b8a7e4 100644 --- a/pnggccrd.c +++ b/pnggccrd.c @@ -17,9 +17,9 @@ 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) @@ -71,7 +71,7 @@ png_dummy_mmx_support(void) "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 diff --git a/pngget.c b/pngget.c index ceac98f5..e3c61f9f 100644 --- a/pngget.c +++ b/pngget.c @@ -1,7 +1,7 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.2.41 [October 2, 2009] + * Last changed in libpng 1.2.41 [October 5, 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.) @@ -36,7 +36,7 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) 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) { @@ -117,7 +117,7 @@ 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"); @@ -138,7 +138,7 @@ 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"); @@ -159,7 +159,7 @@ 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"); @@ -182,13 +182,15 @@ 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"); + if (info_ptr->x_pixels_per_unit == 0) return ((float)0.0); + else return ((float)((float)info_ptr->y_pixels_per_unit /(float)info_ptr->x_pixels_per_unit)); @@ -204,7 +206,7 @@ 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) { @@ -227,7 +229,7 @@ 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"); @@ -249,7 +251,7 @@ 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"); @@ -271,7 +273,7 @@ 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"); @@ -324,7 +326,7 @@ png_get_y_offset_inches(png_structp png_ptr, png_infop 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) @@ -334,6 +336,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, 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; @@ -382,7 +385,7 @@ png_get_signature(png_structp png_ptr, png_infop info_ptr) 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) @@ -391,6 +394,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr, && background != NULL) { png_debug1(1, "in %s retrieval function", "bKGD"); + *background = &(info_ptr->background); return (PNG_INFO_bKGD); } @@ -398,7 +402,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr, } #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, @@ -408,6 +412,7 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr, 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 = (double)info_ptr->x_white; if (white_y != NULL) @@ -436,9 +441,10 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, 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) @@ -462,15 +468,16 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, #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); } @@ -482,10 +489,11 @@ 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); } @@ -494,14 +502,15 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, #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); } @@ -509,16 +518,17 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) } #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 @@ -532,7 +542,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr, } #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) @@ -546,14 +556,15 @@ png_get_sPLT(png_structp png_ptr, png_infop info_ptr, } #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); } @@ -566,6 +577,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_type, int *compression_type, int *filter_type) + { png_debug1(1, "in %s retrieval function", "IHDR"); @@ -599,15 +611,16 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr, return (1); } -#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; @@ -617,17 +630,18 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr, } #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; @@ -641,7 +655,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr, } #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, @@ -677,18 +691,18 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, #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; @@ -715,10 +729,11 @@ 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); @@ -727,14 +742,15 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, 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); } @@ -742,7 +758,7 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) } #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) @@ -767,14 +783,15 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, } #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); } @@ -782,7 +799,7 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) } #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) @@ -791,6 +808,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr, if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { png_debug1(1, "in %s retrieval function", "tRNS"); + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (trans != NULL) @@ -823,7 +841,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr, } #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) @@ -837,7 +855,7 @@ png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, } #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) { @@ -845,7 +863,7 @@ png_get_rgb_to_gray_status (png_structp png_ptr) } #endif -#if defined(PNG_USER_CHUNKS_SUPPORTED) +#ifdef PNG_USER_CHUNKS_SUPPORTED png_voidp PNGAPI png_get_user_chunk_ptr(png_structp png_ptr) { diff --git a/pngrio.c b/pngrio.c index 2267bca9..37d072cc 100644 --- a/pngrio.c +++ b/pngrio.c @@ -1,7 +1,7 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.2.37 [June 4, 2009] + * Last changed in libpng 1.2.41 [October 5, 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.) @@ -20,7 +20,7 @@ #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 @@ -32,13 +32,14 @@ void /* PRIVATE */ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_debug1(4, "reading %d bytes", (int)length); + if (png_ptr->read_data_fn != NULL) (*(png_ptr->read_data_fn))(png_ptr, data, length); else png_error(png_ptr, "Call to NULL read function"); } -#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 @@ -55,7 +56,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) /* 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 @@ -89,7 +90,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) 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 @@ -105,7 +106,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t 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 @@ -151,7 +152,7 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, 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 @@ -170,7 +171,7 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_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 } diff --git a/pngset.c b/pngset.c index e9b292e6..e72f4459 100644 --- a/pngset.c +++ b/pngset.c @@ -1,7 +1,7 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.2.41 [October 2, 2009] + * Last changed in libpng 1.2.41 [October 5, 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.) @@ -20,7 +20,7 @@ #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) { @@ -34,7 +34,7 @@ png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) } #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, @@ -80,7 +80,7 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, 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 @@ -109,7 +109,7 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, #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) @@ -176,7 +176,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point } #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) { @@ -267,7 +267,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr, 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) @@ -284,7 +284,7 @@ png_set_oFFs(png_structp png_ptr, png_infop info_ptr, } #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, @@ -423,7 +423,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, #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) @@ -491,7 +491,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr, 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) @@ -506,7 +506,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr, } #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) { @@ -523,7 +523,7 @@ 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 @@ -531,7 +531,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, 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 @@ -545,7 +545,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, 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); @@ -556,7 +556,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, #endif #endif -#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_cHRM_SUPPORTED int_white_x = 31270L; int_white_y = 32900L; int_red_x = 64000L; @@ -591,7 +591,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, #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, @@ -639,7 +639,7 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr, } #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) @@ -812,7 +812,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, } #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) { @@ -827,7 +827,7 @@ png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_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) @@ -886,7 +886,7 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr, } #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) @@ -1050,7 +1050,7 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) #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) { @@ -1064,7 +1064,7 @@ png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) } #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) @@ -1111,7 +1111,7 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep } #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) @@ -1126,7 +1126,7 @@ png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp 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) { diff --git a/pngtrans.c b/pngtrans.c index 6e1870c5..bb88ad25 100644 --- a/pngtrans.c +++ b/pngtrans.c @@ -1,7 +1,7 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.2.36 [May 14, 2009] + * Last changed in libpng 1.2.41 [October 5, 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.) @@ -21,6 +21,7 @@ void PNGAPI png_set_bgr(png_structp png_ptr) { png_debug(1, "in png_set_bgr"); + if (png_ptr == NULL) return; png_ptr->transformations |= PNG_BGR; @@ -33,6 +34,7 @@ void PNGAPI png_set_swap(png_structp png_ptr) { png_debug(1, "in png_set_swap"); + if (png_ptr == NULL) return; if (png_ptr->bit_depth == 16) @@ -46,6 +48,7 @@ void PNGAPI png_set_packing(png_structp png_ptr) { png_debug(1, "in png_set_packing"); + if (png_ptr == NULL) return; if (png_ptr->bit_depth < 8) @@ -62,6 +65,7 @@ void PNGAPI png_set_packswap(png_structp png_ptr) { png_debug(1, "in png_set_packswap"); + if (png_ptr == NULL) return; if (png_ptr->bit_depth < 8) @@ -74,6 +78,7 @@ void PNGAPI png_set_shift(png_structp png_ptr, png_color_8p true_bits) { png_debug(1, "in png_set_shift"); + if (png_ptr == NULL) return; png_ptr->transformations |= PNG_SHIFT; @@ -87,6 +92,7 @@ int PNGAPI png_set_interlace_handling(png_structp png_ptr) { png_debug(1, "in png_set_interlace handling"); + if (png_ptr && png_ptr->interlaced) { png_ptr->transformations |= PNG_INTERLACE; @@ -107,10 +113,15 @@ void PNGAPI png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) { png_debug(1, "in png_set_filler"); + if (png_ptr == NULL) return; png_ptr->transformations |= 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 @@ -135,12 +146,13 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) } } -#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) { png_debug(1, "in png_set_add_alpha"); + if (png_ptr == NULL) return; png_set_filler(png_ptr, filler, filler_loc); @@ -156,6 +168,7 @@ void PNGAPI png_set_swap_alpha(png_structp png_ptr) { png_debug(1, "in png_set_swap_alpha"); + if (png_ptr == NULL) return; png_ptr->transformations |= PNG_SWAP_ALPHA; @@ -168,6 +181,7 @@ void PNGAPI png_set_invert_alpha(png_structp png_ptr) { png_debug(1, "in png_set_invert_alpha"); + if (png_ptr == NULL) return; png_ptr->transformations |= PNG_INVERT_ALPHA; @@ -179,6 +193,7 @@ void PNGAPI png_set_invert_mono(png_structp png_ptr) { png_debug(1, "in png_set_invert_mono"); + if (png_ptr == NULL) return; png_ptr->transformations |= PNG_INVERT_MONO; @@ -189,10 +204,11 @@ 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 @@ -244,8 +260,9 @@ 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) @@ -375,8 +392,9 @@ 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) @@ -407,7 +425,8 @@ 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 { @@ -565,8 +584,9 @@ 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)) @@ -644,9 +664,10 @@ 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; @@ -668,7 +689,7 @@ 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); diff --git a/pngwio.c b/pngwio.c index f77b2dbd..c89118db 100644 --- a/pngwio.c +++ b/pngwio.c @@ -1,7 +1,7 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.2.37 [June 4, 2009] + * Last changed in libpng 1.2.41 [October 5, 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.) @@ -38,7 +38,7 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) 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 @@ -52,7 +52,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) 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 @@ -84,7 +84,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) 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 @@ -101,7 +101,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { 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 @@ -129,7 +129,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) * 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) { @@ -137,16 +137,16 @@ png_flush(png_structp png_ptr) (*(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 @@ -192,7 +192,7 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, 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; @@ -202,8 +202,8 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, 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; @@ -225,8 +225,8 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, } } -#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; diff --git a/pngwtran.c b/pngwtran.c index 88a7d3cb..1c490a78 100644 --- a/pngwtran.c +++ b/pngwtran.c @@ -1,7 +1,7 @@ /* 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 5, 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.) @@ -26,7 +26,7 @@ png_do_write_transformations(png_structp png_ptr) 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 */ @@ -40,48 +40,48 @@ png_do_write_transformations(png_structp png_ptr) /* 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). @@ -90,8 +90,9 @@ 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) @@ -204,7 +205,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) } #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 @@ -216,7 +217,8 @@ 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 ( @@ -335,12 +337,13 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) } #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 { @@ -423,12 +426,13 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) } #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 { @@ -512,14 +516,15 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) } #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) { 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))