Index: samplecode/DecodeFile.h |
diff --git a/samplecode/DecodeFile.h b/samplecode/DecodeFile.h |
index 3995238bd04208324fb1539e1190a136ded05465..801d67ce979b1fbd0ca9d435a5d16a299284b047 100644 |
--- a/samplecode/DecodeFile.h |
+++ b/samplecode/DecodeFile.h |
@@ -8,9 +8,11 @@ |
#include "SkBitmap.h" |
#include "SkCodec.h" |
#include "SkData.h" |
+#include "SkImage.h" |
-inline bool decode_file(const char* filename, SkBitmap* bitmap, |
- SkColorType colorType = kN32_SkColorType, bool requireUnpremul = false) { |
+static inline bool decode_file(const char* filename, SkBitmap* bitmap, |
+ SkColorType colorType = kN32_SkColorType, |
+ bool requireUnpremul = false) { |
SkASSERT(kIndex_8_SkColorType != colorType); |
sk_sp<SkData> data(SkData::MakeFromFileName(filename)); |
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data.get())); |
@@ -29,3 +31,8 @@ inline bool decode_file(const char* filename, SkBitmap* bitmap, |
return SkCodec::kSuccess == codec->getPixels(info, bitmap->getPixels(), bitmap->rowBytes()); |
} |
+ |
+static inline sk_sp<SkImage> decode_file(const char filename[]) { |
+ sk_sp<SkData> data(SkData::MakeFromFileName(filename)); |
+ return data ? SkImage::MakeFromEncoded(data) : nullptr; |
+} |