Flutter Engine
The Flutter Engine
Canvas_drawImageRect_4.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.
4REG_FIDDLE(Canvas_drawImageRect_4, 256, 64, false, 0) {
5void draw(SkCanvas* canvas) {
6 uint32_t pixels[][2] = { { SK_ColorBLACK, SK_ColorWHITE },
9 bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2),
10 (void*) pixels, sizeof(pixels[0]));
11 sk_sp<SkImage> image = bitmap.asImage();
13 canvas->scale(4, 4);
14 for (auto alpha : { 50, 100, 150, 255 } ) {
15 paint.setAlpha(alpha);
18 canvas->translate(8, 0);
19 }
20}
21} // END FIDDLE
REG_FIDDLE(Canvas_drawImageRect_4, 256, 64, false, 0)
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition: SkCanvas.h:1542
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
const Paint & paint
Definition: color_source.cc:38
sk_sp< const SkImage > image
Definition: SkRecords.h:269
Definition: bitmap.py:1
SkSamplingOptions(SkFilterMode::kLinear))
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609