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

Go to the source code of this file.

Functions

 REG_FIDDLE (Canvas_MakeRasterDirectN32, 256, 256, true, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Canvas_MakeRasterDirectN32  ,
256  ,
256  ,
true  ,
 
)

Definition at line 5 of file Canvas_MakeRasterDirectN32.cpp.

5 {
6void draw(SkCanvas* ) {
7 const int width = 3;
8 const int height = 3;
9 SkPMColor pixels[height][width]; // allocate a 3 by 3 Premultiplied bitmap on the stack
10 // create a SkCanvas backed by a raster device, and delete it when the
11 // function goes out of scope.
12 std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirectN32(
13 width,
14 height,
15 pixels[0], // top-left of the bitmap
16 sizeof(pixels[0])); // byte width of the each row
17 // write a Premultiplied value for white into all pixels in the bitmap
18 canvas->clear(SK_ColorWHITE);
19 SkPMColor pmWhite = pixels[0][0]; // the Premultiplied format may vary
20 SkPaint paint; // by default, draws black
21 canvas->drawPoint(1, 1, paint); // draw in the center
22 for (int y = 0; y < height; ++y) {
23 for (int x = 0; x < width; ++x) {
24 SkDebugf("%c", pixels[y][x] == pmWhite ? '-' : 'x');
25 }
26 SkDebugf("\n");
27 }
28}
29} // END FIDDLE
uint32_t SkPMColor
Definition SkColor.h:205
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
static std::unique_ptr< SkCanvas > MakeRasterDirectN32(int width, int height, SkPMColor *pixels, size_t rowBytes)
Definition SkCanvas.h:163
const Paint & paint
double y
double x
int32_t height
int32_t width