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=de418ccb42471d1589508ef3955f8c53
5cb93a386Sopenharmony_ciREG_FIDDLE(ImageInfo_MakeS32, 256, 128, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    const int width = 256;
8cb93a386Sopenharmony_ci    const int height = 32;
9cb93a386Sopenharmony_ci    SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
10cb93a386Sopenharmony_ci    SkColor  gradColors[] = { 0xFFAA0055, 0xFF11CC88 };
11cb93a386Sopenharmony_ci    SkPoint  gradPoints[] = { { 0, 0 }, { width, 0 } };
12cb93a386Sopenharmony_ci    SkPaint gradPaint;
13cb93a386Sopenharmony_ci    gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr,
14cb93a386Sopenharmony_ci                    SK_ARRAY_COUNT(gradColors), SkTileMode::kClamp));
15cb93a386Sopenharmony_ci    SkBitmap bitmap;
16cb93a386Sopenharmony_ci    bitmap.allocPixels(SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType));
17cb93a386Sopenharmony_ci    SkCanvas offScreen(bitmap);
18cb93a386Sopenharmony_ci    offScreen.drawRect(SkRect::MakeWH(width, height), gradPaint);
19cb93a386Sopenharmony_ci    canvas->drawImage(bitmap.asImage(), 0, 0);
20cb93a386Sopenharmony_ci    bitmap.allocPixels(SkImageInfo::MakeS32(width, height, kPremul_SkAlphaType));
21cb93a386Sopenharmony_ci    SkCanvas sRGBOffscreen(bitmap);
22cb93a386Sopenharmony_ci    sRGBOffscreen.drawRect(SkRect::MakeWH(width, height), gradPaint);
23cb93a386Sopenharmony_ci    canvas->drawImage(bitmap.asImage(), 0, 48);
24cb93a386Sopenharmony_ci    SkBitmap noColorSpaceBitmap;
25cb93a386Sopenharmony_ci    noColorSpaceBitmap.setInfo(SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType));
26cb93a386Sopenharmony_ci    noColorSpaceBitmap.setPixels(bitmap.getAddr(0, 0));
27cb93a386Sopenharmony_ci    canvas->drawImage(noColorSpaceBitmap.asImage(), 0, 96);
28cb93a386Sopenharmony_ci}
29cb93a386Sopenharmony_ci}  // END FIDDLE
30