Chromium Code Reviews| Index: src/android/SkBitmapRegionCodec.cpp |
| diff --git a/src/android/SkBitmapRegionCodec.cpp b/src/android/SkBitmapRegionCodec.cpp |
| index 415b60c5ab354e9ddeac605585e02b4e68244c30..2569ac598bacf5d538060ae20d00df65deaabc84 100644 |
| --- a/src/android/SkBitmapRegionCodec.cpp |
| +++ b/src/android/SkBitmapRegionCodec.cpp |
| @@ -17,7 +17,7 @@ SkBitmapRegionCodec::SkBitmapRegionCodec(SkAndroidCodec* codec) |
| {} |
| bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator, |
| - const SkIRect& desiredSubset, int sampleSize, SkColorType dstColorType, |
| + const SkIRect& desiredSubset, int sampleSize, SkColorType prefColorType, |
| bool requireUnpremul) { |
| // Fix the input sampleSize if necessary. |
| @@ -50,10 +50,10 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat |
| SkISize scaledSize = fCodec->getSampledSubsetDimensions(sampleSize, subset); |
| // Create the image info for the decode |
| - SkAlphaType dstAlphaType = fCodec->getInfo().alphaType(); |
| - if (kOpaque_SkAlphaType != dstAlphaType) { |
| - dstAlphaType = requireUnpremul ? kUnpremul_SkAlphaType : kPremul_SkAlphaType; |
| - } |
| + SkColorType dstColorType = SkAndroidCodec::FixRequestedColorType(prefColorType, |
| + fCodec->getInfo().colorType(), fCodec->getInfo().alphaType()); |
| + SkAlphaType dstAlphaType = SkAndroidCodec::FixRequestedAlphaType(requireUnpremul, |
| + fCodec->getInfo().alphaType()); |
| SkImageInfo decodeInfo = SkImageInfo::Make(scaledSize.width(), scaledSize.height(), |
| dstColorType, dstAlphaType); |
| @@ -94,6 +94,9 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat |
| scaledOutHeight += scaledOutY + scaledExtraY; |
| } |
| SkImageInfo outInfo = decodeInfo.makeWH(scaledOutWidth, scaledOutHeight); |
| + if (kGray_8_SkColorType == dstColorType) { |
|
scroggo
2015/12/09 20:57:31
Comment explaining why?
msarett
2015/12/10 15:19:26
Done.
|
| + outInfo = SkImageInfo::MakeA8(scaledOutWidth, scaledOutHeight); |
| + } |
| bitmap->setInfo(outInfo); |
| if (!bitmap->tryAllocPixels(allocator, colorTable.get())) { |
| SkCodecPrintf("Error: Could not allocate pixels.\n"); |