Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Image_scalePixels.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(Image_scalePixels, 256, 128, false, 3) {
5void draw(SkCanvas* canvas) {
6 std::vector<int32_t> srcPixels;
7 int quarterWidth = image->width() / 16;
8 int rowBytes = quarterWidth * 4;
9 int quarterHeight = image->height() / 16;
10 srcPixels.resize(quarterHeight * rowBytes);
11 SkPixmap pixmap(SkImageInfo::MakeN32Premul(quarterWidth, quarterHeight),
12 &srcPixels.front(), rowBytes);
13 canvas->scale(4, 4);
14
15 const SkSamplingOptions samplings[] = {
19 SkSamplingOptions({1.0f/3, 1.0f/3}),
20 };
21 for (unsigned index = 0; index < std::size(samplings); ++index) {
22 image->scalePixels(pixmap, samplings[index]);
23 sk_sp<SkImage> filtered = SkImages::RasterFromPixmap(pixmap, nullptr, nullptr);
24 canvas->drawImage(filtered, 16 * index, 0);
25 }
26}
27} // END FIDDLE
REG_FIDDLE(Image_scalePixels, 256, 128, false, 3)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
int width() const
Definition: SkImage.h:285
int height() const
Definition: SkImage.h:291
bool scalePixels(const SkPixmap &dst, const SkSamplingOptions &, CachingHint cachingHint=kAllow_CachingHint) const
Definition: SkImage.cpp:127
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SkSamplingOptions(SkFilterMode::kLinear))
def filtered(names, to_skip)
Definition: zip_utils.py:20
static SkImageInfo MakeN32Premul(int width, int height)