Flutter Engine
The Flutter Engine
Functions
ImageInfo_makeWH.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (ImageInfo_makeWH, 256, 144, false, 3)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( ImageInfo_makeWH  ,
256  ,
144  ,
false  ,
 
)

Definition at line 4 of file ImageInfo_makeWH.cpp.

4 {
5void draw(SkCanvas* canvas) {
6 SkImageInfo canvasImageInfo = canvas->imageInfo();
7 SkRect canvasBounds = SkRect::Make(canvasImageInfo.bounds());
10 SkImageInfo insetImageInfo =
11 canvasImageInfo.makeWH(canvasBounds.width() / 2, canvasBounds.height() / 2);
13 inset.allocPixels(insetImageInfo);
14 SkCanvas offscreen(inset);
15 offscreen.drawImageRect(image, SkRect::Make(source.bounds()), SkRect::Make(inset.bounds()),
17 canvas->drawImage(inset.asImage(), canvasBounds.width() / 4, canvasBounds.height() / 4);
18}
19} // END FIDDLE
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
SkIRect bounds() const
Definition: SkBitmap.h:382
@ 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
SkImageInfo imageInfo() const
Definition: SkCanvas.cpp:1206
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
SkBitmap source
Definition: examples.cpp:28
sk_sp< const SkImage > image
Definition: SkRecords.h:269
static SkRect inset(const SkRect &r)
SkImageInfo makeWH(int newWidth, int newHeight) const
Definition: SkImageInfo.h:444
SkIRect bounds() const
Definition: SkImageInfo.h:427
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762