Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
bitmaprecttest.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkImage.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"

Go to the source code of this file.

Functions

static sk_sp< SkImagemake_bm ()
 
 DEF_SIMPLE_GM (bitmaprecttest, canvas, 320, 240)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( bitmaprecttest  ,
canvas  ,
320  ,
240   
)

Definition at line 39 of file bitmaprecttest.cpp.

39 {
40 auto image = make_bm();
41
42 canvas->drawImage(image, 150, 45);
43
44 SkScalar scale = 0.472560018f;
45 canvas->save();
46 canvas->scale(scale, scale);
47 canvas->drawImageRect(image, SkRect::MakeXYWH(100, 100, 128, 128), SkSamplingOptions());
48 canvas->restore();
49
50 canvas->scale(-1, 1);
51 canvas->drawImage(image, -310, 45);
52}
static sk_sp< SkImage > make_bm()
sk_sp< SkImage > image
Definition examples.cpp:29
float SkScalar
Definition extension.cpp:12
const Scalar scale
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659

◆ make_bm()

static sk_sp< SkImage > make_bm ( )
static

Definition at line 17 of file bitmaprecttest.cpp.

17 {
18 SkBitmap bm;
19 bm.allocN32Pixels(60, 60);
20 bm.eraseColor(0);
21
22 SkCanvas canvas(bm);
24 canvas.drawPath(SkPath::Polygon({{6,6}, {6,54}, {30,54}}, false), paint);
25
27 canvas.drawRect(SkRect::MakeLTRB(0.5f, 0.5f, 59.5f, 59.5f), paint);
28 return bm.asImage();
29}
sk_sp< SkImage > asImage() const
Definition SkBitmap.cpp:645
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition SkBitmap.cpp:232
void eraseColor(SkColor4f) const
Definition SkBitmap.cpp:442
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
static SkPath Polygon(const SkPoint pts[], int count, bool isClosed, SkPathFillType=SkPathFillType::kWinding, bool isVolatile=false)
Definition SkPath.cpp:3546
const Paint & paint
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition SkRect.h:646