| 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(Surface_MakeRasterN32Premul, 256, 256, true, 0) { |
| 5 |
void draw(SkCanvas* ) { |
| 6 |
sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(3, 3))); |
| 7 |
SkCanvas* canvas = surface->getCanvas(); |
| 8 |
canvas->clear(SK_ColorWHITE); |
| 9 |
SkPixmap pixmap; |
| 10 |
if (surface->peekPixels(&pixmap)) { |
| 11 |
const uint32_t* colorPtr = pixmap.addr32(); |
| 12 |
SkPMColor pmWhite = colorPtr[0]; |
| 13 |
SkPaint paint; |
| 14 |
canvas->drawPoint(1, 1, paint); |
| 15 |
for (int y = 0; y < surface->height(); ++y) { |
| 16 |
for (int x = 0; x < surface->width(); ++x) { |
| 17 |
SkDebugf("%c", colorPtr[x] == pmWhite ? '-' : 'x'); |
| 18 |
} |
| 19 |
colorPtr += surface->width(); |
| 20 |
SkDebugf("\n"); |
| 21 |
} |
| 22 |
} |
| 23 |
} |
| 24 |
} // END FIDDLE |