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

Unified Diff: tools/picture_utils.cpp

Issue 283123002: render_pictures: add --mismatchPath flag (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix SkDebuggerGUI Created 6 years, 7 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 | « tools/picture_utils.h ('k') | tools/render_pictures_main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/picture_utils.cpp
diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp
index 4bcdf8a964620fe974d2eda915c4f67f61341844..c698a69835b96558a515eadf63791d0e0a0af3ad 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
« no previous file with comments | « tools/picture_utils.h ('k') | tools/render_pictures_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698