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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp

Issue 2942873002: Fix the color issue in CMYK jpeg images.
Patch Set: Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. 2 * Copyright (C) 2006 Apple Computer, Inc.
3 * 3 *
4 * Portions are Copyright (C) 2001-6 mozilla.org 4 * Portions are Copyright (C) 2001-6 mozilla.org
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Stuart Parmenter <stuart@mozilla.com> 7 * Stuart Parmenter <stuart@mozilla.com>
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public 10 * modify it under the terms of the GNU Lesser General Public
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 jpeg_calc_output_dimensions(&info_); 446 jpeg_calc_output_dimensions(&info_);
447 decoder_->SetDecodedSize(info_.output_width, info_.output_height); 447 decoder_->SetDecodedSize(info_.output_width, info_.output_height);
448 448
449 decoder_->SetOrientation(ReadImageOrientation(Info())); 449 decoder_->SetOrientation(ReadImageOrientation(Info()));
450 450
451 // Allow color management of the decoded RGBA pixels if possible. 451 // Allow color management of the decoded RGBA pixels if possible.
452 if (!decoder_->IgnoresColorSpace()) { 452 if (!decoder_->IgnoresColorSpace()) {
453 JOCTET* profile = nullptr; 453 JOCTET* profile = nullptr;
454 unsigned profile_length = 0; 454 unsigned profile_length = 0;
455 if (read_icc_profile(Info(), &profile, &profile_length)) { 455 if (read_icc_profile(Info(), &profile, &profile_length)) {
456 // Default set to ICC type to RGB
457 SkColorSpace::ICCTypeFlag icc_type = SkColorSpace::kRGB_ICCTypeFlag;
458
459 // Update ICC type to CMYK JPEG image
460 if (info_.out_color_space == JCS_CMYK)
461 icc_type = SkColorSpace::kCMYK_ICCTypeFlag;
462
456 Decoder()->SetEmbeddedColorProfile(reinterpret_cast<char*>(profile), 463 Decoder()->SetEmbeddedColorProfile(reinterpret_cast<char*>(profile),
457 profile_length); 464 profile_length, icc_type);
458 free(profile); 465 free(profile);
459 } 466 }
460 if (Decoder()->ColorTransform()) { 467 if (Decoder()->ColorTransform()) {
461 override_color_space = JCS_UNKNOWN; 468 override_color_space = JCS_UNKNOWN;
462 } 469 }
463 } 470 }
464 if (override_color_space == JCS_YCbCr) { 471 if (override_color_space == JCS_YCbCr) {
465 info_.out_color_space = JCS_YCbCr; 472 info_.out_color_space = JCS_YCbCr;
466 info_.raw_data_out = TRUE; 473 info_.raw_data_out = TRUE;
467 uv_size_ = ComputeYUVSize( 474 uv_size_ = ComputeYUVSize(
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 int y = info->output_scanline; 850 int y = info->output_scanline;
844 // Request one scanline: returns 0 or 1 scanlines. 851 // Request one scanline: returns 0 or 1 scanlines.
845 if (jpeg_read_scanlines(info, samples, 1) != 1) 852 if (jpeg_read_scanlines(info, samples, 1) != 1)
846 return false; 853 return false;
847 854
848 ImageFrame::PixelData* pixel = buffer.GetAddr(0, y); 855 ImageFrame::PixelData* pixel = buffer.GetAddr(0, y);
849 for (int x = 0; x < width; ++pixel, ++x) 856 for (int x = 0; x < width; ++pixel, ++x)
850 SetPixel<colorSpace>(pixel, samples, x); 857 SetPixel<colorSpace>(pixel, samples, x);
851 858
852 SkColorSpaceXform* xform = reader->Decoder()->ColorTransform(); 859 SkColorSpaceXform* xform = reader->Decoder()->ColorTransform();
853 if (JCS_RGB == colorSpace && xform) { 860 if (xform) {
854 ImageFrame::PixelData* row = buffer.GetAddr(0, y); 861 ImageFrame::PixelData* row = buffer.GetAddr(0, y);
855 xform->apply(XformColorFormat(), row, XformColorFormat(), row, width, 862 xform->apply(XformColorFormat(), row, XformColorFormat(), row, width,
856 kOpaque_SkAlphaType); 863 kOpaque_SkAlphaType);
857 } 864 }
858 } 865 }
859 866
860 buffer.SetPixelsChanged(true); 867 buffer.SetPixelsChanged(true);
861 return true; 868 return true;
862 } 869 }
863 870
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 // has failed. 1015 // has failed.
1009 if (!reader_->Decode(only_size) && IsAllDataReceived()) 1016 if (!reader_->Decode(only_size) && IsAllDataReceived())
1010 SetFailed(); 1017 SetFailed();
1011 1018
1012 // If decoding is done or failed, we don't need the JPEGImageReader anymore. 1019 // If decoding is done or failed, we don't need the JPEGImageReader anymore.
1013 if (IsComplete(this, only_size) || Failed()) 1020 if (IsComplete(this, only_size) || Failed())
1014 reader_.reset(); 1021 reader_.reset();
1015 } 1022 }
1016 1023
1017 } // namespace blink 1024 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698