blob: da6986122335a512170891c7bb298f241e614fb0 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001#if 0 // Disabled until updated to use current API.
2// Copyright 2019 Google LLC.
3// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05004#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04005// HASH=900c0eab8dfdecd8301ed5be95887f8e
Hal Canarya7181e7c2019-03-18 16:06:34 -04006REG_FIDDLE(Image_peekPixels, 256, 256, true, 0) {
Hal Canary87515122019-03-15 14:22:51 -04007void draw(SkCanvas* canvas) {
8 SkBitmap bitmap;
9 bitmap.allocPixels(SkImageInfo::MakeN32Premul(12, 11));
10 SkCanvas offscreen(bitmap);
11 offscreen.clear(SK_ColorWHITE);
12 SkPaint paint;
13 offscreen.drawString("%", 1, 10, paint);
14 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
15 SkPixmap pixmap;
16 if (image->peekPixels(&pixmap)) {
17 const SkPMColor* pixels = pixmap.addr32();
18 SkPMColor pmWhite = pixels[0];
19 for (int y = 0; y < image->height(); ++y) {
20 for (int x = 0; x < image->width(); ++x) {
21 SkDebugf("%c", *pixels++ == pmWhite ? '-' : 'x');
22 }
23 SkDebugf("\n");
24 }
25 }
26}
27} // END FIDDLE
28#endif // Disabled until updated to use current API.