Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Canvas_readPixels_a.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.
4// HASH=102d014d7f753db2a9b9ee08893aaf11
5REG_FIDDLE(Canvas_readPixels_a, 64, 64, false, 0) {
6void draw(SkCanvas* canvas) {
7 canvas->clear(SK_ColorBLUE);
9 canvas->drawCircle(32, 32, 28, paint);
11 sk_sp<SkData> data(SkData::MakeUninitialized(info.minRowBytes() * info.height()));
12 sk_bzero(data->writable_data(), info.minRowBytes() * info.height());
13 for (int x : { 32, -32 } ) {
14 for (int y : { 32, -32 } ) {
15 canvas->readPixels(info, data->writable_data(), info.minRowBytes(), x, y);
16 }
17 }
19 canvas->drawImage(image, 0, 0);
20}
21} // END FIDDLE
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ 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
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
static void sk_bzero(void *buffer, size_t size)
Definition SkMalloc.h:105
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void clear(SkColor color)
Definition SkCanvas.h:1199
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY)
Definition SkCanvas.cpp:386
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
static sk_sp< SkData > MakeUninitialized(size_t length)
Definition SkData.cpp:116
const Paint & paint
sk_sp< SkImage > image
Definition examples.cpp:29
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
double y
double x
SK_API sk_sp< SkImage > RasterFromData(const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)