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


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

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


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

示例1: Resize

bool SkBitmapScaler::Resize(const SkPixmap& result, const SkPixmap& source, ResizeMethod method) {
    if (!valid_for_resize(source, result.width(), result.height())) {
        return false;
    }
    if (!result.addr() || result.colorType() != source.colorType()) {
        return false;
    }

    SkConvolutionProcs convolveProcs= { 0, nullptr, nullptr, nullptr, nullptr };
    PlatformConvolutionProcs(&convolveProcs);

    SkRect destSubset = SkRect::MakeIWH(result.width(), result.height());

    SkResizeFilter filter(method, source.width(), source.height(),
                          result.width(), result.height(), destSubset, convolveProcs);

    // Get a subset encompassing this touched area. We construct the
    // offsets and row strides such that it looks like a new bitmap, while
    // referring to the old data.
    const uint8_t* sourceSubset = reinterpret_cast<const uint8_t*>(source.addr());

    return BGRAConvolve2D(sourceSubset, static_cast<int>(source.rowBytes()),
                          !source.isOpaque(), filter.xFilter(), filter.yFilter(),
                          static_cast<int>(result.rowBytes()),
                          static_cast<unsigned char*>(result.writable_addr()),
                          convolveProcs, true);
}
开发者ID:qiangyi1989,项目名称:skia,代码行数:27,代码来源:SkBitmapScaler.cpp

示例2: Resize

bool SkBitmapScaler::Resize(SkBitmap* resultPtr, const SkPixmap& source, ResizeMethod method,
                            int destWidth, int destHeight, SkBitmap::Allocator* allocator) {
    if (nullptr == source.addr() || source.colorType() != kN32_SkColorType ||
        source.width() < 1 || source.height() < 1)
    {
        return false;
    }

    if (destWidth < 1 || destHeight < 1) {
        return false;
    }

    SkConvolutionProcs convolveProcs= { 0, nullptr, nullptr, nullptr, nullptr };
    PlatformConvolutionProcs(&convolveProcs);

    SkRect destSubset = SkRect::MakeIWH(destWidth, destHeight);

    SkResizeFilter filter(method, source.width(), source.height(),
                        destWidth, destHeight, destSubset, convolveProcs);

    // Get a subset encompassing this touched area. We construct the
    // offsets and row strides such that it looks like a new bitmap, while
    // referring to the old data.
    const uint8_t* sourceSubset = reinterpret_cast<const uint8_t*>(source.addr());

    // Convolve into the result.
    SkBitmap result;
    result.setInfo(SkImageInfo::MakeN32(SkScalarCeilToInt(destSubset.width()),
                                      SkScalarCeilToInt(destSubset.height()),
                                      source.alphaType()));
    result.allocPixels(allocator, nullptr);
    if (!result.readyToDraw()) {
      return false;
    }

    if (!BGRAConvolve2D(sourceSubset, static_cast<int>(source.rowBytes()),
                        !source.isOpaque(), filter.xFilter(), filter.yFilter(),
                        static_cast<int>(result.rowBytes()),
                        static_cast<unsigned char*>(result.getPixels()),
                        convolveProcs, true)) {
        return false;
    }

    *resultPtr = result;
    resultPtr->lockPixels();
    SkASSERT(resultPtr->getPixels());
    return true;
}
开发者ID:dylanseago,项目名称:gecko-dev,代码行数:48,代码来源:SkBitmapScaler.cpp

示例3: paintEvent

void SkDrawCommandGeometryWidget::paintEvent(QPaintEvent* event) {
    this->QFrame::paintEvent(event);

    if (!fSurface) {
        return;
    }

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);

    SkPixmap pixmap;

    if (fSurface->peekPixels(&pixmap)) {
        SkASSERT(pixmap.width() > 0);
        SkASSERT(pixmap.height() > 0);

        QRectF resultRect;
        if (this->width() < this->height()) {
            float ratio = this->width() / pixmap.width();
            resultRect = QRectF(0, 0, this->width(), ratio * pixmap.height());
        } else {
            float ratio = this->height() / pixmap.height();
            resultRect = QRectF(0, 0, ratio * pixmap.width(), this->height());
        }

        resultRect.moveCenter(this->contentsRect().center());

        QImage image(reinterpret_cast<const uchar*>(pixmap.addr()),
                     pixmap.width(),
                     pixmap.height(),
                     pixmap.rowBytes(),
                     QImage::Format_ARGB32_Premultiplied);
        painter.drawImage(resultRect, image);
    }
}
开发者ID:afedorychak,项目名称:skia,代码行数:35,代码来源:SkDrawCommandGeometryWidget.cpp

示例4: reset

void SkAutoPixmapUnlock::reset(const SkPixmap& pm, void (*unlock)(void*), void* ctx) {
    SkASSERT(pm.addr() != nullptr);

    this->unlock();
    fPixmap = pm;
    fUnlockProc = unlock;
    fUnlockContext = ctx;
    fIsLocked = true;
}
开发者ID:fluxxion82,项目名称:skia,代码行数:9,代码来源:SkPixmap.cpp

示例5:

sk_sp<SkSpecialImage> SkSpecialImage::MakeFromPixmap(const SkIRect& subset,
                                                     const SkPixmap& src,
                                                     RasterReleaseProc releaseProc,
                                                     ReleaseContext context,
                                                     const SkSurfaceProps* props) {
    if (!src.addr()) {
        return nullptr;
    }

    return sk_make_sp<SkSpecialImage_Raster>(subset, src, releaseProc, context, props);
}
开发者ID:BertiKarsunke,项目名称:skia,代码行数:11,代码来源:SkSpecialImage.cpp

示例6: draw

void draw(SkCanvas* canvas) {
    std::vector<int32_t> pixels;
    pixels.resize(image->height() * image->width() * 4);
    SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
            image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
    image->readPixels(pixmap, 0, 0);
    SkDebugf("pixels address: 0x%llx\n", pixmap.addr());
    SkPixmap inset;
    if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) {
         SkDebugf("inset address:  0x%llx\n", inset.addr());
    }
}
开发者ID:HalCanary,项目名称:skia-hc,代码行数:12,代码来源:Pixmap_addr.cpp

示例7: peekPixels

const void* SkSurface::peekPixels(SkImageInfo* info, size_t* rowBytes) {
    SkPixmap pm;
    if (this->peekPixels(&pm)) {
        if (info) {
            *info = pm.info();
        }
        if (rowBytes) {
            *rowBytes = pm.rowBytes();
        }
        return pm.addr();
    }
    return nullptr;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:13,代码来源:SkSurface.cpp

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

示例9: valid_for_resize

static bool valid_for_resize(const SkPixmap& source, int dstW, int dstH) {
    // TODO: Seems like we shouldn't care about the swizzle of source, just that it's 8888
    return source.addr() && source.colorType() == kN32_SkColorType &&
           source.width() >= 1 && source.height() >= 1 && dstW >= 1 && dstH >= 1;
}
开发者ID:qiangyi1989,项目名称:skia,代码行数:5,代码来源:SkBitmapScaler.cpp


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