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=e006bb05cf74ec8d2b3d6adeb5dba11b
5 REG_FIDDLE(Bitmap_getPixels, 256, 256, true, 0) {
draw(SkCanvas * canvas)6 void draw(SkCanvas* canvas) {
7 SkBitmap bitmap;
8 bitmap.setInfo(SkImageInfo::MakeN32(4, 4, kPremul_SkAlphaType));
9 bitmap.allocPixels();
10 bitmap.eraseColor(0x00000000);
11 void* baseAddr = bitmap.getPixels();
12 *(SkPMColor*)baseAddr = 0xFFFFFFFF;
13 SkDebugf("bitmap.getColor(0, 1) %c= 0x00000000\n",
14 bitmap.getColor(0, 1) == 0x00000000 ? '=' : '!');
15 SkDebugf("bitmap.getColor(0, 0) %c= 0xFFFFFFFF\n",
16 bitmap.getColor(0, 0) == 0xFFFFFFFF ? '=' : '!');
17 }
18 } // END FIDDLE
19