diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-15 15:10:48 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-15 15:10:48 +0000 |
commit | 3f0451772109959fcb79bacf2c9a03e0eb39ff27 (patch) | |
tree | 19e1b86cc9824172c7f1c422591cc51314203fdb /tools/picture_utils.cpp | |
parent | 76ac7f81d39a99616541ead9c40aa6d208b517af (diff) |
render_pictures: add --mismatchPath flag
When set, it will only write out images that don't match expectations.
BUG=skia:1942
R=rmistry@google.com
Author: epoger@google.com
Review URL: https://codereview.chromium.org/283123002
git-svn-id: http://skia.googlecode.com/svn/trunk@14748 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/picture_utils.cpp')
-rw-r--r-- | tools/picture_utils.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp index 4bcdf8a964..c698a69835 100644 --- a/tools/picture_utils.cpp +++ b/tools/picture_utils.cpp @@ -6,11 +6,13 @@ */ #include "picture_utils.h" -#include "SkColorPriv.h" #include "SkBitmap.h" +#include "SkColorPriv.h" +#include "SkImageEncoder.h" +#include "SkOSFile.h" #include "SkPicture.h" -#include "SkString.h" #include "SkStream.h" +#include "SkString.h" static bool is_path_seperator(const char chr) { #if defined(SK_BUILD_FOR_WIN) @@ -99,4 +101,23 @@ namespace sk_tools { bitmap->allocPixels(); bitmap->eraseColor(SK_ColorTRANSPARENT); } -} + + bool write_bitmap_to_disk(const SkBitmap& bm, const SkString& dirPath, + const char *subdirOrNull, const SkString& baseName) { + SkString partialPath; + if (subdirOrNull) { + partialPath = SkOSPath::SkPathJoin(dirPath.c_str(), subdirOrNull); + sk_mkdir(partialPath.c_str()); + } else { + partialPath.set(dirPath); + } + SkString fullPath = SkOSPath::SkPathJoin(partialPath.c_str(), baseName.c_str()); + if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPNG_Type, 100)) { + return true; + } else { + SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str()); + return false; + } + } + +} // namespace sk_tools |