本文整理汇总了C++中SkBitmap::getIndex8Color方法的典型用法代码示例。如果您正苦于以下问题:C++ SkBitmap::getIndex8Color方法的具体用法?C++ SkBitmap::getIndex8Color怎么用?C++ SkBitmap::getIndex8Color使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkBitmap
的用法示例。
在下文中一共展示了SkBitmap::getIndex8Color方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: can_use_color_shader
// returns true and set color if the bitmap can be drawn as a single color
// (for efficiency)
static bool can_use_color_shader(const SkBitmap& bm, SkColor* color) {
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
// HWUI does not support color shaders (see b/22390304)
return false;
#endif
if (1 != bm.width() || 1 != bm.height()) {
return false;
}
SkAutoLockPixels alp(bm);
if (!bm.readyToDraw()) {
return false;
}
switch (bm.colorType()) {
case kN32_SkColorType:
*color = SkUnPreMultiply::PMColorToColor(*bm.getAddr32(0, 0));
return true;
case kRGB_565_SkColorType:
*color = SkPixel16ToColor(*bm.getAddr16(0, 0));
return true;
case kIndex_8_SkColorType:
*color = SkUnPreMultiply::PMColorToColor(bm.getIndex8Color(0, 0));
return true;
default: // just skip the other configs for now
break;
}
return false;
}
示例2: canUseColorShader
// returns true and set color if the bitmap can be drawn as a single color
// (for efficiency)
static bool canUseColorShader(const SkBitmap& bm, SkColor* color) {
if (1 != bm.width() || 1 != bm.height()) {
return false;
}
SkAutoLockPixels alp(bm);
if (!bm.readyToDraw()) {
return false;
}
switch (bm.config()) {
case SkBitmap::kARGB_8888_Config:
*color = SkUnPreMultiply::PMColorToColor(*bm.getAddr32(0, 0));
return true;
case SkBitmap::kRGB_565_Config:
*color = SkPixel16ToColor(*bm.getAddr16(0, 0));
return true;
case SkBitmap::kIndex8_Config:
*color = SkUnPreMultiply::PMColorToColor(bm.getIndex8Color(0, 0));
return true;
default: // just skip the other configs for now
break;
}
return false;
}