Flutter Engine
The Flutter Engine
Functions
Bitmap_installPixels_2.cpp File Reference
#include "tools/fiddle/examples.h"
#include <climits>
#include <random>

Go to the source code of this file.

Functions

 REG_FIDDLE (Bitmap_installPixels_2, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Bitmap_installPixels_2  ,
256  ,
256  ,
false  ,
 
)

Definition at line 8 of file Bitmap_installPixels_2.cpp.

8 {
9void draw(SkCanvas* canvas) {
10 std::default_random_engine rng;
11 const auto randUint = [&rng](uint32_t min, uint32_t max) -> uint32_t {
12 return std::uniform_int_distribution<uint32_t>(min, max)(rng);
13 };
15 const int width = 8;
16 const int height = 8;
17 uint32_t pixels[width * height];
18 for (unsigned x = 0; x < width * height; ++x) {
19 pixels[x] = randUint(0, UINT_MAX);
20 }
22 if (bitmap.installPixels(info, pixels, info.minRowBytes())) {
23 canvas->scale(32, 32);
24 canvas->drawImage(bitmap.asImage(), 0, 0);
25 }
26}
27} // END FIDDLE
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
kUnpremul_SkAlphaType
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
double x
Definition: bitmap.py:1
int32_t height
int32_t width
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)