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

Unified Diff: tools/skimage_main.cpp

Issue 25726004: Fixes for decoding to A8. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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
Index: tools/skimage_main.cpp
diff --git a/tools/skimage_main.cpp b/tools/skimage_main.cpp
index d98a6191c30a3201f689f0f18d9e2dd061ef734d..0d60f8afe96ddcd86a6a8141429a30402ea3a53b 100644
--- a/tools/skimage_main.cpp
+++ b/tools/skimage_main.cpp
@@ -111,7 +111,19 @@ static SkBitmap::Config gPrefConfig(SkBitmap::kNo_Config);
SkAutoTUnref<skiagm::JsonExpectationsSource> gJsonExpectations;
static bool write_bitmap(const char outName[], const SkBitmap& bm) {
- return SkImageEncoder::EncodeFile(outName, bm, SkImageEncoder::kPNG_Type, 100);
+ const SkBitmap* bmPtr;
+ SkBitmap bm8888;
+ if (bm.config() == SkBitmap::kA8_Config) {
+ // Copy A8 into ARGB_8888, since our image encoders do not currently
+ // support A8.
djsollen 2013/10/03 16:54:28 is that a feature that we should support?
scroggo 2013/10/03 16:58:52 Possibly, although I'd set it at a low priority. N
reed1 2013/10/04 08:56:27 Perhaps the code at this level shouldn't know if i
scroggo 2013/10/04 19:45:53 They do report failure. I have a CL at https://cod
+ if (!bm.copyTo(&bm8888, SkBitmap::kARGB_8888_Config)) {
+ return false;
+ }
+ bmPtr = &bm8888;
+ } else {
+ bmPtr = &bm;
+ }
+ return SkImageEncoder::EncodeFile(outName, *bmPtr, SkImageEncoder::kPNG_Type, 100);
}
/**
@@ -495,7 +507,8 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath)
}
}
- if (FLAGS_reencode) {
+ // Do not attempt to re-encode A8, since our image encoders do not support encoding to A8.
+ if (FLAGS_reencode && bitmap.config() != SkBitmap::kA8_Config) {
// Encode to the format the file was originally in, or PNG if the encoder for the same
// format is unavailable.
SkImageDecoder::Format format = codec->getFormat();
« src/images/SkImageDecoder_libpng.cpp ('K') | « src/images/SkImageDecoder_libpng.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698