1 // Copyright 2020 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(draw_a8_bitmap, 256, 256, false, 3) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 SkBitmap bitmap;
7 bitmap.allocPixels(SkImageInfo::MakeA8(256, 256));
8 for (int y = 0; y < bitmap.height(); ++y) {
9 for (int x = 0; x < bitmap.width(); ++x) {
10 *bitmap.getAddr8(x, y) = (2 * x + 2 * y) & 0xFF;
11 }
12 }
13 SkPaint paint;
14 paint.setColor(0xFF00FF00);
15 canvas->clear(0xFF000000);
16 canvas->drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(), &paint);
17 }
18 } // END FIDDLE
19