Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
Color_Type_ARGB_4444.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (Color_Type_ARGB_4444, 256, 96, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Color_Type_ARGB_4444  ,
256  ,
96  ,
false  ,
 
)

Definition at line 5 of file Color_Type_ARGB_4444.cpp.

5 {
6void draw(SkCanvas* canvas) {
7 canvas->scale(16, 16);
10 bitmap.allocPixels(imageInfo);
11 SkCanvas offscreen(bitmap);
12 offscreen.clear(SK_ColorGREEN);
13 canvas->drawImage(bitmap.asImage(), 0, 0);
14 auto pack4444 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint16_t {
15 return (a << 0) | (b << 4) | (g << 8) | (r << 12);
16 };
17 uint16_t red4444[] = { pack4444(0xF, 0xF, 0x0, 0x0), pack4444(0xF, 0xb, 0x0, 0x0),
18 pack4444(0xF, 0x7, 0x0, 0x0), pack4444(0xF, 0x3, 0x0, 0x0) };
19 uint16_t blue4444[] = { pack4444(0xF, 0x0, 0x0, 0xF), pack4444(0xF, 0x0, 0x0, 0xb),
20 pack4444(0xF, 0x0, 0x0, 0x7), pack4444(0xF, 0x0, 0x0, 0x3) };
21 SkPixmap redPixmap(imageInfo, &red4444, imageInfo.minRowBytes());
22 if (bitmap.writePixels(redPixmap, 0, 0)) {
23 canvas->drawImage(bitmap.asImage(), 2, 2);
24 }
25 SkPixmap bluePixmap(imageInfo, &blue4444, imageInfo.minRowBytes());
26 if (bitmap.writePixels(bluePixmap, 0, 0)) {
27 canvas->drawImage(bitmap.asImage(), 4, 4);
28 }
29}
30} // END FIDDLE
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition SkColorType.h:23
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void scale(SkScalar sx, SkScalar sy)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
static bool b
struct MyStruct a[10]
size_t minRowBytes() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)