[devel] Added PNG_WRITE_16BIT_SUPPORTED option.

This commit is contained in:
Glenn Randers-Pehrson 2010-08-26 17:14:07 -05:00
parent 07d9fc9478
commit 7d3e6732fb
7 changed files with 36 additions and 3 deletions

View File

@ -390,6 +390,7 @@ Version 1.5.0beta45 [August 26, 2010]
Version 1.5.0beta46 [August 26, 2010] Version 1.5.0beta46 [August 26, 2010]
Added new private header files to libpng_sources in CMakeLists.txt Added new private header files to libpng_sources in CMakeLists.txt
Added PNG_WRITE_16BIT_SUPPORTED option.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net: Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
(subscription required; visit (subscription required; visit

View File

@ -3026,7 +3026,8 @@ Version 1.5.0beta45 [August 26, 2010]
in pngpriv.h in case the user neglected to define them in their pngusr.h in pngpriv.h in case the user neglected to define them in their pngusr.h
Version 1.5.0beta46 [August 26, 2010] Version 1.5.0beta46 [August 26, 2010]
[devel] Added new private header files to libpng_sources in CMakeLists.txt Added new private header files to libpng_sources in CMakeLists.txt
Added PNG_WRITE_16BIT_SUPPORTED option.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -393,6 +393,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
} }
} }
#ifdef PNG_WRITE_16BIT_SUPPORTED
else else
{ {
/* This converts from AARRGGBB to RRGGBBAA */ /* This converts from AARRGGBB to RRGGBBAA */
@ -415,6 +416,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
*(dp++) = save[1]; *(dp++) = save[1];
} }
} }
#endif /* PNG_WRITE_16BIT_SUPPORTED */
} }
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
@ -434,6 +436,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
} }
} }
#ifdef PNG_WRITE_16BIT_SUPPORTED
else else
{ {
/* This converts from AAGG to GGAA */ /* This converts from AAGG to GGAA */
@ -452,6 +455,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
*(dp++) = save[1]; *(dp++) = save[1];
} }
} }
#endif /* PNG_WRITE_16BIT_SUPPORTED */
} }
} }
} }
@ -485,6 +489,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
} }
} }
#ifdef PNG_WRITE_16BIT_SUPPORTED
else else
{ {
/* This inverts the alpha channel in RRGGBBAA */ /* This inverts the alpha channel in RRGGBBAA */
@ -507,6 +512,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
*(dp++) = (png_byte)(255 - *(sp++)); *(dp++) = (png_byte)(255 - *(sp++));
} }
} }
#endif /* PNG_WRITE_16BIT_SUPPORTED */
} }
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
@ -525,6 +531,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
} }
} }
#ifdef PNG_WRITE_16BIT_SUPPORTED
else else
{ {
/* This inverts the alpha channel in GGAA */ /* This inverts the alpha channel in GGAA */
@ -543,6 +550,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
*(dp++) = (png_byte)(255 - *(sp++)); *(dp++) = (png_byte)(255 - *(sp++));
} }
} }
#endif /* PNG_WRITE_16BIT_SUPPORTED */
} }
} }
} }
@ -580,6 +588,7 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
} }
} }
#ifdef PNG_WRITE_16BIT_SUPPORTED
else if (row_info->bit_depth == 16) else if (row_info->bit_depth == 16)
{ {
png_bytep rp; png_bytep rp;
@ -607,6 +616,7 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
*(rp + 5) = (png_byte)(blue & 0xff); *(rp + 5) = (png_byte)(blue & 0xff);
} }
} }
#endif /* PNG_WRITE_16BIT_SUPPORTED */
} }
} }
#endif /* PNG_MNG_FEATURES_SUPPORTED */ #endif /* PNG_MNG_FEATURES_SUPPORTED */

View File

@ -449,7 +449,9 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
case 2: case 2:
case 4: case 4:
case 8: case 8:
#ifdef PNG_WRITE_16BIT_SUPPORTED
case 16: case 16:
#endif
png_ptr->channels = 1; break; png_ptr->channels = 1; break;
default: default:
png_error(png_ptr, png_error(png_ptr,
@ -458,7 +460,11 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
break; break;
case PNG_COLOR_TYPE_RGB: case PNG_COLOR_TYPE_RGB:
#ifdef PNG_WRITE_16BIT_SUPPORTED
if (bit_depth != 8 && bit_depth != 16) if (bit_depth != 8 && bit_depth != 16)
#else
if (bit_depth != 8)
#endif
png_error(png_ptr, "Invalid bit depth for RGB image"); png_error(png_ptr, "Invalid bit depth for RGB image");
png_ptr->channels = 3; png_ptr->channels = 3;
@ -486,7 +492,11 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
break; break;
case PNG_COLOR_TYPE_RGB_ALPHA: case PNG_COLOR_TYPE_RGB_ALPHA:
#ifdef PNG_WRITE_16BIT_SUPPORTED
if (bit_depth != 8 && bit_depth != 16) if (bit_depth != 8 && bit_depth != 16)
#else
if (bit_depth != 8)
#endif
png_error(png_ptr, "Invalid bit depth for RGBA image"); png_error(png_ptr, "Invalid bit depth for RGBA image");
png_ptr->channels = 4; png_ptr->channels = 4;
@ -1106,7 +1116,11 @@ png_write_tRNS(png_structp png_ptr, png_const_bytep trans_alpha,
png_save_uint_16(buf, tran->red); png_save_uint_16(buf, tran->red);
png_save_uint_16(buf + 2, tran->green); png_save_uint_16(buf + 2, tran->green);
png_save_uint_16(buf + 4, tran->blue); png_save_uint_16(buf + 4, tran->blue);
#ifdef PNG_WRITE_16BIT_SUPPORTED
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
#else
if (buf[0] | buf[2] | buf[4])
#endif
{ {
png_warning(png_ptr, png_warning(png_ptr,
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
@ -1154,7 +1168,11 @@ png_write_bKGD(png_structp png_ptr, png_const_color_16p back, int color_type)
png_save_uint_16(buf, back->red); png_save_uint_16(buf, back->red);
png_save_uint_16(buf + 2, back->green); png_save_uint_16(buf + 2, back->green);
png_save_uint_16(buf + 4, back->blue); png_save_uint_16(buf + 4, back->blue);
#ifdef PNG_WRITE_16BIT_SUPPORTED
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
#else
if (buf[0] | buf[2] | buf[4])
#endif
{ {
png_warning(png_ptr, png_warning(png_ptr,
"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");

View File

@ -6,7 +6,7 @@
# #
com pnglibconf.h - library build configuration com pnglibconf.h - library build configuration
com com
com libpng version PNGLIB_VERSION - last changed on August 26, 2010 com libpng version 1.5.0beta46 - last changed on August 26, 2010
com com
com Copyright (c) 1998-2010 Glenn Randers-Pehrson com Copyright (c) 1998-2010 Glenn Randers-Pehrson
com com
@ -314,6 +314,8 @@ option READ_16_TO_8_ACCURATE_SCALE requires READ disabled
# WRITE options # WRITE options
option WRITE option WRITE
option WRITE_16BIT requires WRITE
option WRITE_TRANSFORMS requires WRITE option WRITE_TRANSFORMS requires WRITE
= NO_WRITE_TRANSFORMS PNG_WRITE_TRANSFORMS_NOT_SUPPORTED = NO_WRITE_TRANSFORMS PNG_WRITE_TRANSFORMS_NOT_SUPPORTED

View File

@ -39,6 +39,7 @@
#define PNG_WARNINGS_SUPPORTED #define PNG_WARNINGS_SUPPORTED
#define PNG_FLOATING_ARITHMETIC_SUPPORTED #define PNG_FLOATING_ARITHMETIC_SUPPORTED
#define PNG_WRITE_SUPPORTED #define PNG_WRITE_SUPPORTED
#define PNG_WRITE_16BIT_SUPPORTED
#define PNG_WRITE_INTERLACING_SUPPORTED #define PNG_WRITE_INTERLACING_SUPPORTED
#define PNG_EASY_ACCESS_SUPPORTED #define PNG_EASY_ACCESS_SUPPORTED
#define PNG_ALIGN_MEMORY_SUPPORTED #define PNG_ALIGN_MEMORY_SUPPORTED

View File

@ -29,7 +29,7 @@ PNG_DEFN_MAGIC-;OS2 DESCRIPTION "PNG image compression library"-PNG_DEFN_END
PNG_DEFN_MAGIC-;OS2 CODE PRELOAD MOVEABLE DISCARDABLE-PNG_DEFN_END PNG_DEFN_MAGIC-;OS2 CODE PRELOAD MOVEABLE DISCARDABLE-PNG_DEFN_END
PNG_DEFN_MAGIC--PNG_DEFN_END PNG_DEFN_MAGIC--PNG_DEFN_END
PNG_DEFN_MAGIC-EXPORTS-PNG_DEFN_END PNG_DEFN_MAGIC-EXPORTS-PNG_DEFN_END
PNG_DEFN_MAGIC-;Version PNGLIB_VERSION-PNG_DEFN_END PNG_DEFN_MAGIC-;Version 1.5.0beta46-PNG_DEFN_END
/* Read the defaults, but use scripts/pnglibconf.h.prebuilt; the 'standard' /* Read the defaults, but use scripts/pnglibconf.h.prebuilt; the 'standard'
* header file. * header file.