xref: /aosp_15_r20/external/skia/docs/examples/Pixmap_computeByteSize.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 #include "tools/fiddle/examples.h"
4 REG_FIDDLE(Pixmap_computeByteSize, 256, 256, true, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6     SkPixmap pixmap;
7     for (int width : { 1, 1000, 1000000 } ) {
8         for (int height: { 1, 1000, 1000000 } ) {
9             SkImageInfo imageInfo = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType);
10             pixmap.reset(imageInfo, nullptr, width * 5);
11             SkDebugf("width: %7d height: %7d computeByteSize: %13zu\n", width, height,
12                      pixmap.computeByteSize());
13         }
14     }
15 }
16 }  // END FIDDLE
17