class SkPixmap { SkPixmap(); SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes); void reset(); void reset(const SkImageInfo& info, const void* addr, size_t rowBytes); void setColorSpace(sk_sp<SkColorSpace> colorSpace); bool extractSubset(SkPixmap* subset, const SkIRect& area) const; const SkImageInfo& info() const; size_t rowBytes() const; const void* addr() const; int width() const; int height() const; SkColorType colorType() const; SkAlphaType alphaType() const; SkColorSpace* colorSpace() const; bool isOpaque() const; SkIRect bounds() const; int rowBytesAsPixels() const; int shiftPerPixel() const; size_t computeByteSize() const; bool computeIsOpaque() const; SkColor getColor(int x, int y) const; float getAlphaf(int x, int y) const; const void* addr(int x, int y) const; const uint8_t* addr8() const; const uint16_t* addr16() const; const uint32_t* addr32() const; const uint64_t* addr64() const; const uint16_t* addrF16() const; const uint8_t* addr8(int x, int y) const; const uint16_t* addr16(int x, int y) const; const uint32_t* addr32(int x, int y) const; const uint64_t* addr64(int x, int y) const; const uint16_t* addrF16(int x, int y) const; void* writable_addr() const; void* writable_addr(int x, int y) const; uint8_t* writable_addr8(int x, int y) const; uint16_t* writable_addr16(int x, int y) const; uint32_t* writable_addr32(int x, int y) const; uint64_t* writable_addr64(int x, int y) const; uint16_t* writable_addrF16(int x, int y) const; bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes) const; bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY) const; bool readPixels(const SkPixmap& dst, int srcX, int srcY) const; bool readPixels(const SkPixmap& dst) const; bool scalePixels(const SkPixmap& dst, SkFilterQuality filterQuality) const; bool erase(SkColor color, const SkIRect& subset) const; bool erase(SkColor color) const; bool erase(const SkColor4f& color, const SkIRect* subset = nullptr) const; };
Pixmap provides a utility to pair SkImageInfo with pixels and row bytes. Pixmap is a low level class which provides convenience functions to access raster destinations. Canvas can not draw Pixmap, nor does Pixmap provide a direct drawing destination.
Use Bitmap to draw pixels referenced by Pixmap; use Surface to draw into pixels referenced by Pixmap.
Pixmap does not try to manage the lifetime of the pixel memory. Use Pixel_Ref to manage pixel memory; Pixel_Ref is safe across threads.
SkPixmap()
Creates an empty SkPixmap without pixels, with kUnknown_SkColorType, with kUnknown_SkAlphaType, and with a width and height of zero. Use reset() to associate pixels, SkColorType, SkAlphaType, width, and height after SkPixmap has been created.
empty SkPixmap
SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes) reset() SkAlphaType SkColorType
SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes)
Creates SkPixmap from info width, height, SkAlphaType, and SkColorType. addr points to pixels, or nullptr. rowBytes should be info.width() times info.bytesPerPixel(), or larger.
No parameter checking is performed; it is up to the caller to ensure that addr and rowBytes agree with info.
The memory lifetime of pixels is managed by the caller. When SkPixmap goes out of scope, addr is unaffected.
SkPixmap may be later modified by reset() to change its size, pixel type, or storage.
info |
width, height, SkAlphaType, SkColorType of SkImageInfo |
addr |
pointer to pixels allocated by caller; may be nullptr |
rowBytes |
size of one row of addr; width times pixel size, or larger |
initialized SkPixmap
image alpha only = false
copy alpha only = true
SkPixmap() reset() SkAlphaType SkColorType
void reset()
Sets width, height, row bytes to zero; pixel address to nullptr; SkColorType to kUnknown_SkColorType; and SkAlphaType to kUnknown_SkAlphaType.
The prior pixels are unaffected; it is up to the caller to release pixels memory if desired.
SkPixmap() SkAlphaType SkColorType
void reset(const SkImageInfo& info, const void* addr, size_t rowBytes)
Sets width, height, SkAlphaType, and SkColorType from info. Sets pixel address from addr, which may be nullptr. Sets row bytes from rowBytes, which should be info.width() times info.bytesPerPixel(), or larger.
Does not check addr. Asserts if built with SK_DEBUG defined and if rowBytes is too small to hold one row of pixels.
The memory lifetime pixels are managed by the caller. When SkPixmap goes out of scope, addr is unaffected.
info |
width, height, SkAlphaType, SkColorType of SkImageInfo |
addr |
pointer to pixels allocated by caller; may be nullptr |
rowBytes |
size of one row of addr; width times pixel size, or larger |
SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes) reset() SkAlphaType SkColorType
void setColorSpace(sk_sp<SkColorSpace> colorSpace)
Changes SkColorSpace in SkImageInfo; preserves width, height, SkAlphaType, and SkColorType in SkImage, and leaves pixel address and row bytes unchanged. SkColorSpace reference count is incremented.
colorSpace |
SkColorSpace moved to SkImageInfo |
Color_Space SkImageInfo::makeColorSpace
bool extractSubset(SkPixmap* subset, const SkIRect& area)const
Sets subset width, height, pixel address to intersection of SkPixmap with area, if intersection is not empty; and return true. Otherwise, leave subset unchanged and return false.
Failing to read the return value generates a compile time warning.
subset |
storage for width, height, pixel address of intersection |
area |
bounds to intersect with SkPixmap |
true if intersection of SkPixmap and area is not empty
const SkImageInfo& info()const
Returns width, height, SkAlphaType, SkColorType, and SkColorSpace.
reference to SkImageInfo
size_t rowBytes()const
Returns row bytes, the interval from one pixel row to the next. Row bytes
is at least as large as: width() * info().bytesPerPixel()
.
Returns zero if colorType is kUnknown_SkColorType. It is up to the Bitmap creator to ensure that row bytes is a useful value.
byte length of pixel row
addr() info() SkImageInfo::minRowBytes
const void* addr()const
Returns pixel address, the base address corresponding to the pixel origin.
It is up to the SkPixmap creator to ensure that pixel address is a useful value.
pixel address
addr(int x, int y) addr8 addr16 addr32 addr64 info() rowBytes()
int width()const
Returns pixel count in each pixel row. Should be equal or less than:
rowBytes() / info().bytesPerPixel()
.
pixel width in Image_Info
int height()const
Returns pixel row count.
pixel height in SkImageInfo
SkColorType colorType()const
Returns Color_Type, one of: kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType, kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType, kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType, kGray_8_SkColorType, kRGBA_F16_SkColorType .
alphaType() SkImageInfo::colorType
SkAlphaType alphaType()const
Returns Alpha_Type, one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType, kUnpremul_SkAlphaType .
colorType() SkImageInfo::alphaType
SkColorSpace* colorSpace()const
Returns SkColorSpace, the range of colors, associated with SkImageInfo. The reference count of SkColorSpace is unchanged. The returned SkColorSpace is immutable.
SkColorSpace in SkImageInfo, or nullptr
gammaCloseToSRGB: false gammaIsLinear: true isSRGB: false
Color_Space SkImageInfo::colorSpace
bool isOpaque()const
Returns true if SkAlphaType is kOpaque_SkAlphaType. Does not check if SkColorType allows alpha, or if any pixel value has transparency.
true if SkImageInfo has opaque SkAlphaType
isOpaque: false
isOpaque: false
isOpaque: true
isOpaque: true
computeIsOpaque SkImageInfo::isOpaque
SkIRect bounds()const
Returns SkIRect { 0, 0, width(), height() }.
integral rectangle from origin to width() and height()
int rowBytesAsPixels()const
Returns number of pixels that fit on row. Should be greater than or equal to width().
maximum pixels per row
rowBytes shiftPerPixel width SkImageInfo::bytesPerPixel
int shiftPerPixel()const
Returns bit shift converting row bytes to row pixels. Returns zero for kUnknown_SkColorType.
one of: 0, 1, 2, 3; left shift to convert pixels to bytes
rowBytes rowBytesAsPixels width SkImageInfo::bytesPerPixel
size_t computeByteSize()const
Returns minimum memory required for pixel storage. Does not include unused memory on last row when rowBytesAsPixels() exceeds width(). Returns zero if result does not fit in size_t. Returns zero if height() or width() is 0. Returns height() times rowBytes() if colorType() is kUnknown_SkColorType.
bool computeIsOpaque()const
Returns true if all pixels are opaque. SkColorType determines how pixels are encoded, and whether pixel describes alpha. Returns true for SkColorType without alpha in each pixel; for other SkColorType, returns true if all pixels have alpha values equivalent to 1.0 or greater.
For SkColorType kRGB_565_SkColorType or kGray_8_SkColorType: always returns true. For SkColorType kAlpha_8_SkColorType, kBGRA_8888_SkColorType, kRGBA_8888_SkColorType: returns true if all pixel alpha values are 255. For SkColorType kARGB_4444_SkColorType: returns true if all pixel alpha values are 15. For kRGBA_F16_SkColorType: returns true if all pixel alpha values are 1.0 or greater.
Returns false for kUnknown_SkColorType.
true if all pixels have opaque values or SkColorType is opaque
SkColor getColor(int x, int y)const
Returns pixel at (x, y) as unpremultiplied color. Returns black with alpha if SkColorType is kAlpha_8_SkColorType.
Input is not validated: out of bounds values of x or y trigger an assert() if built with SK_DEBUG defined; and returns undefined values or may crash if SK_RELEASE is defined. Fails if SkColorType is kUnknown_SkColorType or pixel address is nullptr.
SkColorSpace in SkImageInfo is ignored. Some color precision may be lost in the conversion to unpremultiplied color; original pixel data may have additional precision.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
pixel converted to unpremultiplied color
float getAlphaf(int x, int y)const
Looks up the pixel at (x,y) and return its alpha component, normalized to [0..1].
This is roughly equivalent to SkGetColorA(getColor())
, but can be more efficient
(and more precise if the pixels store more than 8 bits per component).
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
alpha converted to normalized float
const void* addr(int x, int y)const
Returns readable pixel address at (x, y). Returns nullptr if SkPixelRef is nullptr.
Input is not validated: out of bounds values of x or y trigger an assert() if built with SK_DEBUG defined. Returns nullptr if SkColorType is kUnknown_SkColorType.
Performs a lookup of pixel size; for better performance, call one of: addr8, addr16, addr32, addr64, or addrF16().
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
readable generic pointer to pixel
addr8 addr16 addr32 addr64 addrF16 getColor writable_addr SkBitmap::getAddr
const uint8_t* addr8()const
Returns readable base pixel address. Result is addressable as unsigned 8-bit bytes. Will trigger an assert() if SkColorType is not kAlpha_8_SkColorType or kGray_8_SkColorType, and is built with SK_DEBUG defined.
One byte corresponds to one pixel.
readable unsigned 8-bit pointer to pixels
addr() addr16 addr32 addr64 addrF16 getColor writable_addr writable_addr8
const uint16_t* addr16()const
Returns readable base pixel address. Result is addressable as unsigned 16-bit words. Will trigger an assert() if SkColorType is not kRGB_565_SkColorType or kARGB_4444_SkColorType, and is built with SK_DEBUG defined.
One word corresponds to one pixel.
readable unsigned 16-bit pointer to pixels
addr() addr8 addr32 addr64 addrF16 getColor writable_addr writable_addr16
const uint32_t* addr32()const
Returns readable base pixel address. Result is addressable as unsigned 32-bit words. Will trigger an assert() if SkColorType is not kRGBA_8888_SkColorType or kBGRA_8888_SkColorType, and is built with SK_DEBUG defined.
One word corresponds to one pixel.
readable unsigned 32-bit pointer to pixels
addr() addr8 addr16 addr64 addrF16 getColor writable_addr writable_addr32
const uint64_t* addr64()const
Returns readable base pixel address. Result is addressable as unsigned 64-bit words. Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built with SK_DEBUG defined.
One word corresponds to one pixel.
readable unsigned 64-bit pointer to pixels
addr() addr8 addr16 addr32 addrF16 getColor writable_addr writable_addr64
const uint16_t* addrF16()const
Returns readable base pixel address. Result is addressable as unsigned 16-bit words. Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built with SK_DEBUG defined.
Each word represents one color component encoded as a half float. Four words correspond to one pixel.
readable unsigned 16-bit pointer to first component of pixels
addr() addr8 addr16 addr32 addr64 getColor writable_addr writable_addrF16
const uint8_t* addr8(int x, int y)const
Returns readable pixel address at (x, y).
Input is not validated: out of bounds values of x or y trigger an assert() if built with SK_DEBUG defined.
Will trigger an assert() if SkColorType is not kAlpha_8_SkColorType or kGray_8_SkColorType, and is built with SK_DEBUG defined.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
readable unsigned 8-bit pointer to pixel at (x, y)
addr() addr16 addr32 addr64 addrF16 getColor writable_addr writable_addr8
const uint16_t* addr16(int x, int y)const
Returns readable pixel address at (x, y).
Input is not validated: out of bounds values of x or y trigger an assert() if built with SK_DEBUG defined.
Will trigger an assert() if SkColorType is not kRGB_565_SkColorType or kARGB_4444_SkColorType, and is built with SK_DEBUG defined.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
readable unsigned 16-bit pointer to pixel at (x, y)
addr() addr8 addr32 addr64 addrF16 getColor writable_addr writable_addr16
const uint32_t* addr32(int x, int y)const
Returns readable pixel address at (x, y).
Input is not validated: out of bounds values of x or y trigger an assert() if built with SK_DEBUG defined.
Will trigger an assert() if SkColorType is not kRGBA_8888_SkColorType or kBGRA_8888_SkColorType, and is built with SK_DEBUG defined.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
readable unsigned 32-bit pointer to pixel at (x, y)
addr() addr8 addr16 addr64 addrF16 getColor writable_addr writable_addr64
const uint64_t* addr64(int x, int y)const
Returns readable pixel address at (x, y).
Input is not validated: out of bounds values of x or y trigger an assert() if built with SK_DEBUG defined.
Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built with SK_DEBUG defined.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
readable unsigned 64-bit pointer to pixel at (x, y)
addr() addr8 addr16 addr32 addrF16 getColor writable_addr writable_addr64
const uint16_t* addrF16(int x, int y)const
Returns readable pixel address at (x, y).
Input is not validated: out of bounds values of x or y trigger an assert() if built with SK_DEBUG defined.
Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built with SK_DEBUG defined.
Each unsigned 16-bit word represents one color component encoded as a half float. Four words correspond to one pixel.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
readable unsigned 16-bit pointer to pixel component at (x, y)
addr() addr8 addr16 addr32 addr64 getColor writable_addr writable_addrF16
void* writable_addr()const
Returns writable base pixel address.
writable generic base pointer to pixels
writable_addr8 writable_addr16 writable_addr32 writable_addr64 writable_addrF16 addr()
void* writable_addr(int x, int y)const
Returns writable pixel address at (x, y).
Input is not validated: out of bounds values of x or y trigger an assert() if built with SK_DEBUG defined. Returns zero if SkColorType is kUnknown_SkColorType.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
writable generic pointer to pixel
writable_addr8 writable_addr16 writable_addr32 writable_addr64 writable_addrF16 addr()
uint8_t* writable_addr8(int x, int y)const
Returns writable pixel address at (x, y). Result is addressable as unsigned 8-bit bytes. Will trigger an assert() if SkColorType is not kAlpha_8_SkColorType or kGray_8_SkColorType, and is built with SK_DEBUG defined.
One byte corresponds to one pixel.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
writable unsigned 8-bit pointer to pixels
writable_addr writable_addr16 writable_addr32 writable_addr64 writable_addrF16 addr() addr8
uint16_t* writable_addr16(int x, int y)const
Returns writable_addr pixel address at (x, y). Result is addressable as unsigned 16-bit words. Will trigger an assert() if SkColorType is not kRGB_565_SkColorType or kARGB_4444_SkColorType, and is built with SK_DEBUG defined.
One word corresponds to one pixel.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
writable unsigned 16-bit pointer to pixel
writable_addr writable_addr8 writable_addr32 writable_addr64 writable_addrF16 addr() addr16
uint32_t* writable_addr32(int x, int y)const
Returns writable pixel address at (x, y). Result is addressable as unsigned 32-bit words. Will trigger an assert() if SkColorType is not kRGBA_8888_SkColorType or kBGRA_8888_SkColorType, and is built with SK_DEBUG defined.
One word corresponds to one pixel.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
writable unsigned 32-bit pointer to pixel
writable_addr writable_addr8 writable_addr16 writable_addr64 writable_addrF16 addr() addr32
uint64_t* writable_addr64(int x, int y)const
Returns writable pixel address at (x, y). Result is addressable as unsigned 64-bit words. Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built with SK_DEBUG defined.
One word corresponds to one pixel.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
writable unsigned 64-bit pointer to pixel
writable_addr writable_addr8 writable_addr16 writable_addr32 writable_addrF16 addr() addr64
uint16_t* writable_addrF16(int x, int y)const
Returns writable pixel address at (x, y). Result is addressable as unsigned 16-bit words. Will trigger an assert() if SkColorType is not kRGBA_F16_SkColorType and is built with SK_DEBUG defined.
Each word represents one color component encoded as a half float. Four words correspond to one pixel.
x |
column index, zero or greater, and less than width() |
y |
row index, zero or greater, and less than height() |
writable unsigned 16-bit pointer to first component of pixel
writable_addr writable_addr8 writable_addr16 writable_addr32 writable_addr64 addr() addrF16
bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes)const
Copies a SkRect of pixels to dstPixels. Copy starts at (0, 0), and does not exceed SkPixmap (width(), height()).
dstInfo specifies width, height, SkColorType, SkAlphaType, and SkColorSpace of destination. dstRowBytes specifics the gap from one destination row to the next. Returns true if pixels are copied. Returns false if dstInfo address equals nullptr, or dstRowBytes is less than dstInfo.minRowBytes().
Pixels are copied only if pixel conversion is possible. If SkPixmap colorType() is kGray_8_SkColorType, or kAlpha_8_SkColorType; dstInfo.colorType() must match. If SkPixmap colorType() is kGray_8_SkColorType, dstInfo.colorSpace() must match. If SkPixmap alphaType() is kOpaque_SkAlphaType, dstInfo.alphaType() must match. If SkPixmap colorSpace() is nullptr, dstInfo.colorSpace() must match. Returns false if pixel conversion is not possible.
Returns false if SkPixmap width() or height() is zero or negative.
dstInfo |
destination width, height, SkColorType, SkAlphaType, SkColorSpace |
dstPixels |
destination pixel storage |
dstRowBytes |
destination row length |
true if pixels are copied to dstPixels
erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels
bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY)const
Copies a Rect of pixels to dstPixels. Copy starts at (srcX, srcY), and does not exceed Pixmap (width(), height()).
dstInfo specifies width, height, Color_Type, Alpha_Type, and Color_Space of destination. dstRowBytes specifics the gap from one destination row to the next. Returns true if pixels are copied. Returns false if dstInfo has no address, or dstRowBytes is less than dstInfo.minRowBytes().
Pixels are copied only if pixel conversion is possible. If Pixmap colorType is kGray_8_SkColorType, or kAlpha_8_SkColorType; dstInfo.colorType() must match. If Pixmap colorType is kGray_8_SkColorType, dstInfo.colorSpace() must match. If Pixmap alphaType is kOpaque_SkAlphaType, dstInfo.alphaType() must match. If Pixmap colorSpace is nullptr, dstInfo.colorSpace() must match. Returns false if pixel conversion is not possible.
srcX and srcY may be negative to copy only top or left of source. Returns false if Pixmap width() or height() is zero or negative. Returns false if:
abs(srcX) >= Pixmap width()
, or if abs(srcY) >= Pixmap height()
.
dstInfo |
destination width, height, Color_Type, Alpha_Type, Color_Space |
dstPixels |
destination pixel storage |
dstRowBytes |
destination row length |
srcX |
column index whose absolute value is less than width() |
srcY |
row index whose absolute value is less than height() |
true if pixels are copied to dstPixels
erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels
bool readPixels(const SkPixmap& dst, int srcX, int srcY)const
Copies a Rect of pixels to dst. Copy starts at (srcX, srcY), and does not exceed Pixmap (width(), height()). dst specifies width, height, Color_Type, Alpha_Type, and Color_Space of destination. Returns true if pixels are copied. Returns false if dst.addr() equals nullptr, or dst.rowBytes() is less than dst SkImageInfo::minRowBytes.
Pixels are copied only if pixel conversion is possible. If Pixmap colorType is kGray_8_SkColorType, or kAlpha_8_SkColorType; dst.info().colorType() must match. If Pixmap colorType is kGray_8_SkColorType, dst.info().colorSpace() must match. If Pixmap alphaType is kOpaque_SkAlphaType, dst.info().alphaType() must match. If Pixmap colorSpace is nullptr, dst.info().colorSpace() must match. Returns false if pixel conversion is not possible.
srcX and srcY may be negative to copy only top or left of source. Returns false Pixmap width() or height() is zero or negative. Returns false if:
abs(srcX) >= Pixmap width()
, or if abs(srcY) >= Pixmap height()
.
dst |
Image_Info and pixel address to write to |
srcX |
column index whose absolute value is less than width() |
srcY |
row index whose absolute value is less than height() |
true if pixels are copied to dst
erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels
bool readPixels(const SkPixmap& dst)const
Copies pixels inside bounds() to dst. dst specifies width, height, SkColorType, SkAlphaType, and SkColorSpace of destination. Returns true if pixels are copied. Returns false if dst address equals nullptr, or dst.rowBytes() is less than dst SkImageInfo::minRowBytes.
Pixels are copied only if pixel conversion is possible. If SkPixmap colorType() is kGray_8_SkColorType, or kAlpha_8_SkColorType; dst SkColorType must match. If SkPixmap colorType() is kGray_8_SkColorType, dst SkColorSpace must match. If SkPixmap alphaType() is kOpaque_SkAlphaType, dst SkAlphaType must match. If SkPixmap colorSpace() is nullptr, dst SkColorSpace must match. Returns false if pixel conversion is not possible.
Returns false if SkPixmap width() or height() is zero or negative.
dst |
SkImageInfo and pixel address to write to |
true if pixels are copied to dst
erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels
bool scalePixels(const SkPixmap& dst, SkFilterQuality filterQuality)const
Copies SkBitmap to dst, scaling pixels to fit dst.width() and dst.height(), and converting pixels to match dst.colorType() and dst.alphaType(). Returns true if pixels are copied. Returns false if dst address is nullptr, or dst.rowBytes() is less than dst SkImageInfo::minRowBytes.
Pixels are copied only if pixel conversion is possible. If SkPixmap colorType() is kGray_8_SkColorType, or kAlpha_8_SkColorType; dst SkColorType must match. If SkPixmap colorType() is kGray_8_SkColorType, dst SkColorSpace must match. If SkPixmap alphaType() is kOpaque_SkAlphaType, dst SkAlphaType must match. If SkPixmap colorSpace() is nullptr, dst SkColorSpace must match. Returns false if pixel conversion is not possible.
Returns false if SkBitmap width() or height() is zero or negative.
Scales the image, with filterQuality, to match dst.width() and dst.height(). filterQuality kNone_SkFilterQuality is fastest, typically implemented with nearest neighbor filter. kLow_SkFilterQuality is typically implemented with bilerp filter. kMedium_SkFilterQuality is typically implemented with bilerp filter, and mip-map filter when size is reduced. kHigh_SkFilterQuality is slowest, typically implemented with bicubic filter.
dst |
SkImageInfo and pixel address to write to |
filterQuality |
one of: kNone_SkFilterQuality, kLow_SkFilterQuality, |
kMedium_SkFilterQuality, kHigh_SkFilterQuality
true if pixels are scaled to fit dst
SkCanvas::drawBitmap SkImage::scalePixels
bool erase(SkColor color, const SkIRect& subset)const
Writes color to pixels bounded by subset; returns true on success. Returns false if colorType() is kUnknown_SkColorType, or if subset does not intersect bounds().
color |
unpremultiplied color to write |
subset |
bounding integer SkRect of written pixels |
true if pixels are changed
SkBitmap::erase SkCanvas::clear SkCanvas::drawColor
bool erase(SkColor color)const
Writes color to pixels inside bounds(); returns true on success. Returns false if colorType() is kUnknown_SkColorType, or if bounds() is empty.
color |
unpremultiplied color to write |
true if pixels are changed
SkBitmap::erase SkCanvas::clear SkCanvas::drawColor
bool erase(const SkColor4f& color, const SkIRect* subset = nullptr)const
Writes color to pixels bounded by subset; returns true on success. if subset is nullptr, writes colors pixels inside bounds(). Returns false if colorType() is kUnknown_SkColorType, if subset is not nullptr and does not intersect bounds(), or if subset is nullptr and bounds() is empty.
color |
unpremultiplied color to write |
subset |
bounding integer SkRect of pixels to write; may be nullptr |
true if pixels are changed