aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/DecodeFile.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-08-22 07:41:46 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-22 07:41:46 -0700
commitccebcec4aca71fd17626b45f27fbe613bfa18b64 (patch)
tree74593bae0dde80a1b4c9cab8336e82b69ae6ac30 /samplecode/DecodeFile.h
parent35bb74b444bc4a9ed2f437d97c6a943012990fe3 (diff)
'F' will toggle filtering for the --picture sample
Diffstat (limited to 'samplecode/DecodeFile.h')
-rw-r--r--samplecode/DecodeFile.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/samplecode/DecodeFile.h b/samplecode/DecodeFile.h
index 3995238bd0..801d67ce97 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;
+}