当前位置: 首页>>代码示例>>C++>>正文


C++ SkPixmap::ctable方法代码示例

本文整理汇总了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;
}
开发者ID:rlugojr,项目名称:skia,代码行数:34,代码来源:SkImageShader.cpp

示例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);
 }
开发者ID:BertiKarsunke,项目名称:skia,代码行数:10,代码来源:SkSpecialImage.cpp

示例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());
}
开发者ID:03050903,项目名称:skia,代码行数:24,代码来源:BitmapTest.cpp


注:本文中的SkPixmap::ctable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。