uint32_t numColorTypes;
switch (codec->getInfo().colorType()) {
case kGray_8_SkColorType:
- // FIXME: Is this a long term solution for testing wbmps decodes to kIndex8?
- // Further discussion on this topic is at https://bug.skia.org/3683 .
- // This causes us to try to convert grayscale jpegs to kIndex8. We currently
- // fail non-fatally in this case.
colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType;
colorTypes[1] = CodecSrc::kGrayscale_Always_DstColorType;
- colorTypes[2] = CodecSrc::kIndex8_Always_DstColorType;
- numColorTypes = 3;
+ if (kWBMP_SkEncodedFormat == codec->getEncodedFormat()) {
+ colorTypes[2] = CodecSrc::kIndex8_Always_DstColorType;
+ numColorTypes = 3;
+ } else {
+ numColorTypes = 2;
+ }
break;
case kIndex_8_SkColorType:
colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType;
*decodeInfo = decodeInfo->makeColorType(kIndex_8_SkColorType);
break;
case CodecSrc::kGrayscale_Always_DstColorType:
- if (kRGB_565_SkColorType == canvasColorType) {
+ if (kRGB_565_SkColorType == canvasColorType ||
+ kOpaque_SkAlphaType != decodeInfo->alphaType()) {
return false;
}
*decodeInfo = decodeInfo->makeColorType(kGray_8_SkColorType);
break;
default:
+ if (kRGB_565_SkColorType == canvasColorType &&
+ kOpaque_SkAlphaType != decodeInfo->alphaType()) {
+ return false;
+ }
*decodeInfo = decodeInfo->makeColorType(canvasColorType);
break;
}
// available.
case SkCodec::kIncompleteInput:
break;
- case SkCodec::kInvalidConversion:
- return Error::Nonfatal("Incompatible colortype conversion");
default:
// Everything else is considered a failure.
return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str());
case SkCodec::kSuccess:
case SkCodec::kIncompleteInput:
break;
- case SkCodec::kInvalidConversion:
- return Error::Nonfatal("Cannot convert to requested color type.");
default:
return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str());
}