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

Unified Diff: tools/get_images_from_skps.cpp

Issue 1828323002: Catch invalid images in get_images_from_skps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/SkJpegCodec.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/get_images_from_skps.cpp
diff --git a/tools/get_images_from_skps.cpp b/tools/get_images_from_skps.cpp
index e6bb6e2012190698ebda8359826f7d36be275861..fecce4e067df8c5969473325cbfe89125aabd456 100644
--- a/tools/get_images_from_skps.cpp
+++ b/tools/get_images_from_skps.cpp
@@ -17,6 +17,7 @@
DEFINE_string2(skps, s, "skps", "A path to a directory of skps.");
DEFINE_string2(out, o, "img-out", "A path to an output directory.");
+DEFINE_bool(test, false, "Indicates if we want to test that the images decode successfully.");
static int gKnown;
static int gUnknown;
@@ -56,6 +57,17 @@ struct Sniffer : public SkPixelSerializer {
default: gUnknown++; return;
}
+ if (FLAGS_test) {
+ SkBitmap bitmap;
+ SkImageInfo info = codec->getInfo().makeColorType(kN32_SkColorType);
+ bitmap.allocPixels(info);
+ if (SkCodec::kSuccess != codec->getPixels(info, bitmap.getPixels(), bitmap.rowBytes()))
+ {
+ gUnknown++;
+ return;
+ }
+ }
+
SkString path;
path.appendf("%s/%d.%s", gOutputDir, gKnown++, ext.c_str());
« no previous file with comments | « src/codec/SkJpegCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698