blob: 225b59832d1a79240b12f53265ac0ac8f8f4cc64 [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=9a392b753167cfa849cebeefd5a6e07d
5REG_FIDDLE(Pixmap_003, 256, 64, false, 4) {
6void draw(SkCanvas* canvas) {
7 std::vector<int32_t> pixels;
8 pixels.resize(image->height() * image->width() * 4);
9 SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
10 image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
11 image->readPixels(pixmap, 0, 0);
12 int x = 0;
13 for (auto colorType : { kRGBA_8888_SkColorType, kBGRA_8888_SkColorType } ) {
14 pixmap.reset(SkImageInfo::Make(image->width(), image->height(), colorType,
15 image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
16 SkBitmap bitmap;
17 bitmap.installPixels(pixmap);
18 canvas->drawBitmap(bitmap, x, 0);
19 x += 128;
20 }
21}
22} // END FIDDLE