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


C++ SkAutoTUnref::readPixels方法代码示例

本文整理汇总了C++中SkAutoTUnref::readPixels方法的典型用法代码示例。如果您正苦于以下问题:C++ SkAutoTUnref::readPixels方法的具体用法?C++ SkAutoTUnref::readPixels怎么用?C++ SkAutoTUnref::readPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkAutoTUnref的用法示例。


在下文中一共展示了SkAutoTUnref::readPixels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GrTextureToYUVPlanes


//.........这里部分代码省略.........
                if (!dc) {
                    return false;
                }
                if (!convert_texture(texture, dc, sizes[1].fWidth, sizes[1].fHeight,
                                     colorSpace,  GrYUVEffect::CreateRGBToUV)) {
                    return false;
                }
            } else {
                SkASSERT(uTex && vTex);
                dc.reset(context->drawContext(uTex->asRenderTarget()));
                if (!dc) {
                    return false;
                }
                if (!convert_texture(texture, dc, sizes[1].fWidth, sizes[1].fHeight,
                                     colorSpace, GrYUVEffect::CreateRGBToU)) {
                    return false;
                }
                dc.reset(context->drawContext(vTex->asRenderTarget()));
                if (!dc) {
                    return false;
                }
                if (!convert_texture(texture, dc, sizes[2].fWidth, sizes[2].fHeight,
                                     colorSpace, GrYUVEffect::CreateRGBToV)) {
                    return false;
                }
            }
        }

        if (yuvTex) {
            SkASSERT(sizes[0] == sizes[1] && sizes[1] == sizes[2]);
            SkISize yuvSize = sizes[0];
            // We have no kRGB_888 pixel format, so readback rgba and then copy three channels.
            SkAutoSTMalloc<128 * 128, uint32_t> tempYUV(yuvSize.fWidth * yuvSize.fHeight);
            if (!yuvTex->readPixels(0, 0, yuvSize.fWidth, yuvSize.fHeight,
                                    kRGBA_8888_GrPixelConfig, tempYUV.get(), 0)) {
                return false;
            }
            size_t yRowBytes = rowBytes[0] ? rowBytes[0] : yuvSize.fWidth;
            size_t uRowBytes = rowBytes[1] ? rowBytes[1] : yuvSize.fWidth;
            size_t vRowBytes = rowBytes[2] ? rowBytes[2] : yuvSize.fWidth;
            if (yRowBytes < (size_t)yuvSize.fWidth || uRowBytes < (size_t)yuvSize.fWidth ||
                vRowBytes < (size_t)yuvSize.fWidth) {
                return false;
            }
            for (int j = 0; j < yuvSize.fHeight; ++j) {
                for (int i = 0; i < yuvSize.fWidth; ++i) {
                    // These writes could surely be made more efficient.
                    uint32_t y = GrColorUnpackR(tempYUV.get()[j * yuvSize.fWidth + i]);
                    uint32_t u = GrColorUnpackG(tempYUV.get()[j * yuvSize.fWidth + i]);
                    uint32_t v = GrColorUnpackB(tempYUV.get()[j * yuvSize.fWidth + i]);
                    uint8_t* yLoc = ((uint8_t*)planes[0]) + j * yRowBytes + i;
                    uint8_t* uLoc = ((uint8_t*)planes[1]) + j * uRowBytes + i;
                    uint8_t* vLoc = ((uint8_t*)planes[2]) + j * vRowBytes + i;
                    *yLoc = y;
                    *uLoc = u;
                    *vLoc = v;
                }
            }
            return true;
        } else {
            SkASSERT(yTex);
            if (!yTex->readPixels(0, 0, sizes[0].fWidth, sizes[0].fHeight,
                                  kAlpha_8_GrPixelConfig, planes[0], rowBytes[0])) {
                return false;
            }
            if (uvTex) {
开发者ID:BertiKarsunke,项目名称:skia,代码行数:67,代码来源:GrTextureToYUVPlanes.cpp


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