Index: tools/Resources.cpp |
diff --git a/tools/Resources.cpp b/tools/Resources.cpp |
index 606c5c4968c52fcb7544ba47fc5fd0ba1285269d..50c08922fa1acc66f61960ce45eb8057ee84272e 100644 |
--- a/tools/Resources.cpp |
+++ b/tools/Resources.cpp |
@@ -6,8 +6,10 @@ |
*/ |
#include "Resources.h" |
- |
+#include "SkBitmap.h" |
#include "SkCommandLineFlags.h" |
+#include "SkData.h" |
+#include "SkDecodingImageGenerator.h" |
#include "SkOSFile.h" |
DEFINE_string2(resourcePath, i, "resources", "Directory with test resources: images, fonts, etc."); |
@@ -19,3 +21,12 @@ SkString GetResourcePath(const char* resource) { |
void SetResourcePath(const char* resource) { |
FLAGS_resourcePath.set(0, resource); |
} |
+ |
+bool GetResourceAsBitmap(const char* resource, SkBitmap* dst) { |
+ SkString resourcePath = GetResourcePath(resource); |
+ SkAutoTUnref<SkData> resourceData( |
+ SkData::NewFromFileName(resourcePath.c_str())); |
+ return resourceData && SkInstallDiscardablePixelRef( |
+ SkDecodingImageGenerator::Create( |
+ resourceData, SkDecodingImageGenerator::Options()), dst); |
+} |