Flutter Engine
The Flutter Engine
ImageInfo_makeWH.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(ImageInfo_makeWH, 256, 144, false, 3) {
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);
17 canvas->drawImage(inset.asImage(), canvasBounds.width() / 4, canvasBounds.height() / 4);
18}
19} // END FIDDLE
REG_FIDDLE(ImageInfo_makeWH, 256, 144, false, 3)
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