Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2657)

Unified Diff: Source/platform/image-decoders/png/PNGImageDecoder.cpp

Issue 774103002: Color-correct PNG images that have an sRGB chunk (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adjust tables/mozilla/marvin/backgr_* Mac and Win. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/image-decoders/png/PNGImageDecoder.cpp
diff --git a/Source/platform/image-decoders/png/PNGImageDecoder.cpp b/Source/platform/image-decoders/png/PNGImageDecoder.cpp
index e766fe41fc113371879caf9391a480a41a02dda7..2ae3b5a9a6134de37c37ecc259b755e98eb138c3 100644
--- a/Source/platform/image-decoders/png/PNGImageDecoder.cpp
+++ b/Source/platform/image-decoders/png/PNGImageDecoder.cpp
@@ -168,16 +168,20 @@ public:
m_transform = 0;
}
- void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
+ void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha, bool sRGB)
{
clearColorTransform();
- if (colorProfile.isEmpty())
+ if (colorProfile.isEmpty() && !sRGB)
return;
qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
if (!deviceProfile)
return;
- qcms_profile* inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
+ qcms_profile* inputProfile = 0;
+ if (!colorProfile.isEmpty())
+ inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
+ else
+ inputProfile = qcms_profile_sRGB();
if (!inputProfile)
return;
// We currently only support color profiles for RGB and RGBA images.
@@ -244,9 +248,15 @@ ImageFrame* PNGImageDecoder::frameBufferAtIndex(size_t index)
}
#if USE(QCMSLIB)
-static void readColorProfile(png_structp png, png_infop info, ColorProfile& colorProfile)
+static void getColorProfile(png_structp png, png_infop info, ColorProfile& colorProfile, bool& sRGB)
{
#ifdef PNG_iCCP_SUPPORTED
+ ASSERT(colorProfile.isEmpty());
+ if (png_get_valid(png, info, PNG_INFO_sRGB)) {
+ sRGB = true;
+ return;
+ }
+
char* profileName;
int compressionType;
#if (PNG_LIBPNG_VER < 10500)
@@ -268,7 +278,6 @@ static void readColorProfile(png_structp png, png_infop info, ColorProfile& colo
else if (!ImageDecoder::inputDeviceColorProfile(profileData, profileLength))
ignoreProfile = true;
- ASSERT(colorProfile.isEmpty());
if (!ignoreProfile)
colorProfile.append(profileData, profileLength);
#endif
@@ -325,10 +334,11 @@ void PNGImageDecoder::headerAvailable()
// 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.
+ bool sRGB = false;
ColorProfile colorProfile;
- readColorProfile(png, info, colorProfile);
- bool decodedImageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCount;
- m_reader->createColorTransform(colorProfile, decodedImageHasAlpha);
+ getColorProfile(png, info, colorProfile, sRGB);
+ bool imageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCount;
+ m_reader->createColorTransform(colorProfile, imageHasAlpha, sRGB);
m_hasColorProfile = !!m_reader->colorTransform();
}
#endif
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698