blob: 56b11d2f25d2a7da4639e9e399ae0482ea4c6fa4 [file] [log] [blame]
Hal Canary6c8422c2020-01-10 15:22:09 -05001// 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"
4REG_FIDDLE(draw_a8_bitmap, 256, 256, false, 3) {
5void 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);
Mike Reedecdd9792021-01-27 20:39:22 -050016 canvas->drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(), &paint);
Hal Canary6c8422c2020-01-10 15:22:09 -050017}
18} // END FIDDLE