Flutter Engine
The Flutter Engine
Bitmap_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(Bitmap_readPixels, 256, 128, false, 0) {
5void draw(SkCanvas* canvas) {
6 const int width = 256;
7 const int height = 64;
9 SkColor gradColors[] = { 0xFFAA3300, 0x7F881122 };
10 SkPoint gradPoints[] = { { 0, 0 }, { 256, 0 } };
12 paint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr,
13 std::size(gradColors), SkTileMode::kClamp));
15 bitmap.allocPixels(srcInfo);
16 SkCanvas srcCanvas(bitmap);
18 canvas->drawImage(bitmap.asImage(), 0, 0);
20 std::vector<int16_t> dstPixels;
21 dstPixels.resize(height * width);
22 bitmap.readPixels(dstInfo, &dstPixels.front(), width * 2, 0, 0);
23 SkPixmap dstPixmap(dstInfo, &dstPixels.front(), width * 2);
24 bitmap.installPixels(dstPixmap);
25 canvas->drawImage(bitmap.asImage(), 0, 64);
26}
27} // END FIDDLE
REG_FIDDLE(Bitmap_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)
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