blob: 0d54ca4278582eff983f9a9c2e9f45e8ab529ce6 [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=93da0eb0b6722a4f33dc7dae094abf0b
5REG_FIDDLE(ImageInfo_011, 256, 64, false, 0) {
6void draw(SkCanvas* canvas) {
7 canvas->scale(16, 16);
8 SkBitmap bitmap;
9 SkImageInfo imageInfo = SkImageInfo::Make(2, 2, kGray_8_SkColorType, kOpaque_SkAlphaType);
10 bitmap.allocPixels(imageInfo);
11 SkCanvas offscreen(bitmap);
12 offscreen.clear(SK_ColorGREEN);
13 canvas->drawBitmap(bitmap, 0, 0);
14 uint8_t gray8[] = { 0xFF, 0xBB, 0x77, 0x33 };
15 SkPixmap grayPixmap(imageInfo, &gray8, imageInfo.minRowBytes());
16 if (bitmap.writePixels(grayPixmap, 0, 0)) {
17 canvas->drawBitmap(bitmap, 2, 2);
18 }
19}
20} // END FIDDLE