diff options
author | msarett <msarett@google.com> | 2015-03-16 08:27:53 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-16 08:27:53 -0700 |
commit | 3675874468de7228944ce21922e6ec863f5f2310 (patch) | |
tree | 0cee05f6f1703fecf3ba6850a7dcac029ef26407 /dm | |
parent | dedc2d8e8dc635ff43e6b314b280e3efe85ce8a7 (diff) |
Implementation of image decoding for bmp files, in accordance with the new API.
Currently decodes to opaque and unpremul.
Tested on local test suite.
BUG=skia:3257
Review URL: https://codereview.chromium.org/947283002
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DMSrcSink.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 5ca66c50e2..22dd5679e3 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -140,15 +140,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 { |