summaryrefslogtreecommitdiff
path: root/pngwutil.c
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2010-08-26 17:14:07 -0500
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2010-08-26 17:14:07 -0500
commit7d3e6732fbf529be0571fb89a5f778d89b2553ac (patch)
treef8a337934f0d88f4d3d39dd1fc366ac1dc788576 /pngwutil.c
parent07d9fc947819a752f06602156de052830f561751 (diff)
downloadlibpng-7d3e6732fbf529be0571fb89a5f778d89b2553ac.tar.gz
[devel] Added PNG_WRITE_16BIT_SUPPORTED option.
Diffstat (limited to 'pngwutil.c')
-rw-r--r--pngwutil.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/pngwutil.c b/pngwutil.c
index 89fb22b41..eb60ef6c0 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -449,7 +449,9 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
case 2:
case 4:
case 8:
+#ifdef PNG_WRITE_16BIT_SUPPORTED
case 16:
+#endif
png_ptr->channels = 1; break;
default:
png_error(png_ptr,
@@ -458,7 +460,11 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
break;
case PNG_COLOR_TYPE_RGB:
+#ifdef PNG_WRITE_16BIT_SUPPORTED
if (bit_depth != 8 && bit_depth != 16)
+#else
+ if (bit_depth != 8)
+#endif
png_error(png_ptr, "Invalid bit depth for RGB image");
png_ptr->channels = 3;
@@ -486,7 +492,11 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
+#ifdef PNG_WRITE_16BIT_SUPPORTED
if (bit_depth != 8 && bit_depth != 16)
+#else
+ if (bit_depth != 8)
+#endif
png_error(png_ptr, "Invalid bit depth for RGBA image");
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 + 2, tran->green);
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]))
+#else
+ if (buf[0] | buf[2] | buf[4])
+#endif
{
png_warning(png_ptr,
"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 + 2, back->green);
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]))
+#else
+ if (buf[0] | buf[2] | buf[4])
+#endif
{
png_warning(png_ptr,
"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");