blob: 506d3b06e61a05b05858116df4d3b5b2996e4db1 [file] [log] [blame]
Hal Canary6c8422c2020-01-10 15:22:09 -05001// Copyright 2020 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"
4REG_FIDDLE(f16to8888busted, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
6 // Create the linear-rgb color space and the image info
7 sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeSRGBLinear();
8 SkImageInfo info = SkImageInfo::Make(100, 100, SkColorType::kRGBA_F16_SkColorType,
9 SkAlphaType::kPremul_SkAlphaType, colorSpace);
10
11 sk_sp<SkSurface> offscreen = SkSurface::MakeRaster(info);
12 SkPaint paint;
13 offscreen->getCanvas()->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), paint);
14
15 // Take a snapshot from surface and draw it on the canvas
16 sk_sp<SkImage> img = offscreen->makeImageSnapshot();
Mike Reedb339d052021-01-28 11:20:41 -050017 canvas->drawImageRect(img, SkRect::MakeWH(100, 100), SkSamplingOptions());
Hal Canary6c8422c2020-01-10 15:22:09 -050018}
19} // END FIDDLE