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=4590fbf052659d6e629fbfd827081ae5
5cb93a386Sopenharmony_ciREG_FIDDLE(Bitmap_readPixels_3, 256, 128, false, 3) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    std::vector<int32_t> srcPixels;
8cb93a386Sopenharmony_ci    srcPixels.resize(source.height() * source.width() * 8);
9cb93a386Sopenharmony_ci    for (int i = 0;  i < 2; ++i) {
10cb93a386Sopenharmony_ci    SkPixmap pixmap(SkImageInfo::Make(source.width() * 2, source.height(),
11cb93a386Sopenharmony_ci                    i ? kRGBA_8888_SkColorType : kBGRA_8888_SkColorType, kPremul_SkAlphaType),
12cb93a386Sopenharmony_ci                    &srcPixels.front() + i * source.width(), source.rowBytes() * 2);
13cb93a386Sopenharmony_ci        source.readPixels(pixmap);
14cb93a386Sopenharmony_ci    }
15cb93a386Sopenharmony_ci    canvas->scale(.25f, .25f);
16cb93a386Sopenharmony_ci    SkBitmap bitmap;
17cb93a386Sopenharmony_ci    bitmap.installPixels(SkImageInfo::MakeN32Premul(source.width() * 2, source.height()),
18cb93a386Sopenharmony_ci                         &srcPixels.front(), source.rowBytes() * 2);
19cb93a386Sopenharmony_ci    canvas->drawImage(bitmap.asImage(), 0, 0);
20cb93a386Sopenharmony_ci}
21cb93a386Sopenharmony_ci}  // END FIDDLE
22