Skia
2D Graphics Library
|
Describes pixel dimensions and encoding. More...
#include <SkImageInfo.h>
Public Member Functions | |
SkImageInfo ()=default | |
Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of zero, and no SkColorSpace. More... | |
int | width () const |
Returns pixel count in each row. More... | |
int | height () const |
Returns pixel row count. More... | |
SkColorType | colorType () const |
SkAlphaType | alphaType () const |
SkColorSpace * | colorSpace () const |
Returns SkColorSpace, the range of colors. More... | |
sk_sp< SkColorSpace > | refColorSpace () const |
Returns smart pointer to SkColorSpace, the range of colors. More... | |
bool | isEmpty () const |
Returns if SkImageInfo describes an empty area of pixels by checking if either width or height is zero or smaller. More... | |
const SkColorInfo & | colorInfo () const |
Returns the dimensionless SkColorInfo that represents the same color type, alpha type, and color space as this SkImageInfo. More... | |
bool | isOpaque () const |
Returns true if SkAlphaType is set to hint that all pixels are opaque; their alpha value is implicitly or explicitly 1.0. More... | |
SkISize | dimensions () const |
Returns SkISize { width(), height() }. More... | |
SkIRect | bounds () const |
Returns SkIRect { 0, 0, width(), height() }. More... | |
bool | gammaCloseToSRGB () const |
Returns true if associated SkColorSpace is not nullptr, and SkColorSpace gamma is approximately the same as sRGB. More... | |
SkImageInfo | makeWH (int newWidth, int newHeight) const |
Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType, with dimensions set to width and height. More... | |
SkImageInfo | makeDimensions (SkISize newSize) const |
Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType, with dimensions set to newDimensions. More... | |
SkImageInfo | makeAlphaType (SkAlphaType newAlphaType) const |
Creates SkImageInfo with same SkColorType, SkColorSpace, width, and height, with SkAlphaType set to newAlphaType. More... | |
SkImageInfo | makeColorType (SkColorType newColorType) const |
Creates SkImageInfo with same SkAlphaType, SkColorSpace, width, and height, with SkColorType set to newColorType. More... | |
SkImageInfo | makeColorSpace (sk_sp< SkColorSpace > cs) const |
Creates SkImageInfo with same SkAlphaType, SkColorType, width, and height, with SkColorSpace set to cs. More... | |
int | bytesPerPixel () const |
Returns number of bytes per pixel required by SkColorType. More... | |
int | shiftPerPixel () const |
Returns bit shift converting row bytes to row pixels. More... | |
uint64_t | minRowBytes64 () const |
Returns minimum bytes per row, computed from pixel width() and SkColorType, which specifies bytesPerPixel(). More... | |
size_t | minRowBytes () const |
Returns minimum bytes per row, computed from pixel width() and SkColorType, which specifies bytesPerPixel(). More... | |
size_t | computeOffset (int x, int y, size_t rowBytes) const |
Returns byte offset of pixel from pixel base address. More... | |
bool | operator== (const SkImageInfo &other) const |
Compares SkImageInfo with other, and returns true if width, height, SkColorType, SkAlphaType, and SkColorSpace are equivalent. More... | |
bool | operator!= (const SkImageInfo &other) const |
Compares SkImageInfo with other, and returns true if width, height, SkColorType, SkAlphaType, and SkColorSpace are not equivalent. More... | |
size_t | computeByteSize (size_t rowBytes) const |
Returns storage required by pixel array, given SkImageInfo dimensions, SkColorType, and rowBytes. More... | |
size_t | computeMinByteSize () const |
Returns storage required by pixel array, given SkImageInfo dimensions, and SkColorType. More... | |
bool | validRowBytes (size_t rowBytes) const |
Returns true if rowBytes is valid for this SkImageInfo. More... | |
void | reset () |
Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of zero, and no SkColorSpace. More... | |
SkImageInfo (SkISize dimensions, const SkColorInfo &colorInfo) | |
SkImageInfo (SkISize dimensions, SkColorInfo &&colorInfo) | |
Static Public Member Functions | |
static SkImageInfo | Make (int width, int height, SkColorType ct, SkAlphaType at) |
Creates SkImageInfo from integral dimensions width and height, SkColorType ct, SkAlphaType at, and optionally SkColorSpace cs. More... | |
static SkImageInfo | Make (int width, int height, SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs) |
static SkImageInfo | Make (SkISize dimensions, SkColorType ct, SkAlphaType at) |
static SkImageInfo | Make (SkISize dimensions, SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs) |
static SkImageInfo | Make (SkISize dimensions, const SkColorInfo &colorInfo) |
Creates SkImageInfo from integral dimensions and SkColorInfo colorInfo,. More... | |
static SkImageInfo | Make (SkISize dimensions, SkColorInfo &&colorInfo) |
static SkImageInfo | MakeN32 (int width, int height, SkAlphaType at) |
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, SkAlphaType at, and optionally SkColorSpace cs. More... | |
static SkImageInfo | MakeN32 (int width, int height, SkAlphaType at, sk_sp< SkColorSpace > cs) |
static SkImageInfo | MakeS32 (int width, int height, SkAlphaType at) |
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, SkAlphaType at, with sRGB SkColorSpace. More... | |
static SkImageInfo | MakeN32Premul (int width, int height) |
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType, with optional SkColorSpace. More... | |
static SkImageInfo | MakeN32Premul (int width, int height, sk_sp< SkColorSpace > cs) |
static SkImageInfo | MakeN32Premul (SkISize dimensions) |
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType, with SkColorSpace set to nullptr. More... | |
static SkImageInfo | MakeN32Premul (SkISize dimensions, sk_sp< SkColorSpace > cs) |
static SkImageInfo | MakeA8 (int width, int height) |
Creates SkImageInfo from integral dimensions width and height, kAlpha_8_SkColorType, kPremul_SkAlphaType, with SkColorSpace set to nullptr. More... | |
static SkImageInfo | MakeA8 (SkISize dimensions) |
Creates SkImageInfo from integral dimensions, kAlpha_8_SkColorType, kPremul_SkAlphaType, with SkColorSpace set to nullptr. More... | |
static SkImageInfo | MakeUnknown (int width, int height) |
Creates SkImageInfo from integral dimensions width and height, kUnknown_SkColorType, kUnknown_SkAlphaType, with SkColorSpace set to nullptr. More... | |
static SkImageInfo | MakeUnknown () |
Creates SkImageInfo from integral dimensions width and height set to zero, kUnknown_SkColorType, kUnknown_SkAlphaType, with SkColorSpace set to nullptr. More... | |
static bool | ByteSizeOverflowed (size_t byteSize) |
Returns true if byteSize equals SIZE_MAX. More... | |
Public Attributes | |
SkDEBUGCODE(void validate() const ;) private SkISize | fDimensions = {0, 0} |
Asserts if internal values are illegal or inconsistent. More... | |
Describes pixel dimensions and encoding.
SkBitmap, SkImage, PixMap, and SkSurface can be created from SkImageInfo. SkImageInfo can be retrieved from SkBitmap and SkPixmap, but not from SkImage and SkSurface. For example, SkImage and SkSurface implementations may defer pixel depth, so may not completely specify SkImageInfo.
SkImageInfo contains dimensions, the pixel integral width and height. It encodes how pixel bits describe alpha, transparency; color components red, blue, and green; and SkColorSpace, the range and linearity of colors.
|
default |
Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of zero, and no SkColorSpace.
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
Returns true if byteSize equals SIZE_MAX.
computeByteSize() and computeMinByteSize() return SIZE_MAX if size_t can not hold buffer size.
byteSize | result of computeByteSize() or computeMinByteSize() |
|
inline |
Returns number of bytes per pixel required by SkColorType.
Returns zero if colorType( is kUnknown_SkColorType.
|
inline |
Returns the dimensionless SkColorInfo that represents the same color type, alpha type, and color space as this SkImageInfo.
SkColorSpace* SkImageInfo::colorSpace | ( | ) | const |
Returns SkColorSpace, the range of colors.
The reference count of SkColorSpace is unchanged. The returned SkColorSpace is immutable.
|
inline |
size_t SkImageInfo::computeByteSize | ( | size_t | rowBytes | ) | const |
Returns storage required by pixel array, given SkImageInfo dimensions, SkColorType, and rowBytes.
rowBytes is assumed to be at least as large as minRowBytes().
Returns zero if height is zero. Returns SIZE_MAX if answer exceeds the range of size_t.
rowBytes | size of pixel row or larger |
|
inline |
Returns storage required by pixel array, given SkImageInfo dimensions, and SkColorType.
Uses minRowBytes() to compute bytes for pixel row.
Returns zero if height is zero. Returns SIZE_MAX if answer exceeds the range of size_t.
size_t SkImageInfo::computeOffset | ( | int | x, |
int | y, | ||
size_t | rowBytes | ||
) | const |
Returns byte offset of pixel from pixel base address.
Asserts in debug build if x or y is outside of bounds. Does not assert if rowBytes is smaller than minRowBytes(), even though result may be incorrect.
x | column index, zero or greater, and less than width() |
y | row index, zero or greater, and less than height() |
rowBytes | size of pixel row or larger |
|
inline |
|
inline |
Returns true if associated SkColorSpace is not nullptr, and SkColorSpace gamma is approximately the same as sRGB.
This includes the
|
inline |
Returns pixel row count.
|
inline |
Returns if SkImageInfo describes an empty area of pixels by checking if either width or height is zero or smaller.
|
inline |
Returns true if SkAlphaType is set to hint that all pixels are opaque; their alpha value is implicitly or explicitly 1.0.
If true, and all pixels are not opaque, Skia may draw incorrectly.
Does not check if SkColorType allows alpha, or if any pixel value has transparency.
|
static |
Creates SkImageInfo from integral dimensions width and height, SkColorType ct, SkAlphaType at, and optionally SkColorSpace cs.
If SkColorSpace cs is nullptr and SkImageInfo is part of drawing source: SkColorSpace defaults to sRGB, mapping into SkSurface SkColorSpace.
Parameters are not validated to see if their values are legal, or that the combination is supported.
width | pixel column count; must be zero or greater |
height | pixel row count; must be zero or greater |
cs | range of colors; may be nullptr |
|
static |
|
inlinestatic |
Creates SkImageInfo from integral dimensions and SkColorInfo colorInfo,.
Parameters are not validated to see if their values are legal, or that the combination is supported.
dimensions | pixel column and row count; must be zeros or greater |
SkColorInfo | the pixel encoding consisting of SkColorType, SkAlphaType, and SkColorSpace (which may be nullptr) |
|
inlinestatic |
|
static |
|
static |
|
static |
Creates SkImageInfo from integral dimensions width and height, kAlpha_8_SkColorType, kPremul_SkAlphaType, with SkColorSpace set to nullptr.
width | pixel column count; must be zero or greater |
height | pixel row count; must be zero or greater |
|
static |
Creates SkImageInfo from integral dimensions, kAlpha_8_SkColorType, kPremul_SkAlphaType, with SkColorSpace set to nullptr.
dimensions | pixel row and column count; must be zero or greater |
|
inline |
Creates SkImageInfo with same SkColorType, SkColorSpace, width, and height, with SkAlphaType set to newAlphaType.
Created SkImageInfo contains newAlphaType even if it is incompatible with SkColorType, in which case SkAlphaType in SkImageInfo is ignored.
SkImageInfo SkImageInfo::makeColorSpace | ( | sk_sp< SkColorSpace > | cs | ) | const |
Creates SkImageInfo with same SkAlphaType, SkColorType, width, and height, with SkColorSpace set to cs.
cs | range of colors; may be nullptr |
|
inline |
Creates SkImageInfo with same SkAlphaType, SkColorSpace, width, and height, with SkColorType set to newColorType.
|
inline |
Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType, with dimensions set to newDimensions.
newSize | pixel column and row count; must be zero or greater |
|
static |
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, SkAlphaType at, and optionally SkColorSpace cs.
kN32_SkColorType will equal either kBGRA_8888_SkColorType or kRGBA_8888_SkColorType, whichever is optimal.
If SkColorSpace cs is nullptr and SkImageInfo is part of drawing source: SkColorSpace defaults to sRGB, mapping into SkSurface SkColorSpace.
Parameters are not validated to see if their values are legal, or that the combination is supported.
width | pixel column count; must be zero or greater |
height | pixel row count; must be zero or greater |
cs | range of colors; may be nullptr |
|
static |
|
static |
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType, with optional SkColorSpace.
If SkColorSpace cs is nullptr and SkImageInfo is part of drawing source: SkColorSpace defaults to sRGB, mapping into SkSurface SkColorSpace.
Parameters are not validated to see if their values are legal, or that the combination is supported.
width | pixel column count; must be zero or greater |
height | pixel row count; must be zero or greater |
cs | range of colors; may be nullptr |
|
static |
|
static |
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType, with SkColorSpace set to nullptr.
If SkImageInfo is part of drawing source: SkColorSpace defaults to sRGB, mapping into SkSurface SkColorSpace.
Parameters are not validated to see if their values are legal, or that the combination is supported.
dimensions | width and height, each must be zero or greater |
cs | range of colors; may be nullptr |
|
static |
|
static |
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, SkAlphaType at, with sRGB SkColorSpace.
Parameters are not validated to see if their values are legal, or that the combination is supported.
width | pixel column count; must be zero or greater |
height | pixel row count; must be zero or greater |
|
inlinestatic |
Creates SkImageInfo from integral dimensions width and height set to zero, kUnknown_SkColorType, kUnknown_SkAlphaType, with SkColorSpace set to nullptr.
Returned SkImageInfo as part of source does not draw, and as part of destination can not be drawn to.
|
static |
Creates SkImageInfo from integral dimensions width and height, kUnknown_SkColorType, kUnknown_SkAlphaType, with SkColorSpace set to nullptr.
Returned SkImageInfo as part of source does not draw, and as part of destination can not be drawn to.
width | pixel column count; must be zero or greater |
height | pixel row count; must be zero or greater |
|
inline |
Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType, with dimensions set to width and height.
newWidth | pixel column count; must be zero or greater |
newHeight | pixel row count; must be zero or greater |
|
inline |
Returns minimum bytes per row, computed from pixel width() and SkColorType, which specifies bytesPerPixel().
SkBitmap maximum value for row bytes must fit in 31 bits.
|
inline |
Returns minimum bytes per row, computed from pixel width() and SkColorType, which specifies bytesPerPixel().
SkBitmap maximum value for row bytes must fit in 31 bits.
|
inline |
Compares SkImageInfo with other, and returns true if width, height, SkColorType, SkAlphaType, and SkColorSpace are not equivalent.
other | SkImageInfo to compare |
|
inline |
Compares SkImageInfo with other, and returns true if width, height, SkColorType, SkAlphaType, and SkColorSpace are equivalent.
other | SkImageInfo to compare |
sk_sp<SkColorSpace> SkImageInfo::refColorSpace | ( | ) | const |
Returns smart pointer to SkColorSpace, the range of colors.
The smart pointer tracks the number of objects sharing this SkColorSpace reference so the memory is released when the owners destruct.
The returned SkColorSpace is immutable.
|
inline |
Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of zero, and no SkColorSpace.
|
inline |
Returns bit shift converting row bytes to row pixels.
Returns zero for kUnknown_SkColorType.
|
inline |
Returns true if rowBytes is valid for this SkImageInfo.
rowBytes | size of pixel row including padding |
|
inline |
Returns pixel count in each row.
SkDEBUGCODE (void validate() const;) private SkISize SkImageInfo::fDimensions = {0, 0} |
Asserts if internal values are illegal or inconsistent.
Only available if SK_DEBUG is defined at compile time.