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


C++ PixelBuffer::map方法代码示例

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


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

示例1: drawCachedGlyphBitmap

void Font::drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y, uint8_t* bitmap,
        uint32_t bitmapWidth, uint32_t bitmapHeight, Rect* bounds, const float* pos) {
    int dstX = x + glyph->mBitmapLeft;
    int dstY = y + glyph->mBitmapTop;

    CacheTexture* cacheTexture = glyph->mCacheTexture;
    PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer();

    uint32_t formatSize = PixelBuffer::formatSize(pixelBuffer->getFormat());
    uint32_t alpha_channel_offset = PixelBuffer::formatAlphaOffset(pixelBuffer->getFormat());
    uint32_t cacheWidth = cacheTexture->getWidth();
    uint32_t srcStride = formatSize * cacheWidth;
    uint32_t startY = glyph->mStartY * srcStride;
    uint32_t endY = startY + (glyph->mBitmapHeight * srcStride);

    const uint8_t* cacheBuffer = pixelBuffer->map();

    for (uint32_t cacheY = startY, bitmapY = dstY * bitmapWidth; cacheY < endY;
            cacheY += srcStride, bitmapY += bitmapWidth) {

        if (formatSize == 1) {
            memcpy(&bitmap[bitmapY + dstX], &cacheBuffer[cacheY + glyph->mStartX], glyph->mBitmapWidth);
        } else {
            for (uint32_t i = 0; i < glyph->mBitmapWidth; ++i) {
                bitmap[bitmapY + dstX + i] = cacheBuffer[cacheY + (glyph->mStartX + i)*formatSize + alpha_channel_offset];
            }
        }
    }

}
开发者ID:aurorarom,项目名称:JsonUtil,代码行数:30,代码来源:Font.cpp

示例2: drawCachedGlyphBitmap

void Font::drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y, uint8_t* bitmap,
        uint32_t bitmapWidth, uint32_t bitmapHeight, Rect* bounds, const float* pos) {
    int dstX = x + glyph->mBitmapLeft;
    int dstY = y + glyph->mBitmapTop;

    CacheTexture* cacheTexture = glyph->mCacheTexture;

    uint32_t cacheWidth = cacheTexture->getWidth();
    uint32_t startY = glyph->mStartY * cacheWidth;
    uint32_t endY = startY + (glyph->mBitmapHeight * cacheWidth);

    PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer();
    const uint8_t* cacheBuffer = pixelBuffer->map();

    for (uint32_t cacheY = startY, bitmapY = dstY * bitmapWidth; cacheY < endY;
            cacheY += cacheWidth, bitmapY += bitmapWidth) {
        memcpy(&bitmap[bitmapY + dstX], &cacheBuffer[cacheY + glyph->mStartX], glyph->mBitmapWidth);
    }
}
开发者ID:LuckJC,项目名称:pro-fw,代码行数:19,代码来源:Font.cpp


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