aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2015-03-16 08:27:53 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-16 08:27:53 -0700
commit3675874468de7228944ce21922e6ec863f5f2310 (patch)
tree0cee05f6f1703fecf3ba6850a7dcac029ef26407 /dm
parentdedc2d8e8dc635ff43e6b314b280e3efe85ce8a7 (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.cpp28
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 {