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.
3 #include "tools/fiddle/examples.h"
4 // HASH=2d991a231e49d1de13eeb2ba9b440e01
5 REG_FIDDLE(Surface_readPixels_3, 256, 256, false, 0) {
6 void draw(SkCanvas* canvas) {
7 sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64));
8 auto surfCanvas = surf->getCanvas();
9 surfCanvas->clear(SK_ColorGREEN);
11 surfCanvas->drawOval({2, 10, 58, 54}, paint);
12 SkImageInfo info = SkImageInfo::Make(64, 64, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
16 for (int x : { 32, -32 } ) {
17 for (int y : { 32, -32 } ) {
18 surf->readPixels(bitmap, x, y);
21 canvas->drawImage(bitmap.asImage(), 0, 0);