Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
Image_readPixels.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (Image_readPixels, 256, 256, false, 3)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Image_readPixels  ,
256  ,
256  ,
false  ,
 
)

Definition at line 5 of file Image_readPixels.cpp.

5 {
6void draw(SkCanvas* canvas) {
7 canvas->scale(.5f, .5f);
8 const int width = 32;
9 const int height = 32;
10 std::vector<int32_t> dstPixels;
11 dstPixels.resize(height * width * 4);
13 for (int y = 0; y < 512; y += height ) {
14 for (int x = 0; x < 512; x += width ) {
15 if (image->readPixels(nullptr, info, &dstPixels.front(), width * 4, x, y)) {
16 SkPixmap dstPixmap(info, &dstPixels.front(), width * 4);
18 bitmap.installPixels(dstPixmap);
19 canvas->drawImage(bitmap.asImage(), 0, 0);
20 }
21 canvas->translate(48, 0);
22 }
23 canvas->translate(-16 * 48, 48);
24 }
25}
26} // END FIDDLE
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void translate(SkScalar dx, SkScalar dy)
void scale(SkScalar sx, SkScalar sy)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
bool readPixels(GrDirectContext *context, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
Definition SkImage.cpp:42
sk_sp< SkImage > image
Definition examples.cpp:29
double y
double x
int32_t height
int32_t width
static SkImageInfo MakeN32Premul(int width, int height)