Image Info specifies the dimensions and encoding of the pixels in a Bitmap. The dimensions are integral width and height. The encoding is how pixel bits describe Color Alpha, transparency; Color components red, blue, and green; and Color Space, the range and linearity of colors.
Image Info describes an uncompressed raster pixels. In contrast, Image additionally describes compressed pixels like PNG, and Surface describes destinations on the GPU. Image and Surface may be specified by Image Info, but Image and Surface may not contain Image Info.
SkImageInfo related constants are defined by enum, enum class, #define, const, and constexpr.
Describes how to interpret the alpha component of a pixel. A pixel may be opaque, or Color Alpha, describing multiple levels of transparency.
In simple blending, Color Alpha weights the draw color and the destination color to create a new color. If alpha describes a weight from zero to one:
In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.
RGB may have Color Alpha included in each component value; the stored value is the original RGB multiplied by Color Alpha. Premultiplied color components improve performance.
SkColorType SkColorSpace
Use kOpaque_SkAlphaType as a hint to optimize drawing when Alpha component of all pixel is set to its maximum value of 1.0; all alpha component bits are set. If Image Info is set to kOpaque_SkAlphaType but all alpha values are not 1.0, results are undefined.
Use kPremul_SkAlphaType when stored color components are the original color multiplied by the alpha component. The alpha component range of 0.0 to 1.0 is achieved by dividing the integer bit value by the maximum bit value.
The color component must be equal to or smaller than the alpha component, or the results are undefined.
Use kUnpremul_SkAlphaType if stored color components are not divided by the alpha component. Some drawing destinations may not support kUnpremul_SkAlphaType.
Returns true if Alpha Type equals kOpaque_SkAlphaType. kOpaque_SkAlphaType is a hint that the Color Type is opaque, or that all Color Alpha values are set to their 1.0 equivalent. If Alpha Type is kOpaque_SkAlphaType, and Color Type is not opaque, then the result of drawing any pixel with a Color Alpha value less than 1.0 is undefined.
true if at equals kOpaque_SkAlphaType
Describes how pixel bits encode color. A pixel may be an alpha mask, a Grayscale, RGB, or ARGB.
kN32_SkColorType selects the native 32-bit ARGB format. On Little Endian processors, pixels containing 8-bit ARGB components pack into 32-bit kBGRA_8888_SkColorType. On Big Endian processors, pixels pack into 32-bit kRGBA_8888_SkColorType.
SkAlphaType SkColorSpace
Alpha pixels encode transparency without color information. Value of zero is completely transparent; a value of 255 is completely opaque. Bitmap pixels do not visibly draw, because its pixels have no color information. When SkColorType is set to kAlpha_8_SkColorType, the paired SkAlphaType is ignored.
Alpha Gray 8
kRGB_565_SkColorType encodes RGB to fit in a 16-bit word. Red and blue components use five bits describing 32 levels. Green components, more sensitive to the eye, use six bits describing 64 levels. kRGB_565_SkColorType has no bits for Alpha. Pixels are fully opaque as if its Color Alpha was set to one, and should always be paired with kOpaque_SkAlphaType.
ARGB 4444 RGBA 8888
kARGB_4444_SkColorType encodes ARGB to fit in 16-bit word. Each component: alpha, blue, green, and red; use four bits, describing 16 levels. Note that kARGB_4444_SkColorType is misnamed; the acronym does not describe the actual component order.
If paired with kPremul_SkAlphaType: blue, green, and red components are Premultiplied by the alpha value. If blue, green, or red is greater than alpha, the drawn result is undefined.
If paired with kUnpremul_SkAlphaType: alpha, blue, green, and red components may have any value. There may be a performance penalty with Unpremultipled pixels.
If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; blue, green, and red components are fully opaque. If any alpha component is less than 15, the drawn result is undefined.
RGBA 8888
kRGBA_8888_SkColorType encodes ARGB into a 32-bit word. Each component: red, green, blue, alpha; use eight bits, describing 256 levels.
If paired with kPremul_SkAlphaType: red, green, and blue components are Premultiplied by the alpha value. If red, green, or blue is greater than alpha, the drawn result is undefined.
If paired with kUnpremul_SkAlphaType: alpha, red, green, and blue components may have any value. There may be a performance penalty with Unpremultipled pixels.
If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; red, green, and blue components are fully opaque. If any alpha component is less than 255, the drawn result is undefined.
On Big Endian platforms, kRGBA_8888_SkColorType is the native Color Type, and will have the best performance. Use kN32_SkColorType to choose the best Color Type for the platform at compile time.
RGB 888 BGRA 8888
kRGB_888x_SkColorType encodes RGB into a 32-bit word. Each component: red, green, blue; use eight bits, describing 256 levels. Eight bits are unused. Pixels described by kRGB_888x_SkColorType are fully opaque as if their Color Alpha was set to one, and should always be paired with kOpaque_SkAlphaType.
RGBA 8888 BGRA 8888
kBGRA_8888_SkColorType encodes ARGB into a 32-bit word. Each component: blue, green, red, and alpha; use eight bits, describing 256 levels.
If paired with kPremul_SkAlphaType: blue, green, and red components are Premultiplied by the alpha value. If blue, green, or red is greater than alpha, the drawn result is undefined.
If paired with kUnpremul_SkAlphaType: blue, green, red, and alpha components may have any value. There may be a performance penalty with Unpremultiplied pixels.
If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; blue, green, and red components are fully opaque. If any alpha component is less than 255, the drawn result is undefined.
On Little Endian platforms, kBGRA_8888_SkColorType is the native Color Type, and will have the best performance. Use kN32_SkColorType to choose the best Color Type for the platform at compile time.
RGBA 8888
kRGBA_1010102_SkColorType encodes ARGB into a 32-bit word. Each Color component: red, green, and blue; use ten bits, describing 1024 levels. Two bits contain alpha, describing four levels. Possible alpha values are zero: fully transparent; one: 33% opaque; two: 67% opaque; three: fully opaque.
At present, Color in Paint does not provide enough precision to draw all colors possible to a kRGBA_1010102_SkColorType Surface.
If paired with kPremul_SkAlphaType: red, green, and blue components are Premultiplied by the alpha value. If red, green, or blue is greater than the alpha replicated to ten bits, the drawn result is undefined.
If paired with kUnpremul_SkAlphaType: alpha, red, green, and blue components may have any value. There may be a performance penalty with Unpremultiplied pixels.
If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; red, green, and blue components are fully opaque. If any alpha component is less than three, the drawn result is undefined.
RGB 101010 RGBA 8888
kRGB_101010x_SkColorType encodes RGB into a 32-bit word. Each Color component: red, green, and blue; use ten bits, describing 1024 levels. Two bits are unused. Pixels described by kRGB_101010x_SkColorType are fully opaque as if its Color Alpha was set to one, and should always be paired with kOpaque_SkAlphaType.
At present, Color in Paint does not provide enough precision to draw all colors possible to a kRGB_101010x_SkColorType Surface.
RGBA 1010102
kGray_8_SkColorType encodes Grayscale level in eight bits that is equivalent to equal values for red, blue, and green, representing colors from black to white. Pixels described by kGray_8_SkColorType are fully opaque as if its Color Alpha was set to one, and should always be paired with kOpaque_SkAlphaType.
Alpha 8
kRGBA_F16_SkColorType encodes ARGB into a 64-bit word. Each component: blue, green, red, and alpha; use 16 bits, describing a floating point value, from -65500 to 65000 with 3.31 decimal digits of precision.
At present, Color in Paint does not provide enough precision or range to draw all colors possible to a kRGBA_F16_SkColorType Surface.
Each component encodes a floating point value using Half floats . Meaningful colors are represented by the range 0.0 to 1.0, although smaller and larger values may be useful when used in combination with Transfer Mode.
If paired with kPremul_SkAlphaType: blue, green, and red components are Premultiplied by the alpha value. If blue, green, or red is greater than alpha, the drawn result is undefined.
If paired with kUnpremul_SkAlphaType: blue, green, red, and alpha components may have any value. There may be a performance penalty with Unpremultiplied pixels.
If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; blue, green, and red components are fully opaque. If any alpha component is less than one, the drawn result is undefined.
SkColor4f
kRGBA_F32_SkColorType encodes ARGB into a 128-bit word. Each component: blue, green, red, and alpha; use 32 bits, describing a floating point value, from -3.402823e+38 to 3.402823e+38 with 7.225 decimal digits of precision.
At present, Color in Paint does not provide enough precision or range to draw all colors possible to a kRGBA_F32_SkColorType Surface.
Each component encodes a floating point value using single-precision floats . Meaningful colors are represented by the range 0.0 to 1.0, although smaller and larger values may be useful when used in combination with Transfer Mode.
If paired with kPremul_SkAlphaType: blue, green, and red components are Premultiplied by the alpha value. If blue, green, or red is greater than alpha, the drawn result is undefined.
If paired with kUnpremul_SkAlphaType: blue, green, red, and alpha components may have any value. There may be a performance penalty with Unpremultiplied pixels.
If paired with kOpaque_SkAlphaType: all alpha component values are at the maximum; blue, green, and red components are fully opaque. If any alpha component is less than one, the drawn result is undefined.
SkColor4f
Returns the number of bytes required to store a pixel, including unused padding. Returns zero if ct is kUnknown_SkColorType or invalid.
bytes per pixel
SkImageInfo::bytesPerPixel
Returns true if Color Type always decodes Color Alpha to 1.0, making the pixel fully opaque. If true, Color Type does not reserve bits to encode Color Alpha.
true if Color Alpha is always set to 1.0
SkColorTypeValidateAlphaType
Returns true if canonical can be set to a valid Alpha Type for colorType. If there is more than one valid canonical Alpha Type, set to alphaType, if valid. If true is returned and canonical is not nullptr, store valid Alpha Type.
Returns false only if alphaType is kUnknown_SkAlphaType, color type is not kUnknown_SkColorType, and Color Type is not always opaque. If false is returned, canonical is ignored.
For kUnknown_SkColorType: set canonical to kUnknown_SkAlphaType and return true. For kAlpha_8_SkColorType: set canonical to kPremul_SkAlphaType or kOpaque_SkAlphaType and return true if alphaType is not kUnknown_SkAlphaType. For kRGB_565_SkColorType, kRGB_888x_SkColorType, kRGB_101010x_SkColorType, and kGray_8_SkColorType: set canonical to kOpaque_SkAlphaType and return true. For kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, and kRGBA_F16_SkColorType: set canonical to alphaType and return true if alphaType is not kUnknown_SkAlphaType.
true if valid Alpha Type can be associated with colorType
SkColorTypeIsAlwaysOpaque
Describes color range of YUV pixels. The color mapping from YUV to RGB varies depending on the source. YUV pixels may be generated by JPEG images, standard video streams, or high definition video streams. Each has its own mapping from YUV and RGB.
JPEG YUV values encode the full range of 0 to 255 for all three components. Video YUV values range from 16 to 235 for all three components. Details of encoding and conversion to RGB are described in YCbCr color space .
SkImage::MakeFromYUVTexturesCopy SkImage::MakeFromNV12TexturesCopy
SkImageInfo related constants are defined by enum, enum class, #define, const, and constexpr.
Describes pixel dimensions and encoding. Bitmap, Image, PixMap, and Surface can be created from Image Info. Image Info can be retrieved from Bitmap and Pixmap, but not from Image and Surface. For example, Image and Surface implementations may defer pixel depth, so may not completely specify Image Info.
Image Info contains dimensions, the pixel integral width and height. It encodes how pixel bits describe Color Alpha, transparency; Color components red, blue, and green; and Color Space, the range and linearity of colors.
SkImageInfo member functions read and modify the structure properties.
SkImageInfo global, struct, and class related member functions share a topic.
SkImageInfo can be constructed or initialized by these functions, including C++ class constructors.
Creates an empty Image Info with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of zero, and no Color Space.
empty Image Info
Make MakeN32 MakeS32 MakeA8
Creates Image Info from integral dimensions width and height, Color Type ct, Alpha Type at, and optionally Color Space cs.
If Color Space cs is nullptr and Image Info is part of drawing source: Color Space defaults to sRGB, mapping into Surface Color Space.
Parameters are not validated to see if their values are legal, or that the combination is supported.
created Image Info
MakeN32 MakeN32Premul[2] MakeS32 MakeA8
Creates Image Info from integral dimensions width and height, kN32_SkColorType, Alpha Type at, and optionally Color Space cs. kN32_SkColorType will equal either kBGRA_8888_SkColorType or kRGBA_8888_SkColorType, whichever is optimal.
If Color Space cs is nullptr and Image Info is part of drawing source: Color Space defaults to sRGB, mapping into Surface Color Space.
Parameters are not validated to see if their values are legal, or that the combination is supported.
created Image Info
Make MakeN32Premul[2] MakeS32 MakeA8
Creates Image Info from integral dimensions width and height, kN32_SkColorType, Alpha Type at, with sRGB Color Space.
Parameters are not validated to see if their values are legal, or that the combination is supported.
created Image Info
Make MakeN32 MakeN32Premul[2] MakeA8
Creates Image Info from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType, with optional Color Space.
If Color Space cs is nullptr and Image Info is part of drawing source: Color Space defaults to sRGB, mapping into Surface Color Space.
Parameters are not validated to see if their values are legal, or that the combination is supported.
created Image Info
MakeN32 MakeS32 MakeA8 Make
Creates Image Info from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType, with Color Space set to nullptr.
If Image Info is part of drawing source: Color Space defaults to sRGB, mapping into Surface Color Space.
Parameters are not validated to see if their values are legal, or that the combination is supported.
created Image Info
MakeN32 MakeS32 MakeA8 Make
Creates Image Info from integral dimensions width and height, kAlpha_8_SkColorType, kPremul_SkAlphaType, with Color Space set to nullptr.
created Image Info
MakeN32 MakeS32 Make
Creates Image Info from integral dimensions width and height, kUnknown_SkColorType, kUnknown_SkAlphaType, with Color Space set to nullptr.
Returned Image Info as part of source does not draw, and as part of destination can not be drawn to.
created Image Info
SkImageInfo() MakeN32 MakeS32 Make
Creates Image Info from integral dimensions width and height set to zero, kUnknown_SkColorType, kUnknown_SkAlphaType, with Color Space set to nullptr.
Returned Image Info as part of source does not draw, and as part of destination can not be drawn to.
created Image Info
SkImageInfo() MakeN32 MakeS32 Make
Returns pixel count in each row.
pixel width
height SkBitmap::width SkPixelRef::width SkImage::width SkSurface::width
Returns pixel row count.
pixel height
width SkBitmap::height SkPixelRef::height SkImage::height SkSurface::height
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.
Color Type
color type: kAlpha_8_SkColorType
alphaType SkPixmap::colorType SkBitmap::colorType
Returns Alpha Type, one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType, kUnpremul_SkAlphaType.
Alpha Type
alpha type: kPremul_SkAlphaType
colorType SkPixmap::alphaType SkBitmap::alphaType
Returns Color Space, the range of colors. The reference count of Color Space is unchanged. The returned Color Space is immutable.
Color Space, or nullptr
gammaCloseToSRGB: false gammaIsLinear: true isSRGB: false
Color Space SkPixmap::colorSpace SkBitmap::colorSpace
Returns smart pointer to Color Space, the range of colors. The smart pointer tracks the number of objects sharing this Color Space reference so the memory is released when the owners destruct.
The returned Color Space is immutable.
Color Space wrapped in a smart pointer
Color Space SkBitmap::refColorSpace
Returns if Image Info describes an empty area of pixels by checking if either width or height is zero or smaller.
true if either dimension is zero or smaller
width: 0 height: 0 empty: true width: 0 height: 2 empty: true width: 2 height: 0 empty: true width: 2 height: 2 empty: false
dimensions bounds SkBitmap::empty SkPixmap::bounds
Returns true if Alpha Type is set to hint that all pixels are opaque; their Color Alpha value is implicitly or explicitly 1.0. If true, and all pixels are not opaque, Skia may draw incorrectly.
Does not check if Color Type allows Alpha, or if any pixel value has transparency.
true if Alpha Type is kOpaque_SkAlphaType
isOpaque: false isOpaque: false isOpaque: true isOpaque: true
Color Alpha SkColorTypeValidateAlphaType SkBitmap::isOpaque SkImage::isOpaque SkPixmap::isOpaque
Returns ISize { width, height }.
integral size of width and height
dimensionsAsBounds == bounds
width height bounds SkBitmap::dimensions
Returns IRect { 0, 0, width, height }.
integral rectangle from origin to width and height
width height dimensions
Returns true if associated Color Space is not nullptr, and Color Space gamma is approximately the same as sRGB. This includes the sRGB transfer function as well as a gamma curve described by a 2.2 exponent.
true if Color Space gamma is approximately the same as sRGB
SkColorSpace::gammaCloseToSRGB
Creates Image Info with the same Color Type, Color Space, and Alpha Type, with dimensions set to width and height.
created Image Info
Make makeAlphaType makeColorSpace makeColorType
Creates Image Info with same Color Type, Color Space, width, and height, with Alpha Type set to newAlphaType.
Created Image Info contains newAlphaType even if it is incompatible with Color Type, in which case Alpha Type in Image Info is ignored.
created Image Info
Make MakeA8 makeColorType makeColorSpace
Creates Image Info with same Alpha Type, Color Space, width, and height, with Color Type set to newColorType.
created Image Info
Make makeAlphaType makeColorSpace
Creates Image Info with same Alpha Type, Color Type, width, and height, with Color Space set to cs.
created Image Info
Make MakeS32 makeAlphaType makeColorType
Returns number of bytes per pixel required by Color Type. Returns zero if colorType( is kUnknown_SkColorType.
bytes in pixel
color: kUnknown_SkColorType bytesPerPixel: 0 color: kAlpha_8_SkColorType bytesPerPixel: 1 color: kRGB_565_SkColorType bytesPerPixel: 2 color: kARGB_4444_SkColorType bytesPerPixel: 2 color: kRGBA_8888_SkColorType bytesPerPixel: 4 color: kRGB_888x_SkColorType bytesPerPixel: 4 color: kBGRA_8888_SkColorType bytesPerPixel: 4 color: kRGBA_1010102_SkColorType bytesPerPixel: 4 color: kRGB_101010x_SkColorType bytesPerPixel: 4 color: kGray_8_SkColorType bytesPerPixel: 1 color: kRGBA_F16_SkColorType bytesPerPixel: 8
width shiftPerPixel SkBitmap::bytesPerPixel
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
color: kUnknown_SkColorType shiftPerPixel: 0 color: kAlpha_8_SkColorType shiftPerPixel: 0 color: kRGB_565_SkColorType shiftPerPixel: 1 color: kARGB_4444_SkColorType shiftPerPixel: 1 color: kRGBA_8888_SkColorType shiftPerPixel: 2 color: kRGB_888x_SkColorType shiftPerPixel: 2 color: kBGRA_8888_SkColorType shiftPerPixel: 2 color: kRGBA_1010102_SkColorType shiftPerPixel: 2 color: kRGB_101010x_SkColorType shiftPerPixel: 2 color: kGray_8_SkColorType shiftPerPixel: 0 color: kRGBA_F16_SkColorType shiftPerPixel: 3
bytesPerPixel minRowBytes SkBitmap::shiftPerPixel SkPixmap::shiftPerPixel
Returns minimum bytes per row, computed from pixel width and Color Type, which specifies bytesPerPixel. Bitmap maximum value for row bytes must fit in 31 bits.
width times bytesPerPixel as unsigned 64-bit integer
RGBA_F16 width 16777216 (0x01000000) OK RGBA_F16 width 33554432 (0x02000000) OK RGBA_F16 width 67108864 (0x04000000) OK RGBA_F16 width 134217728 (0x08000000) OK RGBA_F16 width 268435456 (0x10000000) too large RGBA_F16 width 536870912 (0x20000000) too large RGBA_F16 width 1073741824 (0x40000000) too large RGBA_F16 width -2147483648 (0x80000000) too large
minRowBytes computeByteSize computeMinByteSize validRowBytes
Returns minimum bytes per row, computed from pixel width and Color Type, which specifies bytesPerPixel. Bitmap maximum value for row bytes must fit in 31 bits.
width times bytesPerPixel as signed 32-bit integer
RGBA_F16 width 16777216 (0x01000000) OK RGBA_F16 width 33554432 (0x02000000) OK RGBA_F16 width 67108864 (0x04000000) OK RGBA_F16 width 134217728 (0x08000000) OK RGBA_F16 width 268435456 (0x10000000) too large RGBA_F16 width 536870912 (0x20000000) too large RGBA_F16 width 1073741824 (0x40000000) too large RGBA_F16 width -2147483648 (0x80000000) too large
minRowBytes64 computeByteSize computeMinByteSize validRowBytes
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.
offset within pixel array
height width minRowBytes computeByteSize
SkImageInfo operators inline class member functions with arithmetic equivalents.
Compares Image Info with other, and returns true if width, height, Color Type, Alpha Type, and Color Space are equivalent.
true if Image Info equals other
info1 != info2 info1 != info2 info1 != info2 info1 == info2
operator!=(const SkImageInfo& other) const SkColorSpace::Equals
Compares Image Info with other, and returns true if width, height, Color Type, Alpha Type, and Color Space are not equivalent.
true if Image Info is not equal to other
info1 != info2 info1 != info2 info1 != info2 info1 == info2
operator==(const SkImageInfo& other) const SkColorSpace::Equals
Returns storage required by pixel array, given Image Info dimensions, Color Type, 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.
memory required by pixel buffer
computeMinByteSize validRowBytes
Returns storage required by pixel array, given Image Info dimensions, and Color Type. 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.
least memory required by pixel buffer
computeByteSize validRowBytes
Returns true if byteSize equals SIZE_MAX. computeByteSize and computeMinByteSize return SIZE_MAX if size_t can not hold buffer size.
true if computeByteSize or computeMinByteSize result exceeds size_t
rowBytes:100000000 size:99999999900000008 overflowed:false rowBytes:1000000000 size:999999999000000008 overflowed:false rowBytes:10000000000 size:9999999990000000008 overflowed:false rowBytes:100000000000 size:18446744073709551615 overflowed:true rowBytes:1000000000000 size:18446744073709551615 overflowed:true
computeByteSize computeMinByteSize validRowBytes
Returns true if rowBytes is smaller than width times pixel size.
true if rowBytes is large enough to contain pixel row
validRowBytes(60): false validRowBytes(64): true validRowBytes(68): true
ByteSizeOverflowed computeByteSize computeMinByteSize
Creates an empty Image Info with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of zero, and no Color Space.
info == copy info != reset copy SkImageInfo() == reset copy
SkImageInfo()
Asserts if internal values are illegal or inconsistent. Only available if SK_DEBUG is defined at compile time.
validRowBytes SkBitmap::validate