don't support converting from alpha to non-alpha

BUG=skia:

Change-Id: Ia06bef6c0bfc03b5ca9f569c07e993da0bbd67c3
Reviewed-on: https://skia-review.googlesource.com/5288
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2016-11-28 17:17:38 -05:00 committed by Skia Commit-Bot
parent 2c8104eb18
commit 22f348281a
3 changed files with 13 additions and 4 deletions

View File

@ -707,15 +707,18 @@ bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const {
///////////////////////////////////////////////////////////////////////////////
bool SkBitmap::canCopyTo(SkColorType dstColorType) const {
bool SkBitmap::canCopyTo(SkColorType dstCT) const {
const SkColorType srcCT = this->colorType();
if (srcCT == kUnknown_SkColorType) {
return false;
}
if (srcCT == kAlpha_8_SkColorType && dstCT != kAlpha_8_SkColorType) {
return false; // can't convert from alpha to non-alpha
}
bool sameConfigs = (srcCT == dstColorType);
switch (dstColorType) {
bool sameConfigs = (srcCT == dstCT);
switch (dstCT) {
case kAlpha_8_SkColorType:
case kRGB_565_SkColorType:
case kRGBA_8888_SkColorType:

View File

@ -324,6 +324,12 @@ bool SkPixelInfo::CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t
return false;
}
if (srcInfo.colorType() == kAlpha_8_SkColorType &&
dstInfo.colorType() != kAlpha_8_SkColorType)
{
return false; // can't convert from alpha to non-alpha
}
const int width = srcInfo.width();
const int height = srcInfo.height();

View File

@ -183,7 +183,7 @@ static void writeCoordPixels(SkBitmap& bm, const Coordinates& coords) {
static const Pair gPairs[] = {
{ kUnknown_SkColorType, "000000" },
{ kAlpha_8_SkColorType, "010101" },
{ kAlpha_8_SkColorType, "010000" },
{ kIndex_8_SkColorType, "011111" },
{ kRGB_565_SkColorType, "010101" },
{ kARGB_4444_SkColorType, "010111" },