SkImageInfo Reference
===
enum SkAlphaType {
kUnknown_SkAlphaType,
kOpaque_SkAlphaType,
kPremul_SkAlphaType,
kUnpremul_SkAlphaType,
kLastEnum_SkAlphaType = kUnpremul_SkAlphaType,
};
static bool SkAlphaTypeIsOpaque(SkAlphaType at);
;
enum SkColorType {
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,
kRGBA_F32_SkColorType,
kLastEnum_SkColorType = kRGBA_F32_SkColorType,
kN32_SkColorType = kBGRA_8888_SkColorType,
kN32_SkColorType = kRGBA_8888_SkColorType,
};
int SkColorTypeBytesPerPixel(SkColorType ct);
;
bool SkColorTypeIsAlwaysOpaque(SkColorType ct);
;
bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType,
SkAlphaType* canonical = nullptr);
;
enum SkYUVColorSpace {
kJPEG_SkYUVColorSpace,
kRec601_SkYUVColorSpace,
kRec709_SkYUVColorSpace,
kLastEnum_SkYUVColorSpace = kRec709_SkYUVColorSpace,
};
struct SkImageInfo {
// SkImageInfo interface
};
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.
---
enum SkAlphaType {
kUnknown_SkAlphaType,
kOpaque_SkAlphaType,
kPremul_SkAlphaType,
kUnpremul_SkAlphaType,
kLastEnum_SkAlphaType = kUnpremul_SkAlphaType,
};
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,
new color is set to: draw color * alpha + destination color * (1 - alpha)
.
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.
### Constants
### See Also
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.
### Example
---
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.
stored color = original color * alpha / max alpha
The color component must be equal to or smaller than the alpha component,
or the results are undefined.
### Example
---
Use kUnpremul_SkAlphaType if stored color components are not divided by the
alpha component. Some drawing destinations may not support
kUnpremul_SkAlphaType.
### Example
SkColorSetARGB parameter a is set to 150, less than its maximum value, and is
interpreted as
Color_Alpha of about 0.6.
color is not
Premultiplied;
color components may have values greater than
color alpha.
The four displayed values are the original component values, though not necessarily
in the same order.
---
static bool SkAlphaTypeIsOpaque(SkAlphaType at)
Returns true if SkAlphaType equals kOpaque_SkAlphaType. kOpaque_SkAlphaType is a
hint that the SkColorType is opaque, or that all alpha values are set to
their 1.0 equivalent. If SkAlphaType is kOpaque_SkAlphaType, and SkColorType is not
opaque, then the result of drawing any pixel with a alpha value less than
1.0 is undefined.
### Parameters
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
kUnpremul_SkAlphaType
### Return Value
true if at equals kOpaque_SkAlphaType
---
enum SkColorType {
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,
kRGBA_F32_SkColorType,
kLastEnum_SkColorType = kRGBA_F32_SkColorType,
kN32_SkColorType = kBGRA_8888_SkColorType,
kN32_SkColorType = kRGBA_8888_SkColorType,
};
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.
### Constants
Const |
Value |
Details |
Description |
kUnknown_SkColorType |
0 |
|
Color_Type is set to kUnknown_SkColorType by default. If set,
encoding format and size is unknown.
|
kAlpha_8_SkColorType |
1 |
Alpha 8 |
Stores 8-bit byte pixel encoding that represents transparency. Value of zero
is completely transparent; a value of 255 is completely opaque.
|
kRGB_565_SkColorType |
2 |
RGB 565 |
Stores 16-bit word pixel encoding that contains five bits of blue,
six bits of green, and five bits of red.
|
kARGB_4444_SkColorType |
3 |
ARGB 4444 |
Stores 16-bit word pixel encoding that contains four bits of alpha,
four bits of blue, four bits of green, and four bits of red.
|
kRGBA_8888_SkColorType |
4 |
RGBA 8888 |
Stores 32-bit word pixel encoding that contains eight bits of red,
eight bits of green, eight bits of blue, and eight bits of alpha.
|
kRGB_888x_SkColorType |
5 |
RGB 888 |
Stores 32-bit word pixel encoding that contains eight bits of red,
eight bits of green, eight bits of blue, and eight unused bits.
|
kBGRA_8888_SkColorType |
6 |
BGRA 8888 |
Stores 32-bit word pixel encoding that contains eight bits of blue,
eight bits of green, eight bits of red, and eight bits of alpha.
|
kRGBA_1010102_SkColorType |
7 |
RGBA 1010102 |
Stores 32-bit word pixel encoding that contains ten bits of red,
ten bits of green, ten bits of blue, and two bits of alpha.
|
kRGB_101010x_SkColorType |
8 |
RGB 101010 |
Stores 32-bit word pixel encoding that contains ten bits of red,
ten bits of green, ten bits of blue, and two unused bits.
|
kGray_8_SkColorType |
9 |
Gray 8 |
Stores 8-bit byte pixel encoding that equivalent to equal values for red,
blue, and green, representing colors from black to white.
|
kRGBA_F16_SkColorType |
10 |
RGBA F16 |
Stores 64-bit word pixel encoding that contains 16 bits of blue,
16 bits of green, 16 bits of red, and 16 bits of alpha. Each component
is encoded as a half float.
|
kRGBA_F32_SkColorType |
11 |
RGBA F32 |
Stores 128-bit word pixel encoding that contains 32 bits of blue,
32 bits of green, 32 bits of red, and 32 bits of alpha. Each component
is encoded as a single precision float.
|
kLastEnum_SkColorType |
11 |
|
Used by tests to iterate through all valid values.
|
kN32_SkColorType |
4 or 6 |
|
Encodes ARGB as either kRGBA_8888_SkColorType or
kBGRA_8888_SkColorType, whichever is native to the platform.
|
### See Also
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.
### Example
Alpha pixels can modify another draw. orangePaint fills the bounds of
bitmap,
with its transparency set to alpha8
pixel value.
### See Also
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.
![Color_Type_RGB_565](https://fiddle.skia.org/i/6dec0226490a4ac1977dc87a31564147_raster.png "")
### Example
### See Also
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.
![Color_Type_ARGB_4444](https://fiddle.skia.org/i/e8008512f0d197051e3f26faa67bafc2_raster.png "")
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 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 15, the drawn result is undefined.
### Example
### See Also
RGBA_8888
---
kRGBA_8888_SkColorType encodes ARGB into a 32-bit word. Each component:
red, green, blue, alpha; use eight bits, describing 256 levels.
![Color_Type_RGBA_8888](https://fiddle.skia.org/i/9abc324f670e6468f09385551aae5a1c_raster.png "")
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 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 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.
### Example
### See Also
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.
![Color_Type_RGB_888](https://fiddle.skia.org/i/7527d7ade4764302818e250cd4e03962_raster.png "")
### Example
### See Also
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.
![Color_Type_BGRA_8888](https://fiddle.skia.org/i/6c35ca14d88b0de200ba7f897f889ad7_raster.png "")
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.
### Example
### See Also
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.
![Color_Type_RGBA_1010102](https://fiddle.skia.org/i/8d78daf69145f611054f289a7443a670_raster.png "")
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.
### Example
### See Also
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.
![Color_Type_RGB_101010](https://fiddle.skia.org/i/4c9f4d939e2047269d73fa3507caf01f_raster.png "")
### Example
### See Also
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.
### Example
### See Also
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.
![Color_Type_RGBA_F16](https://fiddle.skia.org/i/1bb35ae52173e0fef874022ca8138adc_raster.png "")
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.
### Example
### See Also
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.
![Color_Type_RGBA_F32](https://fiddle.skia.org/i/4ba31a8f9bc94a996f34da81ef541a9c_raster.png "")
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.
### See Also
SkColor4f
---
int SkColorTypeBytesPerPixel(SkColorType ct)
Returns the number of bytes required to store a pixel, including unused padding.
Returns zero if ct is kUnknown_SkColorType or invalid.
### Parameters
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
### Return Value
bytes per pixel
### Example
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
### See Also
SkImageInfo::bytesPerPixel
---
bool SkColorTypeIsAlwaysOpaque(SkColorType ct)
Returns true if SkColorType always decodes alpha to 1.0, making the pixel
fully opaque. If true, SkColorType does not reserve bits to encode alpha.
### Parameters
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
### Return Value
true if alpha is always set to 1.0
### Example
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
### See Also
SkColorTypeValidateAlphaType
---
bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType,
SkAlphaType* canonical = nullptr)
Returns true if canonical can be set to a valid SkAlphaType for colorType. If
there is more than one valid canonical SkAlphaType, set to alphaType, if valid.
If true is returned and canonical is not nullptr, store valid SkAlphaType.
Returns false only if alphaType is kUnknown_SkAlphaType, color type is not
kUnknown_SkColorType, and SkColorType 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.
### Parameters
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
### Parameters
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
kUnpremul_SkAlphaType
### Parameters
### Return Value
true if valid SkAlphaType can be associated with colorType
### Example
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
kUnpremul_SkAlphaType
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
### See Also
SkColorTypeIsAlwaysOpaque
---
enum SkYUVColorSpace {
kJPEG_SkYUVColorSpace,
kRec601_SkYUVColorSpace,
kRec709_SkYUVColorSpace,
kLastEnum_SkYUVColorSpace = kRec709_SkYUVColorSpace,
};
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 .
### Constants
### See Also
SkImage::MakeFromYUVTexturesCopy SkImage::MakeFromNV12TexturesCopy
---
struct SkImageInfo {
SkImageInfo();
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
sk_sp<SkColorSpace> cs = nullptr);
static SkImageInfo MakeN32(int width, int height, SkAlphaType at,
sk_sp<SkColorSpace> cs = nullptr);
static SkImageInfo MakeS32(int width, int height, SkAlphaType at);
static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs = nullptr);
static SkImageInfo MakeN32Premul(const SkISize& size);
static SkImageInfo MakeA8(int width, int height);
static SkImageInfo MakeUnknown(int width, int height);
static SkImageInfo MakeUnknown();
int width() const;
int height() const;
SkColorType colorType() const;
SkAlphaType alphaType() const;
SkColorSpace* colorSpace() const;
sk_sp<SkColorSpace> refColorSpace() const;
bool isEmpty() const;
bool isOpaque() const;
SkISize dimensions() const;
SkIRect bounds() const;
bool gammaCloseToSRGB() const;
SkImageInfo makeWH(int newWidth, int newHeight) const;
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const;
SkImageInfo makeColorType(SkColorType newColorType) const;
SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const;
int bytesPerPixel() const;
int shiftPerPixel() const;
uint64_t minRowBytes64() const;
size_t minRowBytes() const;
size_t computeOffset(int x, int y, size_t rowBytes) const;
bool operator==(const SkImageInfo& other) const;
bool operator!=(const SkImageInfo& other) const;
size_t computeByteSize(size_t rowBytes) const;
size_t computeMinByteSize() const;
static bool ByteSizeOverflowed(size_t byteSize);
bool validRowBytes(size_t rowBytes) const;
void reset();
void validate() const;
};
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()
Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType,
a width and height of zero, and no SkColorSpace.
### Return Value
empty SkImageInfo
### Example
### See Also
Make MakeN32 MakeS32 MakeA8
---
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
sk_sp<SkColorSpace> cs = nullptr)
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.
### Parameters
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
### Parameters
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
kUnpremul_SkAlphaType
### Parameters
cs |
range of colors; may be nullptr |
### Return Value
created SkImageInfo
### Example
### See Also
MakeN32 MakeN32Premul MakeS32 MakeA8
---
static SkImageInfo MakeN32(int width, int height, SkAlphaType at, sk_sp<SkColorSpace> cs = nullptr)
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.
### Parameters
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
kUnpremul_SkAlphaType
### Parameters
cs |
range of colors; may be nullptr |
### Return Value
created SkImageInfo
### Example
### See Also
Make MakeN32Premul MakeS32 MakeA8
---
static SkImageInfo MakeS32(int width, int height, SkAlphaType at)
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.
### Parameters
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
kUnpremul_SkAlphaType
### Return Value
created SkImageInfo
### Example
Top gradient is drawn to offScreen without
Color_Space. It is darker than middle
gradient, drawn to offScreen with sRGB
Color_Space. Bottom gradient shares bits
with middle, but does not specify the
Color_Space in noColorSpaceBitmap. A source
without
Color_Space is treated as sRGB; the bottom gradient is identical to the
middle gradient.
### See Also
Make MakeN32 MakeN32Premul MakeA8
---
static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs = nullptr)
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.
### Parameters
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 |
### Return Value
created SkImageInfo
### Example
### See Also
MakeN32 MakeS32 MakeA8 Make
---
static SkImageInfo MakeN32Premul(const SkISize& size)
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.
### Parameters
size |
width and height, each must be zero or greater |
### Return Value
created SkImageInfo
### Example
### See Also
MakeN32 MakeS32 MakeA8 Make
---
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.
### Parameters
### Return Value
created SkImageInfo
### Example
### See Also
MakeN32 MakeS32 Make
---
static SkImageInfo MakeUnknown(int width, int height)
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.
### Parameters
### Return Value
created SkImageInfo
### Example
### See Also
SkImageInfo() MakeN32 MakeS32 Make
---
static SkImageInfo MakeUnknown()
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.
### Return Value
created SkImageInfo
### Example
### See Also
SkImageInfo() MakeN32 MakeS32 Make
---
int width()const
Returns pixel count in each row.
### Return Value
pixel width
### Example
### See Also
height SkBitmap::width SkPixelRef::width SkImage::width SkSurface::width
---
int height()const
Returns pixel row count.
### Return Value
pixel height
### Example
### See Also
width SkBitmap::height SkPixelRef::height SkImage::height SkSurface::height
---
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
.
### Return Value
Color_Type
### Example
#### Example Output
~~~~
color type: kAlpha_8_SkColorType
~~~~
### See Also
alphaType SkPixmap::colorType SkBitmap::colorType
---
SkAlphaType alphaType()const
Returns Alpha_Type, one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
kUnpremul_SkAlphaType
.
### Return Value
Alpha_Type
### Example
#### Example Output
~~~~
alpha type: kPremul_SkAlphaType
~~~~
### See Also
colorType SkPixmap::alphaType SkBitmap::alphaType
---
SkColorSpace* colorSpace()const
Returns SkColorSpace, the range of colors. The reference count of
SkColorSpace is unchanged. The returned SkColorSpace is immutable.
### Return Value
SkColorSpace, or nullptr
### Example
#### Example Output
~~~~
gammaCloseToSRGB: false gammaIsLinear: true isSRGB: false
~~~~
### See Also
Color_Space SkPixmap::colorSpace SkBitmap::colorSpace
---
sk_sp<SkColorSpace> 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.
### Return Value
SkColorSpace wrapped in a smart pointer
### Example
### See Also
Color_Space SkBitmap::refColorSpace
---
bool isEmpty()const
Returns if SkImageInfo describes an empty area of pixels by checking if either
width or height is zero or smaller.
### Return Value
true if either dimension is zero or smaller
### Example
#### Example Output
~~~~
width: 0 height: 0 empty: true
width: 0 height: 2 empty: true
width: 2 height: 0 empty: true
width: 2 height: 2 empty: false
~~~~
### See Also
dimensions bounds SkBitmap::empty SkPixmap::bounds
---
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. 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.
### Return Value
true if SkAlphaType is kOpaque_SkAlphaType
### Example
#### Example Output
~~~~
isOpaque: false
isOpaque: false
isOpaque: true
isOpaque: true
~~~~
### See Also
Color_Alpha SkColorTypeValidateAlphaType SkBitmap::isOpaque SkImage::isOpaque SkPixmap::isOpaque
---
SkISize dimensions()const
Returns SkISize { width(), height() }.
### Return Value
integral size of width() and height()
### Example
#### Example Output
~~~~
dimensionsAsBounds == bounds
~~~~
### See Also
width height bounds SkBitmap::dimensions
---
SkIRect bounds()const
Returns SkIRect { 0, 0, width(), height() }.
### Return Value
integral rectangle from origin to width() and height()
### Example
### See Also
width height dimensions
---
bool gammaCloseToSRGB()const
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.
### Return Value
true if Color_Space gamma is approximately the same as sRGB
### Example
### See Also
SkColorSpace::gammaCloseToSRGB
---
SkImageInfo makeWH(int newWidth, int newHeight)const
Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType,
with dimensions set to width and height.
### Parameters
### Return Value
created SkImageInfo
### Example
### See Also
Make makeAlphaType makeColorSpace makeColorType
---
SkImageInfo makeAlphaType(SkAlphaType newAlphaType)const
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.
### Parameters
kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType,
kUnpremul_SkAlphaType
### Return Value
created SkImageInfo
### Example
### See Also
Make MakeA8 makeColorType makeColorSpace
---
SkImageInfo makeColorType(SkColorType newColorType)const
Creates SkImageInfo with same SkAlphaType, SkColorSpace, width, and height,
with SkColorType set to newColorType.
### Parameters
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
### Return Value
created SkImageInfo
### Example
### See Also
Make makeAlphaType makeColorSpace
---
SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs)const
Creates SkImageInfo with same SkAlphaType, SkColorType, width, and height,
with SkColorSpace set to cs.
### Parameters
cs |
range of colors; may be nullptr |
### Return Value
created SkImageInfo
### Example
### See Also
Make MakeS32 makeAlphaType makeColorType
---
int bytesPerPixel()const
Returns number of bytes per pixel required by SkColorType.
Returns zero if colorType( is kUnknown_SkColorType.
### Return Value
bytes in pixel
### Example
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
#### Example Output
~~~~
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
~~~~
### See Also
width shiftPerPixel SkBitmap::bytesPerPixel
---
int shiftPerPixel()const
Returns bit shift converting row bytes to row pixels.
Returns zero for kUnknown_SkColorType.
### Return Value
one of: 0, 1, 2, 3; left shift to convert pixels to bytes
### Example
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
#### Example Output
~~~~
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
~~~~
### See Also
bytesPerPixel minRowBytes SkBitmap::shiftPerPixel SkPixmap::shiftPerPixel
---
uint64_t minRowBytes64()const
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.
### Return Value
width() times bytesPerPixel() as unsigned 64-bit integer
### Example
#### Example Output
~~~~
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
~~~~
### See Also
minRowBytes computeByteSize computeMinByteSize validRowBytes
---
size_t minRowBytes()const
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.
### Return Value
width() times bytesPerPixel() as signed 32-bit integer
### Example
#### Example Output
~~~~
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
~~~~
### See Also
minRowBytes64 computeByteSize computeMinByteSize validRowBytes
---
size_t 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.
### Parameters
### Return Value
offset within pixel array
### Example
### See Also
height width minRowBytes computeByteSize
---
bool operator==(const SkImageInfo& other)const
Compares SkImageInfo with other, and returns true if width, height, SkColorType,
SkAlphaType, and SkColorSpace are equivalent.
### Parameters
### Return Value
true if SkImageInfo equals other
### Example
#### Example Output
~~~~
info1 != info2
info1 != info2
info1 != info2
info1 == info2
~~~~
### See Also
operator!=(const SkImageInfo& other) const SkColorSpace::Equals
---
bool operator!=(const SkImageInfo& other)const
Compares SkImageInfo with other, and returns true if width, height, SkColorType,
SkAlphaType, and SkColorSpace are not equivalent.
### Parameters
### Return Value
true if SkImageInfo is not equal to other
### Example
#### Example Output
~~~~
info1 != info2
info1 != info2
info1 != info2
info1 == info2
~~~~
### See Also
operator==(const SkImageInfo& other) const SkColorSpace::Equals
---
size_t 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.
### Parameters
### Return Value
memory required by pixel buffer
### Example
### See Also
computeMinByteSize validRowBytes
---
size_t computeMinByteSize()const
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.
### Return Value
least memory required by pixel buffer
### Example
### See Also
computeByteSize validRowBytes
---
static bool ByteSizeOverflowed(size_t byteSize)
Returns true if byteSize equals SIZE_MAX. computeByteSize() and
computeMinByteSize() return SIZE_MAX if size_t can not hold buffer size.
### Parameters
### Return Value
true if computeByteSize() or computeMinByteSize() result exceeds size_t
### Example
#### Example Output
~~~~
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
~~~~
### See Also
computeByteSize computeMinByteSize validRowBytes
---
bool validRowBytes(size_t rowBytes)const
Returns true if rowBytes is smaller than width times pixel size.
### Parameters
### Return Value
true if rowBytes is large enough to contain pixel row
### Example
#### Example Output
~~~~
validRowBytes(60): false
validRowBytes(64): true
validRowBytes(68): true
~~~~
### See Also
ByteSizeOverflowed computeByteSize computeMinByteSize
---
void reset()
Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType,
a width and height of zero, and no SkColorSpace.
### Example
#### Example Output
~~~~
info == copy
info != reset copy
SkImageInfo() == reset copy
~~~~
### See Also
SkImageInfo()
---
void validate()const
### See Also
validRowBytes SkBitmap::validate