blob: d3f0637ee2cc6c9b333bbf98fe7e9c261eaacb95 [file] [log] [blame]
Hal Canary83c2f702019-03-07 14:53:03 -05001// 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 "fiddle/examples.h"
4// HASH=809284db136748208b3efc31cd89de29
5REG_FIDDLE(Pixmap_034, 256, 64, false, 0) {
6void draw(SkCanvas* canvas) {
7 uint8_t storage[][5] = {{ 0, 0, 64, 0, 0},
8 { 0, 128, 255, 128, 0},
9 {64, 255, 255, 255, 64},
10 { 0, 128, 255, 128, 0},
11 { 0, 0, 64, 0, 0}};
12 SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kPremul_SkAlphaType);
13 SkPixmap pixmap(imageInfo, storage[0], 5);
14 SkBitmap bitmap;
15 bitmap.installPixels(pixmap);
16 canvas->scale(10, 10);
17 canvas->drawBitmap(bitmap, 0, 0);
18 *pixmap.writable_addr8(2, 2) = 0;
19// bitmap.installPixels(pixmap); // uncomment to fix on GPU
20 canvas->drawBitmap(bitmap, 10, 0);
21}
22} // END FIDDLE