1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC. 2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h" 4cb93a386Sopenharmony_ci// HASH=7ef3d043c4c5885649e591dd7dca92ff 5cb93a386Sopenharmony_ciREG_FIDDLE(Bitmap_tryAllocPixels_2, 256, 256, false, 3) { 6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 7cb93a386Sopenharmony_ci SkBitmap bitmap; 8cb93a386Sopenharmony_ci if (bitmap.tryAllocPixels(SkImageInfo::Make(64, 64, kGray_8_SkColorType, kOpaque_SkAlphaType))) { 9cb93a386Sopenharmony_ci SkCanvas offscreen(bitmap); 10cb93a386Sopenharmony_ci offscreen.scale(.25f, .5f); 11cb93a386Sopenharmony_ci for (int y : { 0, 64, 128, 192 } ) { 12cb93a386Sopenharmony_ci offscreen.drawImage(source.asImage(), -y, -y); 13cb93a386Sopenharmony_ci canvas->drawImage(bitmap.asImage(), y, y); 14cb93a386Sopenharmony_ci } 15cb93a386Sopenharmony_ci } 16cb93a386Sopenharmony_ci} 17cb93a386Sopenharmony_ci} // END FIDDLE 18