Flutter Engine
The Flutter Engine
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.
4REG_FIDDLE(Dither_a, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
6 SkBitmap bm16;
8 SkCanvas c16(bm16);
9 SkPaint colorPaint;
10 for (auto dither : { false, true } ) {
11 colorPaint.setDither(dither);
12 for (auto colors : { 0xFF333333, 0xFF666666, 0xFF999999, 0xFFCCCCCC } ) {
13 for (auto mask : { 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF } ) {
14 colorPaint.setColor(colors & mask);
15 c16.drawRect({0, 0, 8, 4}, colorPaint);
16 c16.translate(8, 0);
17 }
18 c16.translate(-32, 4);
19 }
20 }
21 canvas->scale(8, 8);
22 canvas->drawImage(bm16.asImage(), 0, 0);
23}
24} // END FIDDLE
REG_FIDDLE(Dither_a, 256, 256, false, 0)
Definition: Dither_a.cpp:4
@ 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)
Definition: SkCanvas.cpp:1673
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
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
PODArray< SkColor > colors
Definition: SkRecords.h:276
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)