///////////////////////////////////////////////////////////////////////////////
-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:
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();
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" },