本文整理汇总了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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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());
}
}
示例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;
}
示例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());
}
示例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;
}