mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[devel] Changed some "#if defined(" to "ifdef"
This commit is contained in:
78
pngwutil.c
78
pngwutil.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.4.0 [September 17, 2009]
|
||||
* Last changed in libpng 1.4.0 [September 23, 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.)
|
||||
@@ -28,7 +28,7 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
|
||||
buf[3] = (png_byte)(i & 0xff);
|
||||
}
|
||||
|
||||
#if defined(PNG_SAVE_INT_32_SUPPORTED)
|
||||
#ifdef PNG_SAVE_INT_32_SUPPORTED
|
||||
/* The png_save_int_32 function assumes integers are stored in two's
|
||||
* complement format. If this isn't the case, then this routine needs to
|
||||
* be modified to write data in two's complement format.
|
||||
@@ -220,7 +220,7 @@ png_text_compress(png_structp png_ptr,
|
||||
|
||||
if (compression >= PNG_TEXT_COMPRESSION_LAST)
|
||||
{
|
||||
#if defined(PNG_STDIO_SUPPORTED)
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
char msg[50];
|
||||
png_snprintf(msg, 50, "Unknown compression type %d", compression);
|
||||
png_warning(png_ptr, msg);
|
||||
@@ -483,7 +483,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 ||
|
||||
@@ -511,7 +511,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;
|
||||
@@ -601,7 +601,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)
|
||||
@@ -718,7 +718,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 */
|
||||
@@ -752,7 +752,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)
|
||||
@@ -770,7 +770,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,
|
||||
@@ -849,7 +849,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)
|
||||
@@ -928,7 +928,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)
|
||||
@@ -983,7 +983,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 */
|
||||
@@ -1008,7 +1008,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_CHECK_cHRM_SUPPORTED)
|
||||
#ifdef PNG_CHECK_cHRM_SUPPORTED
|
||||
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
|
||||
@@ -1044,7 +1044,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_CHECK_cHRM_SUPPORTED)
|
||||
#ifdef PNG_CHECK_cHRM_SUPPORTED
|
||||
if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y,
|
||||
green_x, green_y, blue_x, blue_y))
|
||||
#endif
|
||||
@@ -1067,7 +1067,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_alpha, png_color_16p tran,
|
||||
@@ -1122,7 +1122,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans_alpha, 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)
|
||||
@@ -1135,7 +1135,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
|
||||
@@ -1174,7 +1174,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)
|
||||
@@ -1249,7 +1249,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
if ((png_byte)*kp < 0x20 ||
|
||||
((png_byte)*kp > 0x7E && (png_byte)*kp < 0xA1))
|
||||
{
|
||||
#if defined(PNG_STDIO_SUPPORTED)
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
char msg[40];
|
||||
|
||||
png_snprintf(msg, 40,
|
||||
@@ -1335,7 +1335,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,
|
||||
@@ -1374,7 +1374,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,
|
||||
@@ -1432,7 +1432,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,
|
||||
@@ -1519,7 +1519,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,
|
||||
@@ -1540,7 +1540,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,
|
||||
@@ -1601,7 +1601,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_STDIO_SUPPORTED)
|
||||
void /* PRIVATE */
|
||||
@@ -1654,7 +1654,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,
|
||||
@@ -1677,7 +1677,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.
|
||||
*/
|
||||
@@ -1917,7 +1917,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
|
||||
@@ -2163,7 +2163,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;
|
||||
@@ -2227,7 +2227,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.
|
||||
@@ -2280,7 +2280,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;
|
||||
@@ -2341,7 +2341,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;
|
||||
@@ -2383,7 +2383,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;
|
||||
@@ -2446,7 +2446,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;
|
||||
@@ -2495,7 +2495,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;
|
||||
@@ -2579,7 +2579,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;
|
||||
@@ -2660,7 +2660,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;
|
||||
@@ -2702,7 +2702,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
png_write_filtered_row(png_ptr, best_row);
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
#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)
|
||||
{
|
||||
@@ -2769,7 +2769,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 &&
|
||||
|
||||
Reference in New Issue
Block a user