Flutter Engine
The Flutter Engine
Bitmap_installPixels_2.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.
4
5#include <climits>
6#include <random>
7
8REG_FIDDLE(Bitmap_installPixels_2, 256, 256, false, 0) {
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
REG_FIDDLE(Bitmap_installPixels_2, 256, 256, false, 0)
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)