Index: gm/pixelxorxfermode.cpp |
diff --git a/gm/pixelxorxfermode.cpp b/gm/pixelxorxfermode.cpp |
index daccca8c413d23a7224300767229eb9d9df3f480..35926a81c6cd85a82153bc081c4b4ef01e9f5d1b 100644 |
--- a/gm/pixelxorxfermode.cpp |
+++ b/gm/pixelxorxfermode.cpp |
@@ -8,6 +8,7 @@ |
#include "gm.h" |
#include "Resources.h" |
+#include "SkImageDecoder.h" |
#include "SkPixelXorXfermode.h" |
#include "SkStream.h" |
@@ -23,7 +24,17 @@ |
SkISize onISize() override { return SkISize::Make(512, 512); } |
void onOnceBeforeDraw() override { |
- if (!GetResourceAsBitmap("mandrill_512.png", &fBM)) { |
+ SkImageDecoder* codec = nullptr; |
+ SkString resourcePath = GetResourcePath("mandrill_512.png"); |
+ SkFILEStream stream(resourcePath.c_str()); |
+ if (stream.isValid()) { |
+ codec = SkImageDecoder::Factory(&stream); |
+ } |
+ if (codec) { |
+ stream.rewind(); |
+ codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode); |
+ delete codec; |
+ } else { |
fBM.allocN32Pixels(1, 1); |
fBM.eraseARGB(255, 255, 0 , 0); // red == bad |
} |