Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 1 | #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 Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 4 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 5 | // HASH=900c0eab8dfdecd8301ed5be95887f8e |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 6 | REG_FIDDLE(Image_peekPixels, 256, 256, true, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 7 | void 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. |