summaryrefslogtreecommitdiff
path: root/Build/source/libs/libpng/pngrtran.c
diff options
context:
space:
mode:
authorMartin Schröder <martin@oneiros.de>2007-01-05 14:13:59 +0000
committerMartin Schröder <martin@oneiros.de>2007-01-05 14:13:59 +0000
commit97707cda91a226aafbcb0e172b3e77500583cc28 (patch)
tree144b1a9efbdcb870021cdea37e2d4bcd8b83e819 /Build/source/libs/libpng/pngrtran.c
parent7f83d621a028015e39b6831decc8a3295866c5bc (diff)
libpng 1.2.15
git-svn-id: svn://tug.org/texlive/trunk@3155 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/libpng/pngrtran.c')
-rw-r--r--Build/source/libs/libpng/pngrtran.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/Build/source/libs/libpng/pngrtran.c b/Build/source/libs/libpng/pngrtran.c
index 8f6860367aa..2fa96f312ca 100644
--- a/Build/source/libs/libpng/pngrtran.c
+++ b/Build/source/libs/libpng/pngrtran.c
@@ -1,9 +1,9 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
- * Last changed in libpng 1.2.13 November 13, 2006
+ * Last changed in libpng 1.2.15 January 5, 2007
* For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2006 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2007 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.)
*
@@ -94,17 +94,6 @@ png_set_background(png_structp png_ptr,
png_ptr->background_gamma = (float)background_gamma;
png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0);
-
- /* Note: if need_expand is set and color_type is either RGB or RGB_ALPHA
- * (in which case need_expand is superfluous anyway), the background color
- * might actually be gray yet not be flagged as such. This is not a problem
- * for the current code, which uses PNG_BACKGROUND_IS_GRAY only to
- * decide when to do the png_do_gray_to_rgb() transformation.
- */
- if ((need_expand && !(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) ||
- (!need_expand && background_color->red == background_color->green &&
- background_color->red == background_color->blue))
- png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
}
#endif
@@ -732,6 +721,32 @@ png_init_read_transformations(png_structp png_ptr)
#endif
#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
+
+#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
+ /* Detect gray background and attempt to enable optimization
+ * for gray --> RGB case */
+ /* Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or
+ * RGB_ALPHA (in which case need_expand is superfluous anyway), the
+ * background color might actually be gray yet not be flagged as such.
+ * This is not a problem for the current code, which uses
+ * PNG_BACKGROUND_IS_GRAY only to decide when to do the
+ * png_do_gray_to_rgb() transformation.
+ */
+ if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
+ !(color_type & PNG_COLOR_MASK_COLOR))
+ {
+ png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
+ } else if ((png_ptr->transformations & PNG_BACKGROUND) &&
+ !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
+ (png_ptr->transformations & PNG_GRAY_TO_RGB) &&
+ png_ptr->background.red == png_ptr->background.green &&
+ png_ptr->background.red == png_ptr->background.blue)
+ {
+ png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
+ png_ptr->background.gray = png_ptr->background.red;
+ }
+#endif
+
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
(png_ptr->transformations & PNG_EXPAND))
{