aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkBmpCodec.cpp
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-02-11 10:49:31 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-11 10:49:31 -0800
commitf4004f9309242533dea68c95433020db71fc65c8 (patch)
treeec2f1652366a883c243c01a9760c6d6fb934708d /src/codec/SkBmpCodec.cpp
parent17315c20e7a87d6e92fdc4623d2e27303037a051 (diff)
Support more color types for ICOs
Diffstat (limited to 'src/codec/SkBmpCodec.cpp')
-rw-r--r--src/codec/SkBmpCodec.cpp10
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