本文整理汇总了C++中SkPaint::setDither方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPaint::setDither方法的具体用法?C++ SkPaint::setDither怎么用?C++ SkPaint::setDither使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPaint
的用法示例。
在下文中一共展示了SkPaint::setDither方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDraw
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
// canvas->scale(1.5f, 1.5f);
canvas->drawBitmap(fBM, 0, 0);
SkIRect margins;
SkRect dst;
int d = 25;
margins.set(d, d, d, d);
margins.fLeft = fBM.width()/2 - 1;
margins.fTop = fBM.height()/2 - 1;
margins.fRight = fBM.width() - margins.fLeft - 1;
margins.fBottom = fBM.height() - margins.fTop - 1;
// canvas->translate(fX/5, fY/5);
canvas->translate(0, 76);
dst.set(0, 0, SkIntToScalar(200), SkIntToScalar(200));
SkPaint paint;
paint.setAntiAlias(false);
paint.setDither(true);
paint.setFilterBitmap(false);
// SkNinePatch::DrawNine(canvas, dst, fBM, margins, &paint);
test_rects(canvas, fBM, &paint);
}
示例2: onDrawContent
virtual void onDrawContent(SkCanvas* canvas) {
SkPaint paint;
paint.setDither(true);
paint.setFilterBitmap(true);
for (size_t i = 0; i < SK_ARRAY_COUNT(fRecs); i++) {
canvas->save();
paint.setShader(NULL);
canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount,
fRecs[i].fVerts, fRecs[i].fTexs,
NULL, NULL, NULL, 0, paint);
canvas->translate(SkIntToScalar(250), 0);
paint.setShader(fShader0);
canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount,
fRecs[i].fVerts, fRecs[i].fTexs,
NULL, NULL, NULL, 0, paint);
canvas->translate(SkIntToScalar(250), 0);
paint.setShader(fShader1);
canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount,
fRecs[i].fVerts, fRecs[i].fTexs,
NULL, NULL, NULL, 0, paint);
canvas->restore();
canvas->translate(0, SkIntToScalar(250));
}
}
示例3: onDrawContent
void onDrawContent(SkCanvas* canvas) override {
SkPaint paint;
paint.setDither(true);
paint.setFilterQuality(kLow_SkFilterQuality);
for (size_t i = 0; i < SK_ARRAY_COUNT(fRecs); i++) {
auto verts = SkVertices::MakeCopy(fRecs[i].fMode, fRecs[i].fCount,
fRecs[i].fVerts, fRecs[i].fTexs,
nullptr);
canvas->save();
paint.setShader(nullptr);
canvas->drawVertices(verts, SkBlendMode::kModulate, paint);
canvas->translate(SkIntToScalar(250), 0);
paint.setShader(fShader0);
canvas->drawVertices(verts, SkBlendMode::kModulate, paint);
canvas->translate(SkIntToScalar(250), 0);
paint.setShader(fShader1);
canvas->drawVertices(verts, SkBlendMode::kModulate, paint);
canvas->restore();
canvas->translate(0, SkIntToScalar(250));
}
}
示例4: gradient_slide
static void gradient_slide(SkCanvas* canvas) {
SkPoint pts[2] = {
{ 0, 0 },
{ SkIntToScalar(100), SkIntToScalar(100) }
};
SkShader::TileMode tm = SkShader::kClamp_TileMode;
SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
SkPaint paint;
paint.setAntiAlias(true);
paint.setDither(true);
canvas->translate(SkIntToScalar(20), SkIntToScalar(10));
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
canvas->save();
for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
SkShader* shader = gGradMakers[j](pts, gGradData[i], tm);
paint.setShader(shader);
canvas->drawRect(r, paint);
shader->unref();
canvas->translate(0, SkIntToScalar(120));
}
canvas->restore();
canvas->translate(SkIntToScalar(120), 0);
}
}
示例5: onDraw
virtual void onDraw(SkCanvas* canvas) {
SkPoint pts[2] = {
{ 0, 0 },
{ SkIntToScalar(100), SkIntToScalar(100) }
};
SkShader::TileMode tm = SkShader::kClamp_TileMode;
SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
SkPaint paint;
paint.setAntiAlias(true);
paint.setDither(fDither);
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
canvas->save();
for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
SkMatrix scale = SkMatrix::I();
if (i == 5) { // if the clamp case
scale.setScale(0.5f, 0.5f);
scale.postTranslate(25.f, 25.f);
}
paint.setShader(gGradMakers[j](pts, gGradData[i], tm, scale));
canvas->drawRect(r, paint);
canvas->translate(0, SkIntToScalar(120));
}
canvas->restore();
canvas->translate(SkIntToScalar(120), 0);
}
}
示例6: bitmap
static void draw2(SkCanvas* canvas, const SkBitmap& bm) {
SkPaint paint;
SkBitmap bitmap(bm);
setBitmapOpaque(&bitmap, false);
paint.setDither(false);
canvas->drawBitmap(bitmap, 0, 0, &paint);
paint.setDither(true);
canvas->drawBitmap(bitmap, 0, SkIntToScalar(bm.height() + 10), &paint);
setBitmapOpaque(&bitmap, true);
SkScalar x = SkIntToScalar(bm.width() + 10);
paint.setDither(false);
canvas->drawBitmap(bitmap, x, 0, &paint);
paint.setDither(true);
canvas->drawBitmap(bitmap, x, SkIntToScalar(bm.height() + 10), &paint);
}
示例7: canvas
// Make sure our blits always map src==0 to a noop, and src==FF to full opaque
static void test_00_FF(skiatest::Reporter* reporter) {
static const int W = 256;
static const SkBitmap::Config gDstConfig[] = {
SkBitmap::kARGB_8888_Config,
SkBitmap::kRGB_565_Config,
// SkBitmap::kARGB_4444_Config,
// SkBitmap::kA8_Config,
};
static const struct {
SkColor fSrc;
SkColor fDst;
SkPMColor fResult32;
uint16_t fResult16;
uint8_t fResult8;
} gSrcRec[] = {
{ 0, 0, 0, 0, 0 },
{ 0, 0xFFFFFFFF, SkPackARGB32(0xFF, 0xFF, 0xFF, 0xFF), 0xFFFF, 0xFF },
{ 0xFFFFFFFF, 0, SkPackARGB32(0xFF, 0xFF, 0xFF, 0xFF), 0xFFFF, 0xFF },
{ 0xFFFFFFFF, 0xFFFFFFFF, SkPackARGB32(0xFF, 0xFF, 0xFF, 0xFF), 0xFFFF, 0xFF },
};
SkPaint paint;
SkBitmap srcBM;
srcBM.setConfig(SkBitmap::kARGB_8888_Config, W, 1);
srcBM.allocPixels();
for (size_t i = 0; i < SK_ARRAY_COUNT(gDstConfig); i++) {
SkBitmap dstBM;
dstBM.setConfig(gDstConfig[i], W, 1);
dstBM.allocPixels();
SkCanvas canvas(dstBM);
for (size_t j = 0; j < SK_ARRAY_COUNT(gSrcRec); j++) {
srcBM.eraseColor(gSrcRec[j].fSrc);
dstBM.eraseColor(gSrcRec[j].fDst);
for (int k = 0; k < 4; k++) {
bool dither = (k & 1) != 0;
bool blend = (k & 2) != 0;
if (gSrcRec[j].fSrc != 0 && blend) {
// can't make a numerical promise about blending anything
// but 0
// continue;
}
paint.setDither(dither);
paint.setAlpha(blend ? 0x80 : 0xFF);
canvas.drawBitmap(srcBM, 0, 0, &paint);
if (!check_color(dstBM, gSrcRec[j].fResult32, gSrcRec[j].fResult16,
gSrcRec[j].fResult8, reporter)) {
SkDebugf("--- src index %d dither %d blend %d\n", j, dither, blend);
}
}
}
}
}
示例8: applyToPaint
void Gradient::applyToPaint(SkPaint& paint, const SkMatrix& localMatrix) {
if (!m_cachedShader || localMatrix != m_cachedShader->getLocalMatrix())
m_cachedShader = createShader(localMatrix);
paint.setShader(m_cachedShader);
// Legacy behavior: gradients are always dithered.
paint.setDither(true);
}
示例9: applyToPaint
void Gradient::applyToPaint(SkPaint& paint)
{
if (!m_gradient)
m_gradient = createShader();
paint.setShader(m_gradient);
// Legacy behavior: gradients are always dithered.
paint.setDither(true);
}
示例10: show_ramp
static void show_ramp(SkCanvas* canvas, const SkRect& r) {
SkPoint pts[] = { r.fLeft, 0, r.fRight, 0 };
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2,
SkShader::kRepeat_TileMode);
SkPaint p;
p.setShader(s)->unref();
canvas->drawRect(r, p);
canvas->translate(r.width() + SkIntToScalar(8), 0);
p.setDither(true);
canvas->drawRect(r, p);
}
示例11: draw_gradient
static void draw_gradient(SkCanvas* canvas) {
SkRect r = { 0, 0, SkIntToScalar(256), SkIntToScalar(32) };
SkPoint pts[] = { { r.fLeft, r.fTop }, { r.fRight, r.fTop } };
SkColor colors[] = { 0xFF000000, 0xFFFF0000 };
SkPaint p;
p.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode));
draw_rect(canvas, r, p);
canvas->translate(0, SkIntToScalar(40));
p.setDither(true);
draw_rect(canvas, r, p);
}
示例12: make_paint
static SkPaint make_paint() {
SkPaint paint;
if (fuzz->exhausted()) {
return paint;
}
paint.setHinting(make_paint_hinting());
paint.setAntiAlias(make_bool());
paint.setDither(make_bool());
paint.setLinearText(make_bool());
paint.setSubpixelText(make_bool());
paint.setLCDRenderText(make_bool());
paint.setEmbeddedBitmapText(make_bool());
paint.setAutohinted(make_bool());
paint.setVerticalText(make_bool());
paint.setFakeBoldText(make_bool());
paint.setDevKernText(make_bool());
paint.setFilterQuality(make_filter_quality());
paint.setStyle(make_paint_style());
paint.setColor(make_color());
paint.setStrokeWidth(make_number(false));
paint.setStrokeMiter(make_number(false));
paint.setStrokeCap(make_paint_cap());
paint.setStrokeJoin(make_paint_join());
paint.setColorFilter(make_color_filter());
paint.setBlendMode(make_blendmode());
paint.setPathEffect(make_path_effect());
paint.setMaskFilter(make_mask_filter());
if (false) {
// our validating buffer does not support typefaces yet, so skip this for now
paint.setTypeface(SkTypeface::MakeFromName(make_font_name().c_str(),make_typeface_style()));
}
SkLayerRasterizer::Builder rasterizerBuilder;
SkPaint paintForRasterizer;
if (make_bool()) {
paintForRasterizer = make_paint();
}
rasterizerBuilder.addLayer(paintForRasterizer);
paint.setRasterizer(rasterizerBuilder.detach());
paint.setImageFilter(make_image_filter());
bool a, b, c;
fuzz->next(&a, &b, &c);
sk_sp<SkData> data(make_3Dlut(nullptr, a, b, c));
paint.setTextAlign(make_paint_align());
SkScalar d, e, f;
fuzz->next(&d, &e, &f);
paint.setTextSize(d);
paint.setTextScaleX(e);
paint.setTextSkewX(f);
paint.setTextEncoding(make_paint_text_encoding());
return paint;
}
示例13: onDrawContent
virtual void onDrawContent(SkCanvas* canvas)
{
canvas->translate(SkIntToScalar(10), SkIntToScalar(50));
const SkScalar W = SkIntToScalar(fBitmaps[0].width() + 1);
const SkScalar H = SkIntToScalar(fBitmaps[0].height() + 1);
SkPaint paint;
const SkScalar scale = SkFloatToScalar(0.897917f);
canvas->scale(SK_Scalar1, scale);
for (int k = 0; k < 2; k++)
{
paint.setFilterBitmap(k == 1);
for (int j = 0; j < 2; j++)
{
paint.setDither(j == 1);
for (int i = 0; i < fBitmapCount; i++)
{
SkScalar x = (k * fBitmapCount + j) * W;
SkScalar y = i * H;
x = SkIntToScalar(SkScalarRound(x));
y = SkIntToScalar(SkScalarRound(y));
canvas->drawBitmap(fBitmaps[i], x, y, &paint);
if (i == 0)
{
SkPaint p;
p.setAntiAlias(true);
p.setTextAlign(SkPaint::kCenter_Align);
p.setTextSize(SkIntToScalar(18));
SkString s("dither=");
s.appendS32(paint.isDither());
s.append(" filter=");
s.appendS32(paint.isFilterBitmap());
canvas->drawText(s.c_str(), s.size(), x + W/2,
y - p.getTextSize(), p);
}
if (k+j == 2)
{
SkPaint p;
p.setAntiAlias(true);
p.setTextSize(SkIntToScalar(18));
SkString s;
s.append(" depth=");
s.appendS32(fBitmaps[i].config() == SkBitmap::kRGB_565_Config ? 16 : 32);
canvas->drawText(s.c_str(), s.size(), x + W + SkIntToScalar(4),
y + H/2, p);
}
}
}
}
}
示例14: onDraw
void onDraw(SkCanvas* canvas) override {
const SkColor colors[] = { sk_tool_utils::color_to_565(0xFF555555),
sk_tool_utils::color_to_565(0xFF444444) };
const int colorCount = SK_ARRAY_COUNT(colors);
SkRect r = { 0, 0, this->width(), this->height() };
SkSize size = SkSize::Make(r.width(), r.height());
SkPaint paint;
paint.setShader(fProc(colors, colorCount, size))->unref();
paint.setDither(fDither);
canvas->drawRect(r, paint);
}
示例15: onDrawContent
virtual void onDrawContent(SkCanvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(SkIntToScalar(10));
paint.setMaskFilter(new SkEmbossMaskFilter(fLight, SkIntToScalar(4)))->unref();
paint.setShader(new SkColorShader(SK_ColorBLUE))->unref();
paint.setDither(true);
canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50),
SkIntToScalar(30), paint);
}