Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
skpaint_color_table_filter.cpp
Go to the documentation of this file.
1// 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.
4REG_FIDDLE(skpaint_color_table_filter, 256, 256, false, 3) {
5void draw(SkCanvas* canvas) {
6 canvas->scale(0.5, 0.5);
7 uint8_t ct[256];
8 for (int i = 0; i < 256; ++i) {
9 int x = (i - 96) * 255 / 64;
10 ct[i] = x < 0 ? 0 : x > 255 ? 255 : x;
11 }
13 paint.setColorFilter(SkColorFilters::TableARGB(nullptr, ct, ct, ct));
14 canvas->drawImage(image, 0, 0, SkSamplingOptions(), &paint);
15}
16} // END FIDDLE
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void scale(SkScalar sx, SkScalar sy)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
static sk_sp< SkColorFilter > TableARGB(const uint8_t tableA[256], const uint8_t tableR[256], const uint8_t tableG[256], const uint8_t tableB[256])
const Paint & paint
sk_sp< SkImage > image
Definition examples.cpp:29
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
double x