Flutter Engine
The Flutter Engine
Bitmap_readPixels_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.
4REG_FIDDLE(Bitmap_readPixels_2, 256, 256, false, 3) {
5void draw(SkCanvas* canvas) {
6 std::vector<int32_t> srcPixels;
7 srcPixels.resize(source.height() * source.rowBytes());
8 for (int y = 0; y < 4; ++y) {
9 for (int x = 0; x < 4; ++x) {
11 &srcPixels.front() + x * source.height() * source.width() / 4 +
12 y * source.width() / 4, source.rowBytes());
13 source.readPixels(pixmap, x * source.width() / 4, y * source.height() / 4);
14 }
15 }
16 canvas->scale(.5f, .5f);
19 &srcPixels.front(), source.rowBytes());
20 canvas->drawImage(bitmap.asImage(), 0, 0);
21}
22} // END FIDDLE
REG_FIDDLE(Bitmap_readPixels_2, 256, 256, false, 3)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
int width() const
Definition: SkBitmap.h:149
size_t rowBytes() const
Definition: SkBitmap.h:238
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY) const
Definition: SkBitmap.cpp:488
int height() const
Definition: SkBitmap.h:158
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
SkBitmap source
Definition: examples.cpp:28
double y
double x
Definition: bitmap.py:1
static SkImageInfo MakeN32Premul(int width, int height)