Index: dm/DMSrcSink.cpp |
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp |
index 91f4e238c28b2aa96ec761b019f3816ffc8f171f..6f6664f27ce2266bd12156f1ae973cada399ec25 100644 |
--- a/dm/DMSrcSink.cpp |
+++ b/dm/DMSrcSink.cpp |
@@ -141,15 +141,27 @@ Error ImageSrc::draw(SkCanvas* canvas) const { |
SkISize ImageSrc::size() const { |
SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); |
- SkBitmap bitmap; |
- if (!encoded || !SkImageDecoder::DecodeMemory(encoded->data(), |
- encoded->size(), |
- &bitmap, |
- kUnknown_SkColorType, |
- SkImageDecoder::kDecodeBounds_Mode)) { |
- return SkISize::Make(0,0); |
+ if (FLAGS_codec) { |
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
+ if (!codec) { |
+ return SkISize::Make(0,0); |
+ } |
+ SkImageInfo info; |
+ if (!codec->getInfo(&info)) { |
+ return SkISize::Make(0,0); |
+ } |
+ return info.dimensions(); |
+ } else { |
+ SkBitmap bitmap; |
+ if (!encoded || !SkImageDecoder::DecodeMemory(encoded->data(), |
+ encoded->size(), |
+ &bitmap, |
+ kUnknown_SkColorType, |
+ SkImageDecoder::kDecodeBounds_Mode)) { |
+ return SkISize::Make(0,0); |
+ } |
+ return bitmap.dimensions(); |
} |
- return bitmap.dimensions(); |
} |
Name ImageSrc::name() const { |