Flutter Engine
The Flutter Engine
Functions
Dither_a.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (Dither_a, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Dither_a  ,
256  ,
256  ,
false  ,
 
)

Definition at line 4 of file Dither_a.cpp.

4 {
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
@ 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 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)