Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Dither_a.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4// HASH=8b26507690b71462f44642b911890bbf
5REG_FIDDLE(Dither_a, 256, 256, false, 0) {
6void draw(SkCanvas* canvas) {
7 SkBitmap bm16;
9 SkCanvas c16(bm16);
10 SkPaint colorPaint;
11 for (auto dither : { false, true } ) {
12 colorPaint.setDither(dither);
13 for (auto colors : { 0xFF333333, 0xFF666666, 0xFF999999, 0xFFCCCCCC } ) {
14 for (auto mask : { 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF } ) {
15 colorPaint.setColor(colors & mask);
16 c16.drawRect({0, 0, 8, 4}, colorPaint);
17 c16.translate(8, 0);
18 }
19 c16.translate(-32, 4);
20 }
21 }
22 canvas->scale(8, 8);
23 canvas->drawImage(bm16.asImage(), 0, 0);
24}
25} // END FIDDLE
@ kOpaque_SkAlphaType
pixel is opaque
Definition SkAlphaType.h:28
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition SkColorType.h:22
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition SkBitmap.cpp:258
sk_sp< SkImage > asImage() const
Definition SkBitmap.cpp:645
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void scale(SkScalar sx, SkScalar sy)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
void setColor(SkColor color)
Definition SkPaint.cpp:119
void setDither(bool dither)
Definition SkPaint.h:182
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)