add colortable enum to SkImage to ease interop between it and SkBitmap::Config
BUG= R=halcanary@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/68853003 git-svn-id: http://skia.googlecode.com/svn/trunk@12245 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
5401cd019b
commit
23be7a58d9
@ -37,7 +37,8 @@ enum SkColorType {
|
||||
#error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order"
|
||||
#endif
|
||||
|
||||
kLastEnum_SkColorType = kBGRA_8888_SkColorType
|
||||
kIndex8_SkColorType,
|
||||
kLastEnum_SkColorType = kIndex8_SkColorType
|
||||
};
|
||||
|
||||
struct SkImageInfo {
|
||||
|
@ -20,6 +20,9 @@ SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo& info) {
|
||||
case kPMColor_SkColorType:
|
||||
return SkBitmap::kARGB_8888_Config;
|
||||
|
||||
case kIndex8_SkColorType:
|
||||
return SkBitmap::kIndex8_Config;
|
||||
|
||||
default:
|
||||
// break for unsupported colortypes
|
||||
break;
|
||||
@ -34,6 +37,7 @@ int SkImageBytesPerPixel(SkColorType ct) {
|
||||
4, // kRGBA_8888_SkColorType
|
||||
4, // kBGRA_8888_SkColorType
|
||||
4, // kPMColor_SkColorType
|
||||
1, // kIndex8_SkColorType
|
||||
};
|
||||
|
||||
SkASSERT((size_t)ct < SK_ARRAY_COUNT(gColorTypeBytesPerPixel));
|
||||
@ -45,7 +49,11 @@ bool SkBitmapToImageInfo(const SkBitmap& bm, SkImageInfo* info) {
|
||||
case SkBitmap::kA8_Config:
|
||||
info->fColorType = kAlpha_8_SkColorType;
|
||||
break;
|
||||
|
||||
|
||||
case SkBitmap::kIndex8_Config:
|
||||
info->fColorType = kIndex8_SkColorType;
|
||||
break;
|
||||
|
||||
case SkBitmap::kRGB_565_Config:
|
||||
info->fColorType = kRGB_565_SkColorType;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user