From 2312cdcaa36e1c52ebe319ae4fd5c4fa8a567111 Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Thu, 8 Dec 2016 10:15:43 -0500 Subject: [PATCH] Decode to sRGB in BitmapFactory Test: Verified content looks as expected. Color correct modes are well tested in Skia. Change-Id: I922540f0a16df8693e2c30944b595538c34c583a --- core/jni/android/graphics/BitmapFactory.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index 762a3f35ad9e1..18ed0ed72190e 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -395,9 +395,11 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding SkAlphaType alphaType = codec->computeOutputAlphaType(requireUnpremultiplied); const SkImageInfo decodeInfo = SkImageInfo::Make(size.width(), size.height(), - decodeColorType, alphaType, GraphicsJNI::defaultColorSpace()); + decodeColorType, alphaType, codec->computeOutputColorSpace(decodeColorType)); - SkImageInfo bitmapInfo = decodeInfo; + // We always decode to sRGB, but only mark the bitmap with a color space if linear + // blending is enabled. + SkImageInfo bitmapInfo = decodeInfo.makeColorSpace(GraphicsJNI::defaultColorSpace()); if (decodeColorType == kGray_8_SkColorType) { // The legacy implementation of BitmapFactory used kAlpha8 for // grayscale images (before kGray8 existed). While the codec