Flutter Engine
The Flutter Engine
Pixmap_readPixels.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.
4REG_FIDDLE(Pixmap_readPixels, 256, 128, false, 0) {
5void draw(SkCanvas* canvas) {
6 std::vector<int32_t> pixels;
7 const int width = 256;
8 const int height = 64;
9 pixels.resize(height * width * 4);
11 SkPixmap srcPixmap(srcInfo, (const void*) &pixels.front(), width * 4);
12 SkColor gradColors[] = { 0xFFAA3300, 0x7F881122 };
13 SkPoint gradPoints[] = { { 0, 0 }, { 256, 0 } };
15 paint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr,
16 std::size(gradColors), SkTileMode::kClamp));
18 bitmap.installPixels(srcPixmap);
19 SkCanvas srcCanvas(bitmap);
21 canvas->drawImage(bitmap.asImage(), 0, 0);
22 std::vector<int32_t> dstPixels;
23 dstPixels.resize(height * width * 2);
25 srcPixmap.readPixels(dstInfo, &dstPixels.front(), width * 2);
26 SkPixmap dstPixmap(dstInfo, &dstPixels.front(), width * 2);
27 bitmap.installPixels(dstPixmap);
28 canvas->drawImage(bitmap.asImage(), 0, 128);
29}
30} // END FIDDLE
REG_FIDDLE(Pixmap_readPixels, 256, 128, false, 0)
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition: SkColorType.h:23
uint32_t SkColor
Definition: SkColor.h:37
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes) const
Definition: SkPixmap.h:592
const Paint & paint
Definition: color_source.cc:38
Definition: bitmap.py:1
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
int32_t height
int32_t width
static SkImageInfo MakeN32Premul(int width, int height)
SkImageInfo makeColorType(SkColorType newColorType) const
Definition: SkImageInfo.h:475
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609