summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-11-22 09:09:45 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2012-11-22 09:10:13 +0100
commit470286ecfe79d59df14944e5b5d34630fc739391 (patch)
tree43983212872e06cebefd2ae474418fa2908ca54c /Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
parent23037105e948c2065da5a937d3a2396b0ff45c1e (diff)
Imported WebKit commit e89504fa9195b2063b2530961d4b73dd08de3242 (http://svn.webkit.org/repository/webkit/trunk@135485)
Change-Id: I03774e5ac79721c13ffa30d152537a74d0b12e66 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp')
-rw-r--r--Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp b/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
index cc75cb5b2..b0c2adc9f 100644
--- a/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
+++ b/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
@@ -334,20 +334,6 @@ void PNGImageDecoder::headerAvailable()
int bitDepth, colorType, interlaceType, compressionType, filterType, channels;
png_get_IHDR(png, info, &width, &height, &bitDepth, &colorType, &interlaceType, &compressionType, &filterType);
- if ((colorType == PNG_COLOR_TYPE_RGB || colorType == PNG_COLOR_TYPE_RGB_ALPHA) && !m_ignoreGammaAndColorProfile) {
- // We currently support color profiles only for RGB and RGBA PNGs. Supporting
- // color profiles for gray-scale images is slightly tricky, at least using the
- // CoreGraphics ICC library, because we expand gray-scale images to RGB but we
- // don't similarly transform the color profile. We'd either need to transform
- // the color profile or we'd need to decode into a gray-scale image buffer and
- // hand that to CoreGraphics.
- readColorProfile(png, info, m_colorProfile);
-#if USE(QCMSLIB)
- m_reader->createColorTransform(m_colorProfile, colorType & PNG_COLOR_MASK_ALPHA);
- m_colorProfile.clear();
-#endif
- }
-
// The options we set here match what Mozilla does.
// Expand to ensure we use 24-bit for RGB and 32-bit for RGBA.
@@ -367,6 +353,21 @@ void PNGImageDecoder::headerAvailable()
if (colorType == PNG_COLOR_TYPE_GRAY || colorType == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png);
+ if ((colorType & PNG_COLOR_MASK_COLOR) && !m_ignoreGammaAndColorProfile) {
+ // We only support color profiles for color PALETTE and RGB[A] PNG. Supporting
+ // color profiles for gray-scale images is slightly tricky, at least using the
+ // CoreGraphics ICC library, because we expand gray-scale images to RGB but we
+ // do not similarly transform the color profile. We'd either need to transform
+ // the color profile or we'd need to decode into a gray-scale image buffer and
+ // hand that to CoreGraphics.
+ readColorProfile(png, info, m_colorProfile);
+#if USE(QCMSLIB)
+ bool decodedImageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCount;
+ m_reader->createColorTransform(m_colorProfile, decodedImageHasAlpha);
+ m_colorProfile.clear();
+#endif
+ }
+
// Deal with gamma and keep it under our control.
double gamma;
if (!m_ignoreGammaAndColorProfile && png_get_gAMA(png, info, &gamma)) {