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

Unified Diff: tools/viewer/ImageSlide.cpp

Issue 2195523002: Revert of Add color space xform support to SkJpegCodec (includes F16!) (Closed) Base URL: https://skia.googlesource.com/skia.git@drop
Patch Set: Created 4 years, 5 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 | « tests/ColorSpaceXformTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/viewer/ImageSlide.cpp
diff --git a/tools/viewer/ImageSlide.cpp b/tools/viewer/ImageSlide.cpp
index 7dcee5d5ac0fac6b278038b7ed1833bc79673803..b0471547bcb3180efbd0d2fbac5b52a58cbf39bc 100644
--- a/tools/viewer/ImageSlide.cpp
+++ b/tools/viewer/ImageSlide.cpp
@@ -37,18 +37,20 @@
void ImageSlide::load(SkScalar, SkScalar) {
sk_sp<SkData> encoded = SkData::MakeFromFileName(fPath.c_str());
+ fImage = SkImage::MakeFromEncoded(encoded);
+ fImage->asLegacyBitmap(&fOriginalBitmap, SkImage::kRO_LegacyBitmapMode);
+
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded.get()));
- if (!codec) {
- return;
+ sk_sp<SkColorSpace> srcSpace = sk_ref_sp(codec->getInfo().colorSpace());
+ sk_sp<SkColorSpace> dstSpace = SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named);
+ std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(srcSpace, dstSpace);
+ fOriginalBitmap.deepCopyTo(&fXformedBitmap);
+ uint32_t* row = (uint32_t*) fXformedBitmap.getPixels();
+ for (int y = 0; y < fXformedBitmap.height(); y++) {
+ xform->applyTo8888(row, row, fXformedBitmap.width());
+ row = SkTAddOffset<uint32_t>(row, fXformedBitmap.rowBytes());
}
-
- fOriginalBitmap.allocPixels(codec->getInfo());
- codec->getPixels(codec->getInfo(), fOriginalBitmap.getPixels(), fOriginalBitmap.rowBytes());
-
- SkImageInfo xformedInfo = codec->getInfo().makeColorSpace(
- SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named));
- fXformedBitmap.allocPixels(xformedInfo);
- codec->getPixels(xformedInfo, fXformedBitmap.getPixels(), fXformedBitmap.rowBytes());
+ fXformedBitmap.notifyPixelsChanged(); // This is needed for the deepCopy
}
void ImageSlide::unload() {
« no previous file with comments | « tests/ColorSpaceXformTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698