[devel] Made png_set_chop_16() API removeable

by disabling PNG_CHOP_16_TO_8_SUPPORTED
diff --git a/ANNOUNCE b/ANNOUNCE
index af13e24..82d0634 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -200,6 +200,8 @@
   Removed the ACCURATE and LEGACY options (they are no longer useable)
   Use the old scaling method for background if png_set_chop_16() was
     called.
+  Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED
+
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
 (subscription required; visit
diff --git a/CHANGES b/CHANGES
index 0d4e02b..552e6d7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3463,6 +3463,7 @@
   Removed the ACCURATE and LEGACY options (they are no longer useable)
   Use the old scaling method for background if png_set_chop_16() was
     called.
+  Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
diff --git a/png.h b/png.h
index 901e588..8c9bd6a 100644
--- a/png.h
+++ b/png.h
@@ -1427,8 +1427,10 @@
 #define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
 /* Scale a 16-bit depth file down to 8-bit, accurately. */
 PNG_EXPORT(48, void, png_set_strip_16, (png_structp png_ptr));
+#  ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
 /* Strip the second byte of information from a 16-bit depth file. */
 PNG_EXPORT(229, void, png_set_chop_16, (png_structp png_ptr));
+#  endif
 #endif
 
 #ifdef PNG_READ_QUANTIZE_SUPPORTED
diff --git a/pngpriv.h b/pngpriv.h
index ad0ef80..92428b8 100644
--- a/pngpriv.h
+++ b/pngpriv.h
@@ -823,8 +823,10 @@
 PNG_EXTERN void png_do_scale_16_to_8 PNGARG((png_row_infop row_info,
     png_bytep row));
 
+#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
 PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info,
     png_bytep row));
+#endif
 PNG_EXTERN void png_do_scale_16_to_8 PNGARG((png_row_infop row_info,
     png_bytep row));
 #endif
diff --git a/pngrtran.c b/pngrtran.c
index 01f5463..53b2713 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -143,9 +143,12 @@
       return;
 
    png_ptr->transformations |= PNG_16_TO_8;
+#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
    png_ptr->transformations &= ~PNG_CHOP_16_TO_8;
+#endif
 }
 
+#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
 /* Chop 16-bit depth files to 8-bit depth */
 void PNGAPI
 png_set_chop_16(png_structp png_ptr)
@@ -159,6 +162,7 @@
    png_ptr->transformations &= ~PNG_16_TO_8;
 }
 #endif
+#endif /* PNG_READ_16_TO_8_SUPPORTED */
 
 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
 void PNGAPI
@@ -1454,7 +1458,7 @@
        * present, so that case is ok (until do_expand_16 is moved.)
        */
 
-      if (png_ptr->transformations & PNG_CHOP_16_TO_8)
+      if (png_ptr->transformations & PNG_16_TO_8)
       {
 #     define CHOP(x) (x)=((png_uint_16)(((png_uint_32)(x)*255+32895) >> 16))
       CHOP(png_ptr->background.red);
@@ -1463,17 +1467,19 @@
       CHOP(png_ptr->background.gray);
 #     undef CHOP
       }
+#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
       else /* Use pre-libpng-1.5.4 inaccurate "ACCURATE" scaling */
       {
-#     define CHOP(x) ((png_uint_16)((2*(png_uint_32)(x) + 257)/514))
+#     define CHOP(x) (x)=((png_uint_16)((2*(png_uint_32)(x) + 257)/514))
       CHOP(png_ptr->background.red);
       CHOP(png_ptr->background.green);
       CHOP(png_ptr->background.blue);
       CHOP(png_ptr->background.gray);
 #     undef CHOP
       }
+#endif /* PNG_READ_CHOP_16_TO_8_SUPPORTED */
    }
-#endif
+#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */
 
    /* NOTE: below 'PNG_READ_ALPHA_MODE_SUPPORTED' is presumed to also enable the
     * background support (see the comments in scripts/pnglibconf.dfa), this
@@ -2149,8 +2155,10 @@
 #ifdef PNG_READ_16_TO_8_SUPPORTED
    if (png_ptr->transformations & PNG_16_TO_8)
       png_do_scale_16_to_8(&(png_ptr->row_info), png_ptr->row_buf + 1);
+#  ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
    else if (png_ptr->transformations & PNG_CHOP_16_TO_8)
       png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1);
+#  endif
 #endif
 
 #ifdef PNG_READ_QUANTIZE_SUPPORTED
diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa
index db4ae5b..b59bd47 100644
--- a/scripts/pnglibconf.dfa
+++ b/scripts/pnglibconf.dfa
@@ -293,8 +293,8 @@
 
 # Disabling READ_16BIT does not disable reading 16-bit PNG files, but it
 # forces them to be chopped down to 8-bit, and disables any 16-bit
-# processing after that has happened.  You need to be sure to enable READ_16_TO_8
-# when you disable READ_16BIT for this to work properly.
+# processing after that has happened.  You need to be sure to enable
+# READ_16_TO_8 when you disable READ_16BIT for this to work properly.
 
 option READ_16BIT requires READ enables 16BIT
 
@@ -346,8 +346,6 @@
 
 option BUILD_GRAYSCALE_PALETTE
 
-option READ_16_TO_8_ACCURATE_SCALE requires READ
-
 # IN DEVELOPMENT
 # These are currently experimental features; define them if you want
 
@@ -552,7 +550,10 @@
 
 # png_save_int_32 is required by the ancillary chunks oFFs and pCAL
 
-# added at libpng-1.5.3
+# added at libpng-1.5.4
+
+option READ_CHOP_16_TO_8 requires READ_16_TO_8
+
 option WRITE_OPTIMIZE_CMF requires WRITE
 
 option READ_COMPRESSED_TEXT disabled
@@ -570,7 +571,6 @@
 option WRITE_zTXt enables WRITE_COMPRESSED_TEXT
 option WRITE_COMPRESSED_TEXT enables WRITE_TEXT
 
-
 # Turn this off to disable png_read_png() and png_write_png() and
 # leave the row_pointers member out of the info structure.
 
diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt
index dd470dd..78df974 100644
--- a/scripts/pnglibconf.h.prebuilt
+++ b/scripts/pnglibconf.h.prebuilt
@@ -76,6 +76,7 @@
 #define PNG_READ_BGR_SUPPORTED
 #define PNG_READ_bKGD_SUPPORTED
 #define PNG_READ_cHRM_SUPPORTED
+#define PNG_READ_CHOP_16_TO_8_SUPPORTED
 #define PNG_READ_COMPOSITE_NODIV_SUPPORTED
 #define PNG_READ_EXPAND_16_SUPPORTED
 #define PNG_READ_EXPAND_SUPPORTED