diff options
author | msarett <msarett@google.com> | 2016-02-11 10:49:31 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-11 10:49:31 -0800 |
commit | f4004f9309242533dea68c95433020db71fc65c8 (patch) | |
tree | ec2f1652366a883c243c01a9760c6d6fb934708d /src/codec/SkBmpCodec.cpp | |
parent | 17315c20e7a87d6e92fdc4623d2e27303037a051 (diff) |
Support more color types for ICOs
BUG=skia:4620
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1694513002
Review URL: https://codereview.chromium.org/1694513002
Diffstat (limited to 'src/codec/SkBmpCodec.cpp')
-rw-r--r-- | src/codec/SkBmpCodec.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp index 4828f7f7e2..cbba28c172 100644 --- a/src/codec/SkBmpCodec.cpp +++ b/src/codec/SkBmpCodec.cpp @@ -476,6 +476,14 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) { } if (codecOut) { + // BMPs-in-ICOs contain an alpha mask after the image which means we + // cannot guarantee that an image is opaque, even if the bmp thinks + // it is. + bool isOpaque = kOpaque_SkAlphaType == alphaType; + if (inIco) { + alphaType = kUnpremul_SkAlphaType; + } + // Set the image info const SkImageInfo& imageInfo = SkImageInfo::Make(width, height, colorType, alphaType); @@ -486,7 +494,7 @@ bool SkBmpCodec::ReadHeader(SkStream* stream, bool inIco, SkCodec** codecOut) { // We require streams to have a memory base for Bmp-in-Ico decodes. SkASSERT(!inIco || nullptr != stream->getMemoryBase()); *codecOut = new SkBmpStandardCodec(imageInfo, stream, bitsPerPixel, numColors, - bytesPerColor, offset - bytesRead, rowOrder, inIco); + bytesPerColor, offset - bytesRead, rowOrder, isOpaque, inIco); return true; case kBitMask_BmpInputFormat: // Bmp-in-Ico must be standard mode |