Flutter Engine
The Flutter Engine
Bitmap_readPixels_3.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_3, 256, 128, false, 3) {
5void draw(SkCanvas* canvas) {
6 std::vector<int32_t> srcPixels;
7 srcPixels.resize(source.height() * source.width() * 8);
8 for (int i = 0; i < 2; ++i) {
11 &srcPixels.front() + i * source.width(), source.rowBytes() * 2);
12 source.readPixels(pixmap);
13 }
14 canvas->scale(.25f, .25f);
17 &srcPixels.front(), source.rowBytes() * 2);
18 canvas->drawImage(bitmap.asImage(), 0, 0);
19}
20} // END FIDDLE
REG_FIDDLE(Bitmap_readPixels_3, 256, 128, false, 3)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
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
Definition: bitmap.py:1
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)