本文整理汇总了C++中SkBitmap::installMaskPixels方法的典型用法代码示例。如果您正苦于以下问题:C++ SkBitmap::installMaskPixels方法的具体用法?C++ SkBitmap::installMaskPixels怎么用?C++ SkBitmap::installMaskPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkBitmap
的用法示例。
在下文中一共展示了SkBitmap::installMaskPixels方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDraw
virtual void onDraw(SkCanvas* canvas) {
SkRect r;
r.setWH(SkIntToScalar(fRectWidth), SkIntToScalar(fRectHeight));
SkISize canvas_size = canvas->getDeviceSize();
int center_x = (canvas_size.fWidth - (int)(r.width()))/2;
int center_y = (canvas_size.fHeight - (int)(r.height()))/2;
SkMask mask;
if (!this->makeMask(&mask, r)) {
SkPaint paint;
r.offset( SkIntToScalar(center_x), SkIntToScalar(center_y) );
canvas->drawRect(r,paint);
return;
}
SkAutoMaskFreeImage amfi(mask.fImage);
SkBitmap bm;
bm.installMaskPixels(mask);
center_x = (canvas_size.fWidth - mask.fBounds.width())/2;
center_y = (canvas_size.fHeight - mask.fBounds.height())/2;
canvas->drawBitmap(bm, SkIntToScalar(center_x), SkIntToScalar(center_y), NULL);
}
示例2: onRasterize
bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix,
const SkIRect* clipBounds,
SkMask* mask, SkMask::CreateMode mode) const {
SkASSERT(fLayers);
if (fLayers->empty()) {
return false;
}
if (SkMask::kJustRenderImage_CreateMode != mode) {
if (!compute_bounds(*fLayers, path, matrix, clipBounds, &mask->fBounds))
return false;
}
if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode) {
mask->fFormat = SkMask::kA8_Format;
mask->fRowBytes = mask->fBounds.width();
size_t size = mask->computeImageSize();
if (0 == size) {
return false; // too big to allocate, abort
}
mask->fImage = SkMask::AllocImage(size);
memset(mask->fImage, 0, size);
}
if (SkMask::kJustComputeBounds_CreateMode != mode) {
SkBitmap device;
SkRasterClip rectClip;
SkDraw draw;
SkMatrix translatedMatrix; // this translates us to our local pixels
SkMatrix drawMatrix; // this translates the path by each layer's offset
rectClip.setRect(SkIRect::MakeWH(mask->fBounds.width(), mask->fBounds.height()));
translatedMatrix = matrix;
translatedMatrix.postTranslate(-SkIntToScalar(mask->fBounds.fLeft),
-SkIntToScalar(mask->fBounds.fTop));
device.installMaskPixels(*mask);
draw.fBitmap = &device;
draw.fMatrix = &drawMatrix;
draw.fRC = &rectClip;
draw.fClip = &rectClip.bwRgn();
// we set the matrixproc in the loop, as the matrix changes each time (potentially)
SkDeque::F2BIter iter(*fLayers);
SkLayerRasterizer_Rec* rec;
while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL) {
drawMatrix = translatedMatrix;
drawMatrix.preTranslate(rec->fOffset.fX, rec->fOffset.fY);
draw.drawPath(path, rec->fPaint);
}
}
return true;
}
示例3: drawClip
static void drawClip(SkCanvas* canvas, const SkAAClip& clip) {
SkMask mask;
SkBitmap bm;
clip.copyToMask(&mask);
SkAutoMaskFreeImage amfi(mask.fImage);
bm.installMaskPixels(mask);
SkPaint paint;
canvas->drawBitmap(bm,
SK_Scalar1 * mask.fBounds.fLeft,
SK_Scalar1 * mask.fBounds.fTop,
&paint);
}