summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2011-06-16 09:39:40 -0500
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2011-06-16 09:39:40 -0500
commit857dbbe7cce2474bd2d11574c1cfade57a737d6d (patch)
treed32e86d1c5821552cd9f01a24b5bd93ca83e865e
parent3fb7c07ea5d663e6be3ee96166cac401aa4098a5 (diff)
downloadlibpng-857dbbe7cce2474bd2d11574c1cfade57a737d6d.tar.gz
[devel] Revised example.c to demonstrate png_set_chop_16().
-rw-r--r--example.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/example.c b/example.c
index 2c1f27da6..142213432 100644
--- a/example.c
+++ b/example.c
@@ -187,8 +187,15 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
* are mutually exclusive.
*/
- /* Tell libpng to strip 16 bit/color files down to 8 bits/color */
- png_set_strip_16(png_ptr);
+ /* Tell libpng to strip 16 bit/color files down to 8 bits/color.
+ * Use accurate scaling if it's available, otherwise just chop off the
+ * low byte.
+ */
+#ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
+ png_set_strip_16(png_ptr);
+#else
+ png_set_chop_16(png_ptr);
+#endif
/* Strip alpha bytes from the input data without combining with the
* background (not recommended).