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

Unified Diff: src/codec/SkPngCodec.cpp

Issue 2288163003: Add Alpha8 support to SkPNGImageEncoder Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « src/codec/SkAndroidCodec.cpp ('k') | src/codec/SkSwizzler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkPngCodec.cpp
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 2c13b12c7e75ffa00a3e04da067def657fa35141..853334d71b635d728a775e87e604ffa9eba2bcbf 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -764,6 +764,18 @@ static bool read_header(SkStream* stream, SkPngChunkReader* chunkReader, SkCodec
}
}
+ if (PNG_COLOR_TYPE_GRAY == encodedColorType) {
+ png_textp text;
+ if (png_get_text(png_ptr, info_ptr, &text, nullptr)) {
+ if (0 == strcmp("SkColorType", text->key) && 0 == strcmp("Alpha8", text->text)) {
msarett 2016/08/30 14:30:38 Ideally, we store these strings somewhere that is
+ // Recommend a decode to Alpha8 if our custom encoder has marked
+ // the image as Alpha8.
+ imageInfo = imageInfo.makeColorType(kAlpha_8_SkColorType)
+ .makeAlphaType(kPremul_SkAlphaType);
+ }
+ }
+ }
+
if (1 == numberPasses) {
*outCodec = new SkPngNormalCodec(encodedInfo, imageInfo, stream,
chunkReader, png_ptr, info_ptr, bitDepth);
« no previous file with comments | « src/codec/SkAndroidCodec.cpp ('k') | src/codec/SkSwizzler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698