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

Unified Diff: src/codec/SkJpegCodec.cpp

Issue 2009813003: Assign sRGB color space to unmarked jpegs and pngs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months 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 | « no previous file | src/codec/SkPngCodec.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkJpegCodec.cpp
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index 07ece6c95b5257d85b9d835fb948d13efe842cd9..5d24694708ad99fcc8284ee4b18351f2635023ad 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -222,11 +222,15 @@ bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut,
Origin orientation = get_exif_orientation(decoderMgr->dinfo());
sk_sp<SkColorSpace> colorSpace = get_icc_profile(decoderMgr->dinfo());
+ if (!colorSpace) {
+ // Treat unmarked jpegs as sRGB.
+ colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+ }
const int width = decoderMgr->dinfo()->image_width;
const int height = decoderMgr->dinfo()->image_height;
- *codecOut = new SkJpegCodec(width, height, info, stream, decoderMgr.release(), colorSpace,
- orientation);
+ *codecOut = new SkJpegCodec(width, height, info, stream, decoderMgr.release(),
+ std::move(colorSpace), orientation);
} else {
SkASSERT(nullptr != decoderMgrOut);
*decoderMgrOut = decoderMgr.release();
@@ -248,7 +252,7 @@ SkCodec* SkJpegCodec::NewFromStream(SkStream* stream) {
SkJpegCodec::SkJpegCodec(int width, int height, const SkEncodedInfo& info, SkStream* stream,
JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin origin)
- : INHERITED(width, height, info, stream, colorSpace, origin)
+ : INHERITED(width, height, info, stream, std::move(colorSpace), origin)
, fDecoderMgr(decoderMgr)
, fReadyState(decoderMgr->dinfo()->global_state)
, fSwizzlerSubset(SkIRect::MakeEmpty())
« no previous file with comments | « no previous file | src/codec/SkPngCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698