[master] Ported some cosmetic changes from libpng-1.4.0beta87

changing many "#if defined(x)" to "#ifdef x" in pngtest.c and pngwutil.c.
This commit is contained in:
Glenn Randers-Pehrson 2009-10-10 09:27:12 -05:00
parent e9c8dcf96c
commit 722f5fd8d4
4 changed files with 107 additions and 109 deletions

View File

@ -62,6 +62,8 @@ version 1.2.41beta04 [October 7, 2009]
version 1.2.41beta05 [October 10, 2009]
Revised pngconf.h to make it easier to enable iTXt support.
Ported some cosmetic changes from libpng-1.4.0beta87, changing
many "#if defined(x)" to "#ifdef x".
Send comments/corrections/commendations to png-mng-implement at lists.sf.net

View File

@ -2492,6 +2492,8 @@ version 1.2.41beta04 [October 7, 2009]
version 1.2.41beta05 [October 10, 2009]
Revised pngconf.h to make it easier to enable iTXt support.
Ported some cosmetic changes from libpng-1.4.0beta87, changing
many "#if defined(x)" to "#ifdef x".
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

124
pngtest.c
View File

@ -1,7 +1,7 @@
/* 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 10, 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.)
@ -33,7 +33,7 @@
#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
@ -54,8 +54,8 @@
# 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;
@ -75,7 +75,7 @@
#define PNGTEST_TIMING
*/
#ifdef PNG_NO_FLOATING_POINT_SUPPORTED
#ifndef PNG_FLOATING_POINT_SUPPORTED
#undef PNGTEST_TIMING
#endif
@ -84,7 +84,7 @@ static float t_start, t_stop, t_decode, t_encode, t_misc;
#include <time.h>
#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";
@ -162,7 +162,7 @@ write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
}
#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.)
@ -184,7 +184,7 @@ count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
}
#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)
*/
@ -297,7 +297,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
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.
@ -371,7 +371,7 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
}
#endif /* USE_FAR_KEYWORD */
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
#ifdef PNG_WRITE_FLUSH_SUPPORTED
static void
pngtest_flush(png_structp png_ptr)
{
@ -474,7 +474,7 @@ pngtest_error(png_structp png_ptr, png_const_charp message)
* 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 */
@ -607,7 +607,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
/* 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). */
@ -701,14 +701,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#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
@ -719,7 +719,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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
@ -742,12 +742,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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;
@ -767,7 +767,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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
@ -829,7 +829,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#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);
@ -838,7 +838,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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);
@ -860,7 +860,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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++)
@ -868,19 +868,19 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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
@ -899,15 +899,15 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
&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;
@ -919,7 +919,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
#if defined(PNG_gAMA_SUPPORTED)
#ifdef PNG_gAMA_SUPPORTED
{
png_fixed_point gamma;
@ -928,8 +928,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
#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;
@ -941,7 +941,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
#if defined(PNG_gAMA_SUPPORTED)
#ifdef PNG_gAMA_SUPPORTED
{
double gamma;
@ -951,7 +951,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif
#endif /* Floating point */
#endif /* Fixed point */
#if defined(PNG_iCCP_SUPPORTED)
#ifdef PNG_iCCP_SUPPORTED
{
png_charp name;
png_charp profile;
@ -966,7 +966,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
#if defined(PNG_sRGB_SUPPORTED)
#ifdef PNG_sRGB_SUPPORTED
{
int intent;
@ -981,7 +981,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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;
@ -991,7 +991,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
#if defined(PNG_hIST_SUPPORTED)
#ifdef PNG_hIST_SUPPORTED
{
png_uint_16p hist;
@ -999,7 +999,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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;
@ -1011,7 +1011,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
#if defined(PNG_pCAL_SUPPORTED)
#ifdef PNG_pCAL_SUPPORTED
{
png_charp purpose, units;
png_charpp params;
@ -1026,7 +1026,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
#if defined(PNG_pHYs_SUPPORTED)
#ifdef PNG_pHYs_SUPPORTED
{
png_uint_32 res_x, res_y;
int unit_type;
@ -1035,7 +1035,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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;
@ -1043,7 +1043,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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;
@ -1070,7 +1070,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif
#endif
#endif
#if defined(PNG_TEXT_SUPPORTED)
#ifdef PNG_TEXT_SUPPORTED
{
png_textp text_ptr;
int num_text;
@ -1082,14 +1082,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#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.
@ -1103,7 +1103,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
#if defined(PNG_tRNS_SUPPORTED)
#ifdef PNG_tRNS_SUPPORTED
{
png_bytep trans;
int num_trans;
@ -1125,7 +1125,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#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,
@ -1154,7 +1154,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
*/
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'};
@ -1248,17 +1248,17 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#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;
@ -1270,14 +1270,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#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 */
@ -1290,7 +1290,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
{
png_unknown_chunkp unknowns;
int num_unknowns;
@ -1346,7 +1346,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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
@ -1357,7 +1357,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
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
@ -1527,7 +1527,7 @@ main(int argc, char *argv[])
#endif
for (i=2; i<argc; ++i)
{
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
int k;
#endif
int kerror;
@ -1535,19 +1535,19 @@ main(int argc, char *argv[])
kerror = test_one_file(argv[i], outname);
if (kerror == 0)
{
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
(unsigned long)zero_samples);
#else
fprintf(STDERR, " PASS\n");
#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
for (k = 0; k<256; k++)
if (filters_used[k])
fprintf(STDERR, " Filter %d was used %lu times\n",
k, (unsigned long)filters_used[k]);
#endif
#if defined(PNG_TIME_RFC1123_SUPPORTED)
#ifdef PNG_TIME_RFC1123_SUPPORTED
if (tIME_chunk_present != 0)
fprintf(STDERR, " tIME = %s\n", tIME_string);
tIME_chunk_present = 0;
@ -1607,23 +1607,23 @@ main(int argc, char *argv[])
{
if (verbose == 1 || i == 2)
{
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
int k;
#endif
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
(unsigned long)zero_samples);
#else
fprintf(STDERR, " PASS\n");
#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
for (k = 0; k<256; k++)
if (filters_used[k])
fprintf(STDERR, " Filter %d was used %lu times\n",
k,
(unsigned long)filters_used[k]);
#endif
#if defined(PNG_TIME_RFC1123_SUPPORTED)
#ifdef PNG_TIME_RFC1123_SUPPORTED
if (tIME_chunk_present != 0)
fprintf(STDERR, " tIME = %s\n", tIME_string);
#endif /* PNG_TIME_RFC1123_SUPPORTED */

View File

@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file
*
* Last changed in libpng 1.2.40 [October 10, 2009]
* Last changed in libpng 1.2.41 [October 10, 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.)
@ -459,7 +459,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
* 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 ||
@ -487,7 +487,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
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;
@ -579,7 +579,7 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
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)
@ -700,7 +700,7 @@ png_write_IEND(png_structp png_ptr)
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 */
@ -738,7 +738,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
#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)
@ -758,7 +758,7 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
}
#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,
@ -839,7 +839,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
}
#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)
@ -920,7 +920,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
}
#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)
@ -977,7 +977,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
}
#endif
#if defined(PNG_WRITE_cHRM_SUPPORTED)
#ifdef PNG_WRITE_cHRM_SUPPORTED
/* Write the cHRM chunk */
#ifdef PNG_FLOATING_POINT_SUPPORTED
void /* PRIVATE */
@ -1004,7 +1004,7 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
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
@ -1042,7 +1042,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
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
@ -1065,7 +1065,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
#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,
@ -1122,7 +1122,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
}
#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)
@ -1137,7 +1137,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
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
@ -1176,7 +1176,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
}
#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)
@ -1340,7 +1340,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
}
#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,
@ -1381,7 +1381,7 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
}
#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,
@ -1441,7 +1441,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
}
#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,
@ -1530,7 +1530,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
}
#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,
@ -1553,7 +1553,7 @@ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
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,
@ -1616,7 +1616,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
}
#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 */
@ -1631,7 +1631,7 @@ png_write_sCAL(png_structp png_ptr, int unit, double width, double height)
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];
@ -1690,7 +1690,7 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
#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,
@ -1715,7 +1715,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
}
#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.
*/
@ -1753,7 +1753,6 @@ 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 */
@ -1767,7 +1766,6 @@ png_write_start_row(png_structp png_ptr)
/* 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;
@ -1820,7 +1818,7 @@ png_write_start_row(png_structp png_ptr)
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 */
@ -1854,7 +1852,6 @@ 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 */
@ -1868,7 +1865,6 @@ png_write_finish_row(png_structp png_ptr)
/* 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;
@ -1962,7 +1958,7 @@ png_write_finish_row(png_structp png_ptr)
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
@ -1973,7 +1969,6 @@ png_write_finish_row(png_structp png_ptr)
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 */
@ -1981,12 +1976,11 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
/* 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)
@ -2206,7 +2200,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
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;
@ -2270,7 +2264,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
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.
@ -2323,7 +2317,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
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;
@ -2384,7 +2378,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
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;
@ -2426,7 +2420,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
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;
@ -2489,7 +2483,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
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;
@ -2538,7 +2532,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
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;
@ -2622,7 +2616,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
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;
@ -2703,7 +2697,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
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;
@ -2739,13 +2733,13 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
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)
{
@ -2757,7 +2751,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
png_ptr->prev_filters[j] = best_row[0];
}
#endif
#endif /* PNG_NO_WRITE_FILTER */
#endif /* PNG_WRITE_FILTER_SUPPORTED */
}
@ -2812,7 +2806,7 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
/* 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 &&