本文整理汇总了C++中SkPixmap::rowBytesAsPixels方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPixmap::rowBytesAsPixels方法的具体用法?C++ SkPixmap::rowBytesAsPixels怎么用?C++ SkPixmap::rowBytesAsPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPixmap
的用法示例。
在下文中一共展示了SkPixmap::rowBytesAsPixels方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: call_proc_X
static void call_proc_X(SkMorphologyImageFilter::Proc procX,
const SkPixmap& src, SkBitmap* dst,
int radiusX, const SkIRect& bounds) {
procX(src.addr32(bounds.left(), bounds.top()), dst->getAddr32(0, 0),
radiusX, bounds.width(), bounds.height(),
src.rowBytesAsPixels(), dst->rowBytesAsPixels());
}
示例2: test_blender
static void test_blender(std::string resourceName, skiatest::Reporter* reporter) {
std::string fileName = resourceName + ".png";
sk_sp<SkImage> image = GetResourceAsImage(fileName.c_str());
if (image == nullptr) {
ERRORF(reporter, "image is NULL");
return;
}
SkBitmap bm;
if (!as_IB(image)->getROPixels(&bm)) {
ERRORF(reporter, "Could not read resource");
return;
}
SkPixmap pixmap;
bm.peekPixels(&pixmap);
SkASSERTF(pixmap.colorType() == kN32_SkColorType, "colorType: %d", pixmap.colorType());
SkASSERT(pixmap.alphaType() != kUnpremul_SkAlphaType);
const uint32_t* src = pixmap.addr32();
const int width = pixmap.rowBytesAsPixels();
SkASSERT(width > 0);
SkASSERT(width < 4000);
SkAutoTArray<uint32_t> correctDst(width);
SkAutoTArray<uint32_t> testDst(width);
for (int y = 0; y < pixmap.height(); y++) {
// TODO: zero is not the most interesting dst to test srcover...
sk_bzero(correctDst.get(), width * sizeof(uint32_t));
sk_bzero(testDst.get(), width * sizeof(uint32_t));
brute_force_srcover_srgb_srgb(correctDst.get(), src, width, width);
SkOpts:: srcover_srgb_srgb( testDst.get(), src, width, width);
for (int x = 0; x < width; x++) {
REPORTER_ASSERT_MESSAGE(
reporter, correctDst[x] == testDst[x],
mismatch_message(resourceName, x, y, src[x], correctDst[x], testDst[x]));
if (correctDst[x] != testDst[x]) break;
}
src += width;
}
}
示例3: dstLock
sk_sp<SkSpecialImage> SkMorphologyImageFilter::filterImageGeneric(bool dilate,
SkSpecialImage* source,
const Context& ctx,
SkIPoint* offset) const {
SkIPoint inputOffset = SkIPoint::Make(0, 0);
sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
if (!input) {
return nullptr;
}
SkIRect bounds;
input = this->applyCropRect(this->mapContext(ctx), input.get(), &inputOffset, &bounds);
if (!input) {
return nullptr;
}
SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()),
SkIntToScalar(this->radius().height()));
ctx.ctm().mapVectors(&radius, 1);
int width = SkScalarFloorToInt(radius.fX);
int height = SkScalarFloorToInt(radius.fY);
if (width < 0 || height < 0) {
return nullptr;
}
SkIRect srcBounds = bounds;
srcBounds.offset(-inputOffset);
if (0 == width && 0 == height) {
offset->fX = bounds.left();
offset->fY = bounds.top();
return input->makeSubset(srcBounds);
}
#if SK_SUPPORT_GPU
if (input->peekTexture() && input->peekTexture()->getContext()) {
auto type = dilate ? GrMorphologyEffect::kDilate_MorphologyType
: GrMorphologyEffect::kErode_MorphologyType;
sk_sp<SkSpecialImage> result(apply_morphology(input.get(), srcBounds, type,
SkISize::Make(width, height)));
if (result) {
offset->fX = bounds.left();
offset->fY = bounds.top();
}
return result;
}
#endif
SkPixmap inputPixmap;
if (!input->peekPixels(&inputPixmap)) {
return nullptr;
}
if (inputPixmap.colorType() != kN32_SkColorType) {
return nullptr;
}
SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(),
inputPixmap.colorType(), inputPixmap.alphaType());
SkBitmap dst;
if (!dst.tryAllocPixels(info)) {
return nullptr;
}
SkAutoLockPixels dstLock(dst);
SkMorphologyImageFilter::Proc procX, procY;
if (dilate) {
procX = SkOpts::dilate_x;
procY = SkOpts::dilate_y;
} else {
procX = SkOpts::erode_x;
procY = SkOpts::erode_y;
}
if (width > 0 && height > 0) {
SkBitmap tmp;
if (!tmp.tryAllocPixels(info)) {
return nullptr;
}
SkAutoLockPixels tmpLock(tmp);
call_proc_X(procX, inputPixmap, &tmp, width, srcBounds);
SkIRect tmpBounds = SkIRect::MakeWH(srcBounds.width(), srcBounds.height());
call_proc_Y(procY,
tmp.getAddr32(tmpBounds.left(), tmpBounds.top()), tmp.rowBytesAsPixels(),
&dst, height, tmpBounds);
} else if (width > 0) {
call_proc_X(procX, inputPixmap, &dst, width, srcBounds);
} else if (height > 0) {
call_proc_Y(procY,
inputPixmap.addr32(srcBounds.left(), srcBounds.top()),
inputPixmap.rowBytesAsPixels(),
&dst, height, srcBounds);
}
//.........这里部分代码省略.........