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=a7e04447b2081010c50d7920e80a6bb2 5cb93a386Sopenharmony_ciREG_FIDDLE(Bitmap_installPixels_2, 256, 256, false, 0) { 6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 7cb93a386Sopenharmony_ci SkRandom random; 8cb93a386Sopenharmony_ci SkBitmap bitmap; 9cb93a386Sopenharmony_ci const int width = 8; 10cb93a386Sopenharmony_ci const int height = 8; 11cb93a386Sopenharmony_ci uint32_t pixels[width * height]; 12cb93a386Sopenharmony_ci for (unsigned x = 0; x < width * height; ++x) { 13cb93a386Sopenharmony_ci pixels[x] = random.nextU(); 14cb93a386Sopenharmony_ci } 15cb93a386Sopenharmony_ci SkImageInfo info = SkImageInfo::MakeN32(width, height, kUnpremul_SkAlphaType); 16cb93a386Sopenharmony_ci if (bitmap.installPixels(info, pixels, info.minRowBytes())) { 17cb93a386Sopenharmony_ci canvas->scale(32, 32); 18cb93a386Sopenharmony_ci canvas->drawImage(bitmap.asImage(), 0, 0); 19cb93a386Sopenharmony_ci } 20cb93a386Sopenharmony_ci} 21cb93a386Sopenharmony_ci} // END FIDDLE 22