Flutter Engine
The Flutter Engine
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 4 of file Image_readPixels.cpp.

4 {
5void draw(SkCanvas* canvas) {
6 canvas->scale(.5f, .5f);
7 const int width = 32;
8 const int height = 32;
9 std::vector<int32_t> dstPixels;
10 dstPixels.resize(height * width * 4);
12 for (int y = 0; y < 512; y += height ) {
13 for (int x = 0; x < 512; x += width ) {
14 if (image->readPixels(nullptr, info, &dstPixels.front(), width * 4, x, y)) {
15 SkPixmap dstPixmap(info, &dstPixels.front(), width * 4);
17 bitmap.installPixels(dstPixmap);
18 canvas->drawImage(bitmap.asImage(), 0, 0);
19 }
20 canvas->translate(48, 0);
21 }
22 canvas->translate(-16 * 48, 48);
23 }
24}
25} // 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)
Definition: SkCanvas.cpp:1278
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
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
double y
double x
sk_sp< const SkImage > image
Definition: SkRecords.h:269
Definition: bitmap.py:1
int32_t height
int32_t width
static SkImageInfo MakeN32Premul(int width, int height)