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

Unified Diff: src/images/SkImageDecoder_libpng.cpp

Issue 1506663002: SkPNGImageEncoder encodes all SkColorTypes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libpng.cpp
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index a03ed10453f70d8053dc72bafee1bae8f8f5ae3f..fe72d8a9d881bf483138bf15b000680250e07550 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -827,7 +827,24 @@ private:
typedef SkImageEncoder INHERITED;
};
-bool SkPNGImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int /*quality*/) {
+bool SkPNGImageEncoder::onEncode(SkWStream* stream,
+ const SkBitmap& originalBitmap,
+ int /*quality*/) {
+ SkBitmap copy;
+ bool useCopy = false;
scroggo 2015/12/07 17:05:45 I don't think this variable is necessary. Instead
hal.canary 2015/12/07 21:34:38 done.
+ switch (originalBitmap.colorType()) {
+ case kIndex_8_SkColorType:
+ case kN32_SkColorType:
+ case kARGB_4444_SkColorType:
+ case kRGB_565_SkColorType:
+ break;
+ default:
scroggo 2015/12/07 17:05:45 So basically, what we are now supporting are: - T
hal.canary 2015/12/07 21:34:38 I added TODOs and assigned them to you.
+ if (originalBitmap.copyTo(&copy, kN32_SkColorType)) {
+ useCopy = true;
+ }
+ }
+ const SkBitmap& bitmap = useCopy ? copy : originalBitmap;
+
SkColorType ct = bitmap.colorType();
const bool hasAlpha = !bitmap.isOpaque();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698