Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Image_RasterFromData.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=22e7ce79ab2fe94252d23319f2258127
5REG_FIDDLE(Image_RasterFromData, 256, 256, false, 3) {
6void draw(SkCanvas* canvas) {
11 image->readPixels(nullptr, dstInfo, data->writable_data(), rowBytes, 0, 0, SkImage::kAllow_CachingHint);
12 auto ii = dstInfo.makeColorType(kRGBA_8888_SkColorType);
13 sk_sp<SkImage> raw = SkImages::RasterFromData(ii, data, rowBytes);
14 canvas->drawImage(image, 0, 0);
15 canvas->drawImage(raw.get(), 128, 0);
16}
17} // END FIDDLE
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
SK_API int SkColorTypeBytesPerPixel(SkColorType ct)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
static sk_sp< SkData > MakeUninitialized(size_t length)
Definition SkData.cpp:116
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
int width() const
Definition SkImage.h:285
int height() const
Definition SkImage.h:291
@ kAllow_CachingHint
allows internally caching decoded and copied pixels
Definition SkImage.h:464
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 > RasterFromData(const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes)
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
SkImageInfo makeColorType(SkColorType newColorType) const