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. 4 #include "tools/fiddle/examples.h" 5 // HASH=900c0eab8dfdecd8301ed5be95887f8e 6 REG_FIDDLE(Image_peekPixels, 256, 256, true, 0) { 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. 29