[devel] Made use of whitespace around debug statements consistent.

This commit is contained in:
Glenn Randers-Pehrson 2009-08-15 13:25:47 -05:00
parent 951028949c
commit da00980433
17 changed files with 168 additions and 30 deletions

View File

@ -2,7 +2,7 @@
#if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 2009]
* This file has been placed in the public domain by the authors.
* Maintained 1998-2009 Glenn Randers-Pehrson
* Maintained 1996, 1997 Andreas Dilger)

14
png.c
View File

@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)
@ -97,7 +97,9 @@ png_set_sig_bytes(png_structp png_ptr, int num_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");
@ -212,6 +214,7 @@ png_create_info_struct(png_structp png_ptr)
png_infop info_ptr;
png_debug(1, "in png_create_info_struct");
if (png_ptr == NULL)
return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED
@ -239,6 +242,7 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
return;
png_debug(1, "in png_destroy_info_struct");
if (info_ptr_ptr != NULL)
info_ptr = *info_ptr_ptr;
@ -288,6 +292,7 @@ png_data_freer(png_structp png_ptr, png_infop info_ptr,
int freer, png_uint_32 mask)
{
png_debug(1, "in png_data_freer");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (freer == PNG_DESTROY_WILL_FREE_DATA)
@ -305,6 +310,7 @@ 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;
@ -596,6 +602,7 @@ void PNGAPI
png_init_io(png_structp png_ptr, png_FILE_p fp)
{
png_debug(1, "in png_init_io");
if (png_ptr == NULL)
return;
png_ptr->io_ptr = (png_voidp)fp;
@ -652,13 +659,13 @@ png_get_copyright(png_structp png_ptr)
#else
#ifdef __STDC__
return ((png_charp) PNG_STRING_NEWLINE \
"libpng version x 1.4.0beta75 - August 13, 2009" PNG_STRING_NEWLINE \
"libpng version x 1.4.0beta75 - August 15, 2009" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2009 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE);
#else
return ((png_charp) "libpng version 1.4.0beta75 - August 13, 2009\
return ((png_charp) "libpng version 1.4.0beta75 - August 15, 2009\
Copyright (c) 1998-2009 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");
@ -811,6 +818,7 @@ png_check_cHRM_fixed(png_structp png_ptr,
unsigned long xy_hi,xy_lo,yx_hi,yx_lo;
png_debug(1, "in function png_check_cHRM_fixed");
if (png_ptr == NULL)
return 0;

View File

@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)

View File

@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)
@ -187,6 +187,7 @@ png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
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
@ -334,6 +335,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;
@ -391,6 +393,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);
}
@ -408,6 +411,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)
@ -439,6 +443,7 @@ png_get_cHRM_fixed(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 = info_ptr->int_x_white;
if (white_y != NULL)
@ -471,6 +476,7 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
&& file_gamma != NULL)
{
png_debug1(1, "in %s retrieval function", "gAMA");
*file_gamma = (double)info_ptr->gamma;
return (PNG_INFO_gAMA);
}
@ -486,6 +492,7 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
&& int_file_gamma != NULL)
{
png_debug1(1, "in %s retrieval function", "gAMA");
*int_file_gamma = info_ptr->int_gamma;
return (PNG_INFO_gAMA);
}
@ -502,6 +509,7 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
&& file_srgb_intent != NULL)
{
png_debug1(1, "in %s retrieval function", "sRGB");
*file_srgb_intent = (int)info_ptr->srgb_intent;
return (PNG_INFO_sRGB);
}
@ -519,6 +527,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
&& 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
@ -554,6 +563,7 @@ png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
&& hist != NULL)
{
png_debug1(1, "in %s retrieval function", "hIST");
*hist = info_ptr->hist;
return (PNG_INFO_hIST);
}
@ -572,6 +582,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
bit_depth != NULL && color_type != NULL)
{
png_debug1(1, "in %s retrieval function", "IHDR");
*width = info_ptr->width;
*height = info_ptr->height;
*bit_depth = info_ptr->bit_depth;
@ -624,6 +635,7 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
&& 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;
@ -644,6 +656,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
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;
@ -735,6 +748,7 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
&& 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);
@ -751,6 +765,7 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
&& sig_bit != NULL)
{
png_debug1(1, "in %s retrieval function", "sBIT");
*sig_bit = &(info_ptr->sig_bit);
return (PNG_INFO_sBIT);
}
@ -791,6 +806,7 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
&& mod_time != NULL)
{
png_debug1(1, "in %s retrieval function", "tIME");
*mod_time = &(info_ptr->mod_time);
return (PNG_INFO_tIME);
}
@ -807,6 +823,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_alpha != NULL)

View File

@ -1,7 +1,7 @@
/* pngmem.c - stub functions for memory allocation
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)

View File

@ -1,7 +1,7 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)

View File

@ -1,7 +1,7 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)
@ -53,6 +53,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
int i;
png_debug(1, "in png_create_read_struct");
#ifdef PNG_USER_MEM_SUPPORTED
png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
malloc_fn, mem_ptr);
@ -200,7 +201,9 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
{
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)
{
@ -411,6 +414,7 @@ void PNGAPI
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_read_update_info");
if (png_ptr == NULL)
return;
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
@ -431,6 +435,7 @@ void PNGAPI
png_start_read_image(png_structp png_ptr)
{
png_debug(1, "in png_start_read_image");
if (png_ptr == NULL)
return;
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
@ -451,7 +456,9 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
int ret;
if (png_ptr == NULL)
return;
png_debug2(1, "in png_read_row (row %lu, pass %d)",
(unsigned long) png_ptr->row_number, png_ptr->pass);
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
png_read_start_row(png_ptr);
@ -702,6 +709,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
png_bytepp dp;
png_debug(1, "in png_read_rows");
if (png_ptr == NULL)
return;
rp = row;
@ -752,6 +760,7 @@ png_read_image(png_structp png_ptr, png_bytepp image)
png_bytepp rp;
png_debug(1, "in png_read_image");
if (png_ptr == NULL)
return;
@ -789,6 +798,7 @@ void PNGAPI
png_read_end(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_read_end");
if (png_ptr == NULL)
return;
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
@ -970,6 +980,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
#endif
png_debug(1, "in png_destroy_read_struct");
if (png_ptr_ptr != NULL)
png_ptr = *png_ptr_ptr;
if (png_ptr == NULL)
@ -1044,6 +1055,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
#endif
png_debug(1, "in png_read_destroy");
if (info_ptr != NULL)
png_info_destroy(png_ptr, info_ptr);

View File

@ -1,7 +1,7 @@
/* pngrio.c - functions for data input
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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,6 +32,7 @@ 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

View File

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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,11 @@ 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 */
@ -55,6 +57,7 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
break;
}
/* Tell libpng how we react to CRC errors in ancillary chunks */
switch (ancil_action)
{
case PNG_CRC_NO_CHANGE: /* Leave setting as is */
@ -94,6 +97,7 @@ png_set_background(png_structp png_ptr,
int need_expand, double background_gamma)
{
png_debug(1, "in png_set_background");
if (png_ptr == NULL)
return;
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
@ -117,6 +121,7 @@ void PNGAPI
png_set_strip_16(png_structp png_ptr)
{
png_debug(1, "in png_set_strip_16");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_16_TO_8;
@ -128,6 +133,7 @@ void PNGAPI
png_set_strip_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_strip_alpha");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
@ -139,6 +145,7 @@ void PNGAPI
png_set_premultiply_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_premultiply_alpha");
if(png_ptr == NULL)
return;
png_ptr->transformations |=
@ -174,6 +181,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
int full_dither)
{
png_debug(1, "in png_set_dither");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_DITHER;
@ -570,6 +578,7 @@ void PNGAPI
png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
{
png_debug(1, "in png_set_gamma");
if (png_ptr == NULL)
return;
if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) ||
@ -590,6 +599,7 @@ void PNGAPI
png_set_expand(png_structp png_ptr)
{
png_debug(1, "in png_set_expand");
if (png_ptr == NULL)
return;
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
@ -618,6 +628,7 @@ void PNGAPI
png_set_palette_to_rgb(png_structp png_ptr)
{
png_debug(1, "in png_set_palette_to_rgb");
if (png_ptr == NULL)
return;
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
@ -629,6 +640,7 @@ void PNGAPI
png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
{
png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_EXPAND;
@ -642,6 +654,7 @@ void PNGAPI
png_set_tRNS_to_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_tRNS_to_alpha");
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
}
@ -652,6 +665,7 @@ void PNGAPI
png_set_gray_to_rgb(png_structp png_ptr)
{
png_debug(1, "in png_set_gray_to_rgb");
png_ptr->transformations |= PNG_GRAY_TO_RGB;
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
}
@ -680,6 +694,7 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
png_fixed_point red, png_fixed_point green)
{
png_debug(1, "in png_set_rgb_to_gray");
if (png_ptr == NULL)
return;
switch(error_action)
@ -735,6 +750,7 @@ 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)
@ -751,6 +767,7 @@ void /* PRIVATE */
png_init_read_transformations(png_structp png_ptr)
{
png_debug(1, "in png_init_read_transformations");
{
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \
|| defined(PNG_READ_GAMMA_SUPPORTED)
@ -1164,6 +1181,7 @@ 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)
if (png_ptr->transformations & PNG_EXPAND)
{
@ -1302,6 +1320,7 @@ 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)
@ -1557,6 +1576,7 @@ void /* PRIVATE */
png_do_unpack(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_unpack");
if (row_info->bit_depth < 8)
{
png_uint_32 i;
@ -1645,6 +1665,7 @@ 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 (
row_info->color_type != PNG_COLOR_TYPE_PALETTE)
{
@ -1751,6 +1772,7 @@ void /* PRIVATE */
png_do_chop(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_chop");
if (row_info->bit_depth == 16)
{
png_bytep sp = row;
@ -1804,6 +1826,7 @@ void /* PRIVATE */
png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_read_swap_alpha");
{
png_uint_32 row_width = row_info->width;
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
@ -1893,6 +1916,7 @@ void /* PRIVATE */
png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_read_invert_alpha");
{
png_uint_32 row_width = row_info->width;
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
@ -1988,6 +2012,7 @@ void /* PRIVATE */
png_do_read_premultiply_alpha(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_read_premultiply_alpha");
{
png_uint_32 row_width = row_info->width;
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
@ -2074,6 +2099,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
png_byte lo_filler = (png_byte)(filler & 0xff);
png_debug(1, "in png_do_read_filler");
if (
row_info->color_type == PNG_COLOR_TYPE_GRAY)
{
@ -2243,6 +2269,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
png_uint_32 row_width = row_info->width;
png_debug(1, "in png_do_gray_to_rgb");
if (row_info->bit_depth >= 8 &&
!(row_info->color_type & PNG_COLOR_MASK_COLOR))
{
@ -2346,6 +2373,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
int rgb_error = 0;
png_debug(1, "in png_do_rgb_to_gray");
if (
(row_info->color_type & PNG_COLOR_MASK_COLOR))
{
@ -2581,6 +2609,7 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
int v;
png_debug(1, "in png_do_build_grayscale_palette");
if (palette == NULL)
return;
@ -2643,6 +2672,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
int shift;
png_debug(1, "in png_do_background");
if (background != NULL &&
(!(row_info->color_type & PNG_COLOR_MASK_ALPHA) ||
(row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_color)))
@ -3329,6 +3359,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
png_uint_32 row_width=row_info->width;
png_debug(1, "in png_do_gamma");
if (
((row_info->bit_depth <= 8 && gamma_table != NULL) ||
(row_info->bit_depth == 16 && gamma_16_table != NULL)))
@ -3514,6 +3545,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
png_uint_32 row_width=row_info->width;
png_debug(1, "in png_do_expand_palette");
if (
row_info->color_type == PNG_COLOR_TYPE_PALETTE)
{
@ -3657,6 +3689,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
png_uint_32 row_width=row_info->width;
png_debug(1, "in png_do_expand");
{
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
{
@ -3865,6 +3898,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
png_uint_32 row_width=row_info->width;
png_debug(1, "in png_do_dither");
{
if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
palette_lookup && row_info->bit_depth == 8)
@ -4227,6 +4261,7 @@ void /* PRIVATE */
png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_read_intrapixel");
if (
(row_info->color_type & PNG_COLOR_MASK_COLOR))
{

View File

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)

View File

@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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,6 +25,7 @@ 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");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -41,6 +42,7 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
double green_x, double green_y, double blue_x, double blue_y)
{
png_debug1(1, "in %s storage function", "cHRM");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -74,6 +76,7 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
png_fixed_point blue_x, png_fixed_point blue_y)
{
png_debug1(1, "in %s storage function", "cHRM fixed");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -112,7 +115,9 @@ void PNGAPI
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
{
double png_gamma;
png_debug1(1, "in %s storage function", "gAMA");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -140,6 +145,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
png_fixed_point png_gamma;
png_debug1(1, "in %s storage function", "gAMA");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -177,6 +183,7 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
int i;
png_debug1(1, "in %s storage function", "hIST");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->num_palette == 0 || info_ptr->num_palette
@ -221,6 +228,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
int filter_type)
{
png_debug1(1, "in %s storage function", "IHDR");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -328,6 +336,7 @@ png_set_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 storage function", "oFFs");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -348,6 +357,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
int i;
png_debug1(1, "in %s storage function", "pCAL");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -417,6 +427,7 @@ png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
int unit, double width, double height)
{
png_debug1(1, "in %s storage function", "sCAL");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -435,6 +446,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
png_size_t length;
png_debug1(1, "in %s storage function", "sCAL");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -480,6 +492,7 @@ png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
png_uint_32 res_x, png_uint_32 res_y, int unit_type)
{
png_debug1(1, "in %s storage function", "pHYs");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -496,6 +509,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
{
png_debug1(1, "in %s storage function", "PLTE");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -551,6 +565,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
png_color_8p sig_bit)
{
png_debug1(1, "in %s storage function", "sBIT");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -564,6 +579,7 @@ void PNGAPI
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
{
png_debug1(1, "in %s storage function", "sRGB");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -591,6 +607,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
int_green_y, int_blue_x, int_blue_y;
#endif
png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -660,6 +677,7 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
png_uint_32 length;
png_debug1(1, "in %s storage function", "iCCP");
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
return;
@ -874,6 +892,7 @@ 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");
if (png_ptr == NULL || info_ptr == NULL ||
(png_ptr->mode & PNG_WROTE_tIME))
return;
@ -889,6 +908,7 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
png_bytep trans_alpha, int num_trans, png_color_16p trans_color)
{
png_debug1(1, "in %s storage function", "tRNS");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -1090,6 +1110,7 @@ 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");
if (png_ptr == NULL)
return (png_uint_32)0;
png_ptr->mng_features_permitted =
@ -1151,6 +1172,7 @@ png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
png_user_chunk_ptr read_user_chunk_fn)
{
png_debug(1, "in png_set_read_user_chunk_fn");
if (png_ptr == NULL)
return;
png_ptr->read_user_chunk_fn = read_user_chunk_fn;
@ -1235,6 +1257,7 @@ void PNGAPI
png_set_benign_errors(png_structp png_ptr, int allowed)
{
png_debug(1, "in png_set_benign_errors");
if (allowed)
png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
else

View File

@ -1,7 +1,7 @@
/* pngtest.c - a simple test program to test libpng
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)

View File

@ -1,7 +1,7 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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,6 +113,7 @@ 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;
@ -140,6 +147,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);
@ -154,6 +162,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;
@ -166,6 +175,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;
@ -177,6 +187,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;
@ -187,6 +198,7 @@ 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 &&
*/
@ -238,6 +250,7 @@ void /* PRIVATE */
png_do_swap(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_swap");
if (
row_info->bit_depth == 16)
{
@ -366,6 +379,7 @@ void /* PRIVATE */
png_do_packswap(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_packswap");
if (
row_info->bit_depth < 8)
{
@ -395,6 +409,7 @@ 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");
{
png_bytep sp=row;
png_bytep dp=row;
@ -550,6 +565,7 @@ void /* PRIVATE */
png_do_bgr(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_bgr");
if (
(row_info->color_type & PNG_COLOR_MASK_COLOR))
{
@ -625,6 +641,7 @@ 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)

View File

@ -1,7 +1,7 @@
/* pngwio.c - functions for data output
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)

View File

@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)
@ -29,6 +29,7 @@ void PNGAPI
png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_write_info_before_PLTE");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
@ -310,6 +311,7 @@ void PNGAPI
png_write_end(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_write_end");
if (png_ptr == NULL)
return;
if (!(png_ptr->mode & PNG_HAVE_IDAT))
@ -423,6 +425,7 @@ void PNGAPI
png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime)
{
png_debug(1, "in png_convert_from_struct_tm");
ptime->year = (png_uint_16)(1900 + ttime->tm_year);
ptime->month = (png_byte)(ttime->tm_mon + 1);
ptime->day = (png_byte)ttime->tm_mday;
@ -437,6 +440,7 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
struct tm *tbuf;
png_debug(1, "in png_convert_from_time_t");
tbuf = gmtime(&ttime);
png_convert_from_struct_tm(ptime, tbuf);
}
@ -471,7 +475,9 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#endif
#endif
int i;
png_debug(1, "in png_create_write_struct");
#ifdef PNG_USER_MEM_SUPPORTED
png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
(png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);
@ -620,6 +626,7 @@ png_write_image(png_structp png_ptr, png_bytepp image)
return;
png_debug(1, "in png_write_image");
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
/* Initialize interlace handling. If image is not interlaced,
* this will set pass to 1
@ -645,6 +652,7 @@ png_write_row(png_structp png_ptr, png_bytep row)
{
if (png_ptr == NULL)
return;
png_debug2(1, "in png_write_row (row %ld, pass %d)",
png_ptr->row_number, png_ptr->pass);
@ -820,6 +828,7 @@ void PNGAPI
png_set_flush(png_structp png_ptr, int nrows)
{
png_debug(1, "in png_set_flush");
if (png_ptr == NULL)
return;
png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);
@ -832,6 +841,7 @@ png_write_flush(png_structp png_ptr)
int wrote_IDAT;
png_debug(1, "in png_write_flush");
if (png_ptr == NULL)
return;
/* We have already written out all of the data */
@ -892,6 +902,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
#endif
png_debug(1, "in png_destroy_write_struct");
if (png_ptr_ptr != NULL)
{
png_ptr = *png_ptr_ptr;
@ -955,7 +966,7 @@ void /* PRIVATE */
png_write_destroy(png_structp png_ptr)
{
#ifdef PNG_SETJMP_SUPPORTED
jmp_buf tmp_jmp; /* save jump buffer */
jmp_buf tmp_jmp; /* Save jump buffer */
#endif
png_error_ptr error_fn;
png_error_ptr warning_fn;
@ -965,10 +976,11 @@ png_write_destroy(png_structp png_ptr)
#endif
png_debug(1, "in png_write_destroy");
/* free any memory zlib uses */
/* Free any memory zlib uses */
deflateEnd(&png_ptr->zstream);
/* free our memory. png_free checks NULL for us. */
/* Free our memory. png_free checks NULL for us. */
png_free(png_ptr, png_ptr->zbuf);
png_free(png_ptr, png_ptr->row_buf);
#ifndef PNG_NO_WRITE_FILTER
@ -1022,6 +1034,7 @@ 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)
@ -1145,6 +1158,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
int i;
png_debug(1, "in png_set_filter_heuristics");
if (png_ptr == NULL)
return;
if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST)
@ -1259,6 +1273,7 @@ void PNGAPI
png_set_compression_level(png_structp png_ptr, int level)
{
png_debug(1, "in png_set_compression_level");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL;
@ -1269,6 +1284,7 @@ void PNGAPI
png_set_compression_mem_level(png_structp png_ptr, int mem_level)
{
png_debug(1, "in png_set_compression_mem_level");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL;
@ -1279,6 +1295,7 @@ void PNGAPI
png_set_compression_strategy(png_structp png_ptr, int strategy)
{
png_debug(1, "in png_set_compression_strategy");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;
@ -1310,6 +1327,7 @@ void PNGAPI
png_set_compression_method(png_structp png_ptr, int method)
{
png_debug(1, "in png_set_compression_method");
if (png_ptr == NULL)
return;
if (method != 8)
@ -1332,6 +1350,7 @@ png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
write_user_transform_fn)
{
png_debug(1, "in png_set_write_user_transform_fn");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_USER_TRANSFORM;

View File

@ -1,7 +1,7 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)
@ -90,6 +90,7 @@ 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 &&
row_info->channels == 1)
{
@ -213,6 +214,7 @@ 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 (
row_info->color_type != PNG_COLOR_TYPE_PALETTE)
{
@ -333,6 +335,7 @@ 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 (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
{
@ -418,6 +421,7 @@ 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 (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
{
@ -505,6 +509,7 @@ void /* PRIVATE */
png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_write_intrapixel");
if (
(row_info->color_type & PNG_COLOR_MASK_COLOR))
{

View File

@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file
*
* Last changed in libpng 1.4.0 [August 13, 2009]
* Last changed in libpng 1.4.0 [August 15, 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.)
@ -107,6 +107,12 @@ png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,
{
png_byte buf[8];
png_debug2(0, "Writing %s chunk, length = %lu", chunk_name,
(unsigned long)length);
if (png_ptr == NULL)
return;
#ifdef PNG_IO_STATE_SUPPORTED
/* Inform the I/O callback that the chunk header is being written.
* PNG_IO_CHUNK_HDR requires a single I/O call.
@ -114,11 +120,6 @@ png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,
png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR;
#endif
png_debug2(0, "Writing %s chunk, length = %lu", chunk_name,
(unsigned long)length);
if (png_ptr == NULL)
return;
/* Write the length and the chunk name */
png_save_uint_32(buf, length);
png_memcpy(buf + 4, chunk_name, 4);
@ -739,7 +740,7 @@ png_write_gAMA(png_structp png_ptr, double file_gamma)
png_debug(1, "in png_write_gAMA");
/* file_gamma is saved in 1/100,000ths */
/* File_gamma is saved in 1/100,000ths */
igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);
png_save_uint_32(buf, igamma);
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
@ -756,7 +757,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
png_debug(1, "in png_write_gAMA");
/* file_gamma is saved in 1/100,000ths */
/* File_gamma is saved in 1/100,000ths */
png_save_uint_32(buf, (png_uint_32)file_gamma);
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
}