Hal Canary | 6c8422c | 2020-01-10 15:22:09 -0500 | [diff] [blame] | 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) { |
| 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); |
Mike Reed | ecdd979 | 2021-01-27 20:39:22 -0500 | [diff] [blame] | 16 | canvas->drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(), &paint); |
Hal Canary | 6c8422c | 2020-01-10 15:22:09 -0500 | [diff] [blame] | 17 | } |
| 18 | } // END FIDDLE |