Debian Codegraph @

docs/examples/Canvas_writePixels_2.cpp

raw
1 // 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 "tools/fiddle/examples.h"
4 REG_FIDDLE(Canvas_writePixels_2, 256, 256, false, 0) {
5 void draw(SkCanvas* canvas) {
6 SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(2, 2);
7 SkBitmap bitmap;
8 uint32_t pixels[4];
9 bitmap.installPixels(imageInfo, pixels, imageInfo.minRowBytes());
10 for (int y = 0; y < 256; y += 2) {
11 for (int x = 0; x < 256; x += 2) {
12 pixels[0] = SkColorSetRGB(x, y, x | y);
13 pixels[1] = SkColorSetRGB(x ^ y, y, x);
14 pixels[2] = SkColorSetRGB(x, x & y, y);
15 pixels[3] = SkColorSetRGB((~x) & 0xFF, (~y) & 0xFF, x);
16 canvas->writePixels(bitmap, x, y);
17 }
18 }
19 }
20 } // END FIDDLE