This adds the ability to define long phrases in one place and refer to those phrases in many places. Bookmaker has new syntax to support phrase substitution. When it encounters #some_phrase_reference# It substitutes the body of #PhraseDef some_phrase_reference text to substitute when encountering the phrase ## The phrase label must start with a lowercase letter, and be bracketed by single hash marks, without spaces between the label and the hash marks. Docs-Preview: https://skia.org/?cl=111224 TBR=caryclark@google.com Bug: skia:6898 Change-Id: I12c57d916ccedbd86b421377d117399150ada72a Reviewed-on: https://skia-review.googlesource.com/111224 Reviewed-by: Cary Clark <caryclark@skia.org> Commit-Queue: Cary Clark <caryclark@skia.org>
62 KiB
SkImageInfo Reference
Image Info
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.
Overview
Overview Subtopic
name | description |
---|---|
Constructor | functions that construct SkImageInfo |
Member Function | static functions and member methods |
Operator | operator overloading methods |
Related Function | similar methods grouped together |
Constant
name | description |
---|
Alpha Type
Enum SkAlphaType
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 = draw color * alpha + destination color * (1 - alpha) In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.
Color RGB may have Color Alpha included in each component value; the stored value is the original Color RGB multiplied by Color Alpha. Premultiplied color components improve performance.
Constants
kUnknown_SkAlphaType | 0 | Alpha Type is uninitialized. |
kOpaque_SkAlphaType | 1 | Pixels are opaque. The Color Type must have no explicit alpha component, or all alpha components must be set to their maximum value. |
kPremul_SkAlphaType | 2 | Pixels have alpha premultiplied into color components. Surface pixels must be premultiplied. |
kUnpremul_SkAlphaType | 3 | Pixel color component values are independent of alpha value. Images generated from encoded data like PNG do not premultiply pixel color components. kUnpremul_SkAlphaType is supported for Image pixels, but not for Surface pixels. |
See Also
Alpha Type Opaque
Use Opaque 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 Opaque but all alpha values are not 1.0, results are undefined.
Example
Alpha Type Premul
Use Premul 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 alphaThe color component must be equal to or smaller than the alpha component, or the results are undefined.
Example
Alpha Type Unpremul
Use Unpremul if stored color components are not divided by the alpha component. Some drawing destinations may not support Unpremul.
Example
Color Type
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 Native
Enum SkColorType
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, kLastEnum_SkColorType = kRGBA_F16_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 gray level, Color RGB, or Color ARGB.
kN32_SkColorType selects the native 32-bit Color ARGB format. On Little_Endian processors, pixels containing 8-bit Color ARGB components pack into 32-bit kBGRA_8888_SkColorType. On Big_Endian processors, pixels pack into 32-bit kRGBA_8888_SkColorType.
Constants
kUnknown_SkColorType | 0 | |
kAlpha_8_SkColorType | 1 | Encodes Color Alpha as Alpha 8 pixel in an 8-bit byte. |
kRGB_565_SkColorType | 2 | Encodes Color RGB as BGR 565 pixel in a 16-bit word. |
kARGB_4444_SkColorType | 3 | Encodes Color ARGB as ABGR 4444 pixel in a 16-bit word. |
kRGBA_8888_SkColorType | 4 | Encodes Color ARGB as RGBA 8888 pixel in a 32-bit word. |
kRGB_888x_SkColorType | 5 | Encodes Color RGB as RGB 888x pixel in a 32-bit word. |
kBGRA_8888_SkColorType | 6 | Encodes Color ARGB as BGRA 8888 pixel in a 32-bit word. |
kRGBA_1010102_SkColorType | 7 | Encodes Color ARGB as RGBA 1010102 pixel in a 32-bit word. |
kRGB_101010x_SkColorType | 8 | Encodes Color RGB as RGB 101010x pixel in a 32-bit word. |
kGray_8_SkColorType | 9 | Encodes Color Gray as Gray 8 in an 8-bit byte. |
kRGBA_F16_SkColorType | 10 | Encodes Color ARGB as RGBA F16 in a 64-bit word. |
Constants
kN32_SkColorType | 4 | Encodes Color ARGB as either RGBA 8888 or BGRA 8888, whichever is native to the platform. |
See Also
Color Type Alpha 8
Alpha 8 is an 8-bit byte pixel encoding that represents transparency. A value of zero is completely transparent; a value of 255 is completely opaque. Bitmap with Alpha 8 pixels does not visibly draw, because its pixels have no color information. The paired SkAlphaType is ignored.
Example
Color Type BGR 565
BGR 565 is a 16-bit word pixel encoding that contains five bits of blue, six bits of green, and five bits of red. BGR 565 is fully opaque as if its Color Alpha was set to one, and should always be paired with kOpaque_SkAlphaType.
Example
Color Type ABGR 4444
ABGR 4444 is a 16-bit word pixel encoding that contains four bits of alpha, four bits of blue, four bits of green, and four bits of red.
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.
Example
Color Type RGBA 8888
RGBA 8888 is a 32-bit word pixel encoding that contains eight bits of red, eight bits of green, eight bits of blue, and eight bits of alpha.
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, RGBA 8888 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
Color Type RGB 888x
RGB 888x is a 32-bit word pixel encoding that contains eight bits of red, eight bits of green, eight bits of blue, and eight unused bits. RGB 888x is fully opaque as if its Color Alpha was set to one, and should always be paired with kOpaque_SkAlphaType.
Example
Color Type BGRA 8888
BGRA 8888 is a 32-bit word pixel encoding that contains eight bits of blue, eight bits of green, eight bits of red, and eight bits of alpha.
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 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 255, the drawn result is undefined.
On Little_Endian platforms, BGRA 8888 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
Color Type RGBA 1010102
RGBA 1010102 is a 32-bit word pixel encoding that contains ten bits of red, ten bits of green, ten bits of blue, and two bits of alpha. Possible alpha values are zero: fully transparent; one: 33% opaque; two: 67% opaque; three: fully opaque.
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 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 3, the drawn result is undefined.
Example
Color Type RGB 101010x
Example
Color Type Gray 8
Example
Color Type RGBA F16
Example
YUV ColorSpace
Enum SkYUVColorSpace
enum SkYUVColorSpace { kJPEG_SkYUVColorSpace, kRec601_SkYUVColorSpace, kRec709_SkYUVColorSpace, kLastEnum_SkYUVColorSpace = kRec709_SkYUVColorSpace, };
Describes the color space a YUV pixel.
Constants
kJPEG_SkYUVColorSpace | 0 | Standard JPEG color space. |
kRec601_SkYUVColorSpace | 1 | SDTV standard Rec. 601 color space. Uses "studio swing" [16, 235] color range. See http://en.wikipedia.org/wiki/Rec._601 for details. |
kRec709_SkYUVColorSpace | 2 | HDTV standard Rec. 709 color space. Uses "studio swing" [16, 235] color range. See http://en.wikipedia.org/wiki/Rec._709 for details. |
Example
See Also
incomplete
Enum SkDestinationSurfaceColorMode
enum class SkDestinationSurfaceColorMode { kLegacy, kGammaAndColorSpaceAware, };
Constants
SkDestinationSurfaceColorMode::kLegacy | 0 | |
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware | 1 |
Example
See Also
incomplete
Struct SkImageInfo
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.
Member Function
Related Function
name | description |
---|---|
Property | metrics and attributes |
Utility | rarely called management functions |
Constructor
name | description |
---|---|
Make | creates Image Info from dimensions, Color Type, Alpha Type, Color Space |
MakeA8 | creates Image Info with kAlpha_8_SkColorType, kPremul_SkAlphaType |
MakeN32 | creates Image Info with Native Color Type |
MakeN32Premul | creates Image Info with Native Color Type, kPremul_SkAlphaType |
MakeN32Premul(int width, int height, sk sp<SkColorSpace> cs = nullptr) | |
MakeN32Premul(const SkISize& size) | |
MakeS32 | creates Image Info with Native Color Type, sRGB Color Space |
MakeUnknown | creates Image Info with kUnknown_SkColorType, kUnknown_SkAlphaType |
MakeUnknown(int width, int height) | |
MakeUnknown() | |
SkImageInfo() | creates with zero dimensions, kUnknown_SkColorType, kUnknown_SkAlphaType |
makeAlphaType | creates Image Info with changed Alpha Type |
makeColorSpace | creates Image Info with changed Color Space |
makeColorType | creates Image Info with changed Color Type |
makeWH | creates Image Info with changed dimensions |
reset | incomplete |
SkImageInfo
SkImageInfo()
Creates an empty Image Info with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of zero, and no Color Space.
Return Value
empty Image Info
Example
See Also
Make
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs = nullptr)
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.
Parameters
width | pixel column count; must be zero or greater |
height | pixel row count; must be zero or greater |
ct | 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 |
at | one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType, kUnpremul_SkAlphaType |
cs | range of colors; may be nullptr |
Return Value
created Image Info
Example
See Also
MakeN32 MakeN32Premul[2] MakeS32 MakeA8
MakeN32
static SkImageInfo MakeN32(int width, int height, SkAlphaType at, sk_sp<SkColorSpace> cs = nullptr)
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.
Parameters
width | pixel column count; must be zero or greater |
height | pixel row count; must be zero or greater |
at | one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType, kUnpremul_SkAlphaType |
cs | range of colors; may be nullptr |
Return Value
created Image Info
Example
See Also
Make MakeN32Premul[2] MakeS32 MakeA8
MakeS32
static SkImageInfo MakeS32(int width, int height, SkAlphaType at)
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.
Parameters
width | pixel column count; must be zero or greater |
height | pixel row count; must be zero or greater |
at | one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType, kPremul_SkAlphaType, kUnpremul_SkAlphaType |
Return Value
created Image Info
Example
See Also
Make MakeN32 MakeN32Premul[2] MakeA8
MakeN32Premul
static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs = nullptr)
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.
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 Image Info
Example
See Also
static SkImageInfo MakeN32Premul(const SkISize& size)
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.
Parameters
size | width and height, each must be zero or greater |
Return Value
created Image Info
Example
See Also
MakeA8
static SkImageInfo MakeA8(int width, int height)
Creates Image Info from integral dimensions width and height, kAlpha_8_SkColorType, kPremul_SkAlphaType, with Color Space set to nullptr.
Parameters
width | pixel column count; must be zero or greater |
height | pixel row count; must be zero or greater |
Return Value
created Image Info
Example
See Also
MakeUnknown
static SkImageInfo MakeUnknown(int width, int height)
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.
Parameters
width | pixel column count; must be zero or greater |
height | pixel row count; must be zero or greater |
Return Value
created Image Info
Example
See Also
SkImageInfo() MakeN32 MakeS32 Make
static SkImageInfo MakeUnknown()
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.
Return Value
created Image Info
Example
See Also
SkImageInfo() MakeN32 MakeS32 Make
Property
name | description |
---|---|
alphaType | incomplete |
bounds | incomplete |
bytesPerPixel | incomplete |
colorSpace | incomplete |
colorType | incomplete |
dimensions | incomplete |
gammaCloseToSRGB | incomplete |
height | returns pixel row count |
isEmpty | incomplete |
isOpaque | incomplete |
minRowBytes | incomplete |
minRowBytes64 | incomplete |
refColorSpace | incomplete |
shiftPerPixel | incomplete |
width | returns pixel column count |
width
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
height
int height() const
Returns pixel row count.
Return Value
pixel height
Example
See Also
width SkBitmap::height SkPixelRef::height SkImage::height SkSurface::height
colorType
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
Example
See Also
incomplete
alphaType
SkAlphaType alphaType() const
Return Value
incomplete
Example
See Also
incomplete
colorSpace
SkColorSpace* colorSpace() const
Return Value
incomplete
Example
See Also
incomplete
refColorSpace
sk_sp<SkColorSpace> refColorSpace() const
Return Value
incomplete
Example
See Also
incomplete
isEmpty
bool isEmpty() const
Return Value
incomplete
Example
See Also
incomplete
isOpaque
bool isOpaque() const
Return Value
incomplete
Example
See Also
incomplete
dimensions
SkISize dimensions() const
Return Value
incomplete
Example
See Also
incomplete
bounds
SkIRect bounds() const
Return Value
incomplete
Example
See Also
incomplete
gammaCloseToSRGB
bool gammaCloseToSRGB() const
Return Value
incomplete
Example
See Also
incomplete
makeWH
SkImageInfo makeWH(int newWidth, int newHeight) const
Creates Image Info with the same Color Type and Alpha Type as this info, but with the specified width and height.
Parameters
newWidth | incomplete |
newHeight | incomplete |
Return Value
incomplete
Example
See Also
incomplete
makeAlphaType
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
Parameters
newAlphaType | incomplete |
Return Value
incomplete
Example
See Also
incomplete
makeColorType
SkImageInfo makeColorType(SkColorType newColorType) const
Parameters
newColorType | incomplete |
Return Value
incomplete
Example
See Also
incomplete
makeColorSpace
SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const
Parameters
cs | incomplete |
Return Value
incomplete
Example
See Also
incomplete
bytesPerPixel
int bytesPerPixel() const
Return Value
incomplete
Example
See Also
incomplete
shiftPerPixel
int shiftPerPixel() const
Return Value
incomplete
Example
See Also
incomplete
minRowBytes64
uint64_t minRowBytes64() const
Return Value
incomplete
Example
See Also
incomplete
minRowBytes
size_t minRowBytes() const
Return Value
incomplete
Example
See Also
incomplete
computeOffset
size_t computeOffset(int x, int y, size_t rowBytes) const
Parameters
x | incomplete |
y | incomplete |
rowBytes | incomplete |
Return Value
incomplete
Example
See Also
incomplete
Operator
name | description |
---|---|
operator!=(const SkImageInfo& other) const | incomplete |
operator==(const SkImageInfo& other) const | incomplete |
operator==
bool operator==(const SkImageInfo& other) _const
Parameters
other | incomplete |
Return Value
incomplete
Example
See Also
incomplete
operator!=
bool operator!=(const SkImageInfo& other) _const
Parameters
other | incomplete |
Return Value
incomplete
Example
See Also
incomplete
unflatten
void unflatten(SkReadBuffer& buffer)
Parameters
buffer | incomplete |
Example
See Also
incomplete
flatten
void flatten(SkWriteBuffer& buffer) const
Parameters
buffer | incomplete |
Example
See Also
incomplete
computeByteSize
size_t computeByteSize(size_t rowBytes) const
Returns the size (in bytes) of the image buffer that this info needs, given the specified rowBytes. The rowBytes must be >= this->minRowBytes. if (height == 0) { return 0; } else { return (height - 1) * rowBytes + width * bytes_per_pixel.
If the calculation overflows this returns SK MaxSizeT.
Parameters
rowBytes | incomplete |
Return Value
incomplete
Example
See Also
incomplete
computeMinByteSize
size_t computeMinByteSize() const
Returns the minimum size (in bytes) of the image buffer that this info needs. If the calculation overflows, or if the height is 0, this returns 0.
Return Value
incomplete
Example
See Also
incomplete
ByteSizeOverflowed
static bool ByteSizeOverflowed(size_t byteSize)
Returns true if the result of computeByteSize (or computeMinByteSize) overflowed
Parameters
byteSize | incomplete |
Return Value
incomplete
Example
See Also
incomplete
validRowBytes
bool validRowBytes(size_t rowBytes) const
Parameters
rowBytes | incomplete |
Return Value
incomplete
Example
See Also
incomplete
reset
void reset()
Example
See Also
incomplete
Utility
name | description |
---|---|
ByteSizeOverflowed | incomplete |
computeByteSize | incomplete |
computeMinByteSize | incomplete |
computeOffset | incomplete |
flatten | incomplete |
unflatten | incomplete |
validRowBytes | incomplete |
validate | incomplete |
validate
void validate() const
Example
See Also
incomplete