Index: src/codec/SkCodecImageGenerator.cpp |
diff --git a/src/codec/SkCodecImageGenerator.cpp b/src/codec/SkCodecImageGenerator.cpp |
index e579da92f6f435c8a34ba21aae5fdfb02f2cbe23..db13aaea2973f62445477f8fefdf42bef948d761 100644 |
--- a/src/codec/SkCodecImageGenerator.cpp |
+++ b/src/codec/SkCodecImageGenerator.cpp |
@@ -16,16 +16,24 @@ SkImageGenerator* SkCodecImageGenerator::NewFromEncodedCodec(SkData* data) { |
return new SkCodecImageGenerator(codec, data); |
} |
-static SkImageInfo make_premul(const SkImageInfo& info) { |
- if (kUnpremul_SkAlphaType == info.alphaType()) { |
- return info.makeAlphaType(kPremul_SkAlphaType); |
- } |
+// FIXME: We should expose information about the encoded format on the |
+// SkImageGenerator, so the client can interpret the encoded |
+// format and request an output format. For now, as a workaround, |
+// we guess what output format the client wants. |
+static SkImageInfo fix_info(const SkCodec& codec) { |
+ const SkImageInfo& info = codec.getInfo(); |
+ SkAlphaType alphaType = (kUnpremul_SkAlphaType == info.alphaType()) ? kPremul_SkAlphaType : |
+ info.alphaType(); |
+ |
+ // Crudely guess that the presence of a color space means sRGB. |
+ SkColorProfileType profileType = (codec.getColorSpace()) ? kSRGB_SkColorProfileType : |
+ kLinear_SkColorProfileType; |
- return info; |
+ return SkImageInfo::Make(info.width(), info.height(), info.colorType(), alphaType, profileType); |
} |
SkCodecImageGenerator::SkCodecImageGenerator(SkCodec* codec, SkData* data) |
- : INHERITED(make_premul(codec->getInfo())) |
+ : INHERITED(fix_info(*codec)) |
, fCodec(codec) |
, fData(SkRef(data)) |
{} |