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 REG_FIDDLE(Canvas_readPixels_b, 256, 256, true, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 canvas->clear(0x8055aaff);
7 for (SkAlphaType alphaType : { kPremul_SkAlphaType, kUnpremul_SkAlphaType } ) {
8 uint32_t pixel = 0;
9 SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, alphaType);
10 if (canvas->readPixels(info, &pixel, 4, 0, 0)) {
11 SkDebugf("pixel = %08x\n", pixel);
12 }
13 }
14 }
15 } // END FIDDLE
16