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

Unified Diff: samplecode/DecodeFile.h

Issue 2263203002: 'F' will toggle filtering for the --picture sample (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | samplecode/SamplePictFile.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
« no previous file with comments | « no previous file | samplecode/SamplePictFile.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698