Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Image_encodeToData_2.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.
4// HASH=30cee813f6aa476b0a9c8a24283e53a3
5REG_FIDDLE(Image_encodeToData_2, 256, 256, false, 3) {
6void draw(SkCanvas* canvas) {
7 canvas->scale(4, 4);
8 SkIRect subset = {136, 32, 200, 96};
9 // This prevents re-encoding the image's pixels if the image itself was created from
10 // something like an encoded PNG.
12 if (!data) {
13 data = SkPngEncoder::Encode(nullptr, image.get(), {});
14 }
16 canvas->drawImage(eye, 0, 0);
17}
18} // 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
sk_sp< SkData > refEncodedData() const
Definition SkImage.cpp:214
virtual sk_sp< SkImage > makeSubset(GrDirectContext *direct, const SkIRect &subset) const =0
T * get() const
Definition SkRefCnt.h:303
sk_sp< SkImage > image
Definition examples.cpp:29
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)