2019-03-15 18:22:51 +00:00
|
|
|
// Copyright 2019 Google LLC.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/fiddle/examples.h"
|
2019-03-15 18:22:51 +00:00
|
|
|
// HASH=809284db136748208b3efc31cd89de29
|
2019-03-18 20:06:34 +00:00
|
|
|
REG_FIDDLE(Pixmap_writable_addr8, 256, 64, false, 0) {
|
2019-03-15 18:22:51 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
uint8_t storage[][5] = {{ 0, 0, 64, 0, 0},
|
|
|
|
{ 0, 128, 255, 128, 0},
|
|
|
|
{64, 255, 255, 255, 64},
|
|
|
|
{ 0, 128, 255, 128, 0},
|
|
|
|
{ 0, 0, 64, 0, 0}};
|
|
|
|
SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kPremul_SkAlphaType);
|
|
|
|
SkPixmap pixmap(imageInfo, storage[0], 5);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
bitmap.installPixels(pixmap);
|
|
|
|
canvas->scale(10, 10);
|
2021-01-28 01:39:22 +00:00
|
|
|
canvas->drawImage(bitmap.asImage(), 0, 0);
|
2019-03-15 18:22:51 +00:00
|
|
|
*pixmap.writable_addr8(2, 2) = 0;
|
|
|
|
// bitmap.installPixels(pixmap); // uncomment to fix on GPU
|
2021-01-28 01:39:22 +00:00
|
|
|
canvas->drawImage(bitmap.asImage(), 10, 0);
|
2019-03-15 18:22:51 +00:00
|
|
|
}
|
|
|
|
} // END FIDDLE
|