本文整理汇总了C++中SkPixmap::ctable方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPixmap::ctable方法的具体用法?C++ SkPixmap::ctable怎么用?C++ SkPixmap::ctable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPixmap
的用法示例。
在下文中一共展示了SkPixmap::ctable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 SkImage* image, SkColor* color) {
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
// HWUI does not support color shaders (see b/22390304)
return false;
#endif
if (1 != image->width() || 1 != image->height()) {
return false;
}
SkPixmap pmap;
if (!image->peekPixels(&pmap)) {
return false;
}
switch (pmap.colorType()) {
case kN32_SkColorType:
*color = SkUnPreMultiply::PMColorToColor(*pmap.addr32(0, 0));
return true;
case kRGB_565_SkColorType:
*color = SkPixel16ToColor(*pmap.addr16(0, 0));
return true;
case kIndex_8_SkColorType: {
const SkColorTable& ctable = *pmap.ctable();
*color = SkUnPreMultiply::PMColorToColor(ctable[*pmap.addr8(0, 0)]);
return true;
}
default: // just skip the other configs for now
break;
}
return false;
}
示例2: INHERITED
SkSpecialImage_Raster(const SkIRect& subset,
const SkPixmap& pixmap,
RasterReleaseProc releaseProc,
ReleaseContext context,
const SkSurfaceProps* props)
: INHERITED(subset, kNeedNewImageUniqueID_SpecialImage, props) {
fBitmap.installPixels(pixmap.info(), pixmap.writable_addr(),
pixmap.rowBytes(), pixmap.ctable(),
releaseProc, context);
}
示例3: test_peekpixels
static void test_peekpixels(skiatest::Reporter* reporter) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
SkPixmap pmap;
SkBitmap bm;
// empty should return false
REPORTER_ASSERT(reporter, !bm.peekPixels(nullptr));
REPORTER_ASSERT(reporter, !bm.peekPixels(&pmap));
// no pixels should return false
bm.setInfo(SkImageInfo::MakeN32Premul(10, 10));
REPORTER_ASSERT(reporter, !bm.peekPixels(nullptr));
REPORTER_ASSERT(reporter, !bm.peekPixels(&pmap));
// real pixels should return true
bm.allocPixels(info);
REPORTER_ASSERT(reporter, bm.peekPixels(nullptr));
REPORTER_ASSERT(reporter, bm.peekPixels(&pmap));
REPORTER_ASSERT(reporter, pmap.info() == bm.info());
REPORTER_ASSERT(reporter, pmap.addr() == bm.getPixels());
REPORTER_ASSERT(reporter, pmap.rowBytes() == bm.rowBytes());
REPORTER_ASSERT(reporter, pmap.ctable() == bm.getColorTable());
}