Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Color_Type_Gray_8.cpp
Go to the documentation of this file.
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.
4// HASH=93da0eb0b6722a4f33dc7dae094abf0b
5REG_FIDDLE(Color_Type_Gray_8, 256, 64, false, 0) {
6void draw(SkCanvas* canvas) {
7 canvas->scale(16, 16);
10 bitmap.allocPixels(imageInfo);
11 SkCanvas offscreen(bitmap);
12 offscreen.clear(SK_ColorGREEN);
13 canvas->drawImage(bitmap.asImage(), 0, 0);
14 uint8_t gray8[] = { 0xFF, 0xBB, 0x77, 0x33 };
15 SkPixmap grayPixmap(imageInfo, &gray8, imageInfo.minRowBytes());
16 if (bitmap.writePixels(grayPixmap, 0, 0)) {
17 canvas->drawImage(bitmap.asImage(), 2, 2);
18 }
19}
20} // END FIDDLE
static const uint8_t gray8[kNumPixels]
@ kOpaque_SkAlphaType
pixel is opaque
Definition SkAlphaType.h:28
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition SkColorType.h:35
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void clear(SkColor color)
Definition SkCanvas.h:1199
void scale(SkScalar sx, SkScalar sy)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
size_t minRowBytes() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)