Flutter Engine
The Flutter Engine
draw_pixel_array_with_copy.cpp
Go to the documentation of this file.
1// Copyright 2020 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(draw_pixel_array_with_copy, 256, 256, false, 5) {
5void draw(SkCanvas* canvas) {
6 constexpr int width = 4;
7 constexpr int height = 4;
8 const uint32_t pixels[height * width] = {
9 0xFF000000, 0xFF005500, 0xFF00AA00, 0xFF00FF00,
10 0xFF000055, 0xFF005555, 0xFF00AA55, 0xFF00FF55,
11 0xFF0000AA, 0xFF0055AA, 0xFF00AAAA, 0xFF00FFAA,
12 0xFF0000FF, 0xFF0055FF, 0xFF00AAFF, 0xFF00FFFF,
13 };
14 SkPixmap pixmap(SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType),
15 pixels, sizeof(uint32_t) * width);
17
18 canvas->scale(16,16);
19 canvas->drawImage(img, 6, 6);
20}
21} // END FIDDLE
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
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
REG_FIDDLE(draw_pixel_array_with_copy, 256, 256, false, 5)
SK_API sk_sp< SkImage > RasterFromPixmapCopy(const SkPixmap &pixmap)
int32_t height
int32_t width
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)