ImageInfo
- class ImageInfo
Describes pixel dimensions and encoding.
Bitmap
,Image
,Pixmap
, andSurface
can be created fromImageInfo
.ImageInfo
can be retrieved fromBitmap
andPixmap
, but not fromImage
andSurface
. For example,Image
andSurface
implementations may defer pixel depth, so may not completely specifyImageInfo
.ImageInfo
contains dimensions, the pixel integral width and height. It encodes how pixel bits describe alpha, transparency; color components red, blue, and green; andColorSpace
, the range and linearity of colors.Methods
Returns true if byteSize equals SIZE_MAX.
Overloaded function.
Overloaded function.
Creates
ImageInfo
from integral dimensions width and height,kN32_ColorType
,AlphaType
at, and optionallyColorSpace
cs.Overloaded function.
Creates
ImageInfo
from integral dimensions width and height,kN32_ColorType
,AlphaType
at, with sRGBColorSpace
.Overloaded function.
Creates an empty
ImageInfo
withkUnknown_ColorType
,kUnknown_AlphaType
, a width and height of zero, and noColorSpace
.Returns number of bytes per pixel required by
ColorType
.Returns the dimensionless
ColorInfo
that represents the same color type, alpha type, and color space as thisImageInfo
.Returns
ColorSpace
, the range of colors.Returns storage required by pixel array, given
ImageInfo
dimensions,ColorType
, and rowBytes.Returns storage required by pixel array, given
ImageInfo
dimensions, andColorType
.Returns byte offset of pixel from pixel base address.
Returns true if associated
ColorSpace
is not nullptr, andColorSpace
gamma is approximately the same as sRGB.Returns pixel row count.
Returns if
ImageInfo
describes an empty area of pixels by checking if either width or height is zero or smaller.Returns true if
AlphaType
is set to hint that all pixels are opaque; their alpha value is implicitly or explicitly 1.0.Creates
ImageInfo
with sameColorType
,ColorSpace
, width, and height, withAlphaType
set to newAlphaType.Creates
ImageInfo
with sameAlphaType
,ColorType
, width, and height, withColorSpace
set to cs.Creates
ImageInfo
with sameAlphaType
,ColorSpace
, width, and height, withColorType
set to newColorType.Creates
ImageInfo
with the sameColorType
,ColorSpace
, andAlphaType
, with dimensions set to newDimensions.Creates
ImageInfo
with the sameColorType
,ColorSpace
, andAlphaType
, with dimensions set to width and height.Returns minimum bytes per row, computed from pixel
width()
andColorType
, which specifiesbytesPerPixel()
.Returns minimum bytes per row, computed from pixel
width()
andColorType
, which specifiesbytesPerPixel()
.Returns smart pointer to
ColorSpace
, the range of colors.Creates an empty
ImageInfo
withkUnknown_ColorType
,kUnknown_AlphaType
, a width and height of zero, and noColorSpace
.Returns bit shift converting row bytes to row pixels.
Returns true if rowBytes is valid for this
ImageInfo
.Returns pixel count in each row.
Methods
- static ImageInfo.ByteSizeOverflowed(byteSize: int) bool
Returns true if byteSize equals SIZE_MAX.
computeByteSize()
andcomputeMinByteSize()
return SIZE_MAX if size_t can not hold buffer size.- Parameters:
byteSize (int) – result of
computeByteSize()
orcomputeMinByteSize()
- Returns:
true if
computeByteSize()
orcomputeMinByteSize()
result exceeds size_t
- static ImageInfo.Make(*args, **kwargs)
Overloaded function.
Make(width: int, height: int, ct: skia.ColorType, at: skia.AlphaType, cs: skia.ColorSpace = None) -> skia.ImageInfo
Creates
ImageInfo
from integral dimensions width and height,ColorType
ct,AlphaType
at, and optionallyColorSpace
cs.If
ColorSpace
cs is nullptr andImageInfo
is part of drawing source:ColorSpace
defaults to sRGB, mapping intoSurface
ColorSpace
.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
- return:
created
ImageInfo
Make(dimensions: skia.ISize, ct: skia.ColorType, at: skia.AlphaType, cs: skia.ColorSpace = None) -> skia.ImageInfo
Make(dimensions: skia.ISize, colorInfo: skia.ColorInfo) -> skia.ImageInfo
Creates
ImageInfo
from integral dimensions andColorInfo
colorInfo,.Parameters are not validated to see if their values are legal, or that the combination is supported.
- param skia.ISize dimensions:
pixel column and row count; must be zeros or greater
- param skia.ColorInfo colorInfo:
ColorInfo
the pixel encoding consisting ofColorType
,AlphaType
, andColorSpace
(which may be nullptr)- return:
created
ImageInfo
- static ImageInfo.MakeA8(*args, **kwargs)
Overloaded function.
MakeA8(width: int, height: int) -> skia.ImageInfo
Creates
ImageInfo
from integral dimensions width and height,kAlpha_8_ColorType
,kPremul_AlphaType
, withColorSpace
set to nullptr.- width:
pixel column count; must be zero or greater
- height:
pixel row count; must be zero or greater
MakeA8(dimensions: skia.ISize) -> skia.ImageInfo
Creates
ImageInfo
from integral dimensions,kAlpha_8_ColorType
,kPremul_AlphaType
, withColorSpace
set to nullptr.- dimensions:
pixel row and column count; must be zero or greater
- static ImageInfo.MakeN32(width: int, height: int, at: skia.AlphaType, cs: skia.ColorSpace = None) skia.ImageInfo
Creates
ImageInfo
from integral dimensions width and height,kN32_ColorType
,AlphaType
at, and optionallyColorSpace
cs.kN32_ColorType
will equal eitherkBGRA_8888_ColorType
orkRGBA_8888_ColorType
, whichever is optimal.If
ColorSpace
cs is nullptr andImageInfo
is part of drawing source:ColorSpace
defaults to sRGB, mapping intoSurface
ColorSpace
.Parameters are not validated to see if their values are legal, or that the combination is supported.
- Parameters:
width (int) – pixel column count; must be zero or greater
height (int) – pixel row count; must be zero or greater
cs (skia.ColorSpace) – range of colors; may be nullptr
- Returns:
created
ImageInfo
- static ImageInfo.MakeN32Premul(*args, **kwargs)
Overloaded function.
MakeN32Premul(width: int, height: int, cs: skia.ColorSpace = None) -> skia.ImageInfo
Creates
ImageInfo
from integral dimensions width and height,kN32_ColorType
,kPremul_AlphaType
, with optionalColorSpace
.If
ColorSpace
cs is nullptr andImageInfo
is part of drawing source:ColorSpace
defaults to sRGB, mapping intoSurface
ColorSpace
.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
- return:
created
ImageInfo
MakeN32Premul(dimensions: skia.ISize, cs: skia.ColorSpace = None) -> skia.ImageInfo
Creates
ImageInfo
from integral dimensions width and height,kN32_ColorType
,kPremul_AlphaType
, with optionalColorSpace
.If
ColorSpace
cs is nullptr andImageInfo
is part of drawing source:ColorSpace
defaults to sRGB, mapping intoSurface
ColorSpace
.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
- return:
created
ImageInfo
- static ImageInfo.MakeS32(width: int, height: int, at: skia.AlphaType) skia.ImageInfo
Creates
ImageInfo
from integral dimensions width and height,kN32_ColorType
,AlphaType
at, with sRGBColorSpace
.Parameters are not validated to see if their values are legal, or that the combination is supported.
- Parameters:
width (int) – pixel column count; must be zero or greater
height (int) – pixel row count; must be zero or greater
- Returns:
created
ImageInfo
- static ImageInfo.MakeUnknown(*args, **kwargs)
Overloaded function.
MakeUnknown(width: int, height: int) -> skia.ImageInfo
Creates
ImageInfo
from integral dimensions width and height,kUnknown_ColorType
,kUnknown_AlphaType
, withColorSpace
set to nullptr.Returned
ImageInfo
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
- return:
created
ImageInfo
MakeUnknown() -> skia.ImageInfo
Creates
ImageInfo
from integral dimensions width and height set to zero,kUnknown_ColorType
,kUnknown_AlphaType
, withColorSpace
set to nullptr.Returned
ImageInfo
as part of source does not draw, and as part of destination can not be drawn to.- return:
created
ImageInfo
- ImageInfo.__init__(self: skia.ImageInfo) None
Creates an empty
ImageInfo
withkUnknown_ColorType
,kUnknown_AlphaType
, a width and height of zero, and noColorSpace
.
- ImageInfo.alphaType(self: skia.ImageInfo) skia.AlphaType
- ImageInfo.bounds(self: skia.ImageInfo) skia.IRect
- ImageInfo.bytesPerPixel(self: skia.ImageInfo) int
Returns number of bytes per pixel required by
ColorType
.Returns zero if
colorType()
iskUnknown_ColorType
.- Returns:
bytes in pixel
- ImageInfo.colorInfo(self: skia.ImageInfo) skia.ColorInfo
Returns the dimensionless
ColorInfo
that represents the same color type, alpha type, and color space as thisImageInfo
.
- ImageInfo.colorSpace(self: skia.ImageInfo) skia.ColorSpace
Returns
ColorSpace
, the range of colors.The reference count of
ColorSpace
is unchanged. The returnedColorSpace
is immutable.- Returns:
ColorSpace
, or nullptr
- ImageInfo.colorType(self: skia.ImageInfo) skia.ColorType
- ImageInfo.computeByteSize(self: skia.ImageInfo, rowBytes: int) int
Returns storage required by pixel array, given
ImageInfo
dimensions,ColorType
, 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:
rowBytes (int) – size of pixel row or larger
- Returns:
memory required by pixel buffer
- ImageInfo.computeMinByteSize(self: skia.ImageInfo) int
Returns storage required by pixel array, given
ImageInfo
dimensions, andColorType
.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.
- Returns:
least memory required by pixel buffer
- ImageInfo.computeOffset(self: skia.ImageInfo, x: int, y: int, rowBytes: int) int
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.
- ImageInfo.dimensions(self: skia.ImageInfo) skia.ISize
- ImageInfo.gammaCloseToSRGB(self: skia.ImageInfo) bool
Returns true if associated
ColorSpace
is not nullptr, andColorSpace
gamma is approximately the same as sRGB.- Returns:
true if
ColorSpace
gamma is approximately the same as sRGB
- ImageInfo.height(self: skia.ImageInfo) int
Returns pixel row count.
- Returns:
pixel height
- ImageInfo.isEmpty(self: skia.ImageInfo) bool
Returns if
ImageInfo
describes an empty area of pixels by checking if either width or height is zero or smaller.- Returns:
true if either dimension is zero or smaller
- ImageInfo.isOpaque(self: skia.ImageInfo) bool
Returns true if
AlphaType
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
ColorType
allows alpha, or if any pixel value has transparency.- Returns:
true if
AlphaType
iskOpaque_AlphaType
- ImageInfo.makeAlphaType(self: skia.ImageInfo, newAlphaType: skia.AlphaType) skia.ImageInfo
Creates
ImageInfo
with sameColorType
,ColorSpace
, width, and height, withAlphaType
set to newAlphaType.Created
ImageInfo
contains newAlphaType even if it is incompatible withColorType
, in which caseAlphaType
inImageInfo
is ignored.- Parameters:
newAlphaType (skia.AlphaType) – new alpha type
- Returns:
created
ImageInfo
- ImageInfo.makeColorSpace(self: skia.ImageInfo, cs: skia.ColorSpace) skia.ImageInfo
Creates
ImageInfo
with sameAlphaType
,ColorType
, width, and height, withColorSpace
set to cs.- Parameters:
cs (skia.ColorSpace) – range of colors; may be nullptr
- Returns:
created
ImageInfo
- ImageInfo.makeColorType(self: skia.ImageInfo, newColorType: skia.ColorType) skia.ImageInfo
Creates
ImageInfo
with sameAlphaType
,ColorSpace
, width, and height, withColorType
set to newColorType.- Parameters:
newColorType (skia.ColorType) – new color type
- Returns:
created
ImageInfo
- ImageInfo.makeDimensions(self: skia.ImageInfo, newSize: skia.ISize) skia.ImageInfo
Creates
ImageInfo
with the sameColorType
,ColorSpace
, andAlphaType
, with dimensions set to newDimensions.- Parameters:
newSize (skia.ISize) – pixel column and row count; must be zero or greater
- Returns:
created
ImageInfo
- ImageInfo.makeWH(self: skia.ImageInfo, newWidth: int, newHeight: int) skia.ImageInfo
Creates
ImageInfo
with the sameColorType
,ColorSpace
, andAlphaType
, with dimensions set to width and height.- Parameters:
newWidth (int) – pixel column count; must be zero or greater
newHeight (int) – pixel row count; must be zero or greater
- Returns:
created
ImageInfo
- ImageInfo.minRowBytes(self: skia.ImageInfo) int
Returns minimum bytes per row, computed from pixel
width()
andColorType
, which specifiesbytesPerPixel()
.Bitmap
maximum value for row bytes must fit in 31 bits.- Returns:
width()
timesbytesPerPixel()
as signed 32-bit integer
- ImageInfo.minRowBytes64(self: skia.ImageInfo) int
Returns minimum bytes per row, computed from pixel
width()
andColorType
, which specifiesbytesPerPixel()
.Bitmap
maximum value for row bytes must fit in 31 bits.- Returns:
width()
timesbytesPerPixel()
as unsigned 64-bit integer
- ImageInfo.refColorSpace(self: skia.ImageInfo) skia.ColorSpace
Returns smart pointer to
ColorSpace
, the range of colors.The smart pointer tracks the number of objects sharing this
ColorSpace
reference so the memory is released when the owners destruct.The returned
ColorSpace
is immutable.- Returns:
ColorSpace
wrapped in a smart pointer
- ImageInfo.reset(self: skia.ImageInfo) None
Creates an empty
ImageInfo
withkUnknown_ColorType
,kUnknown_AlphaType
, a width and height of zero, and noColorSpace
.
- ImageInfo.shiftPerPixel(self: skia.ImageInfo) int
Returns bit shift converting row bytes to row pixels.
Returns zero for
skia.ColorType.kUnknown_ColorType
.- Returns:
one of: 0, 1, 2, 3; left shift to convert pixels to bytes
- ImageInfo.validRowBytes(self: skia.ImageInfo, rowBytes: int) bool
Returns true if rowBytes is valid for this
ImageInfo
.- Parameters:
rowBytes (int) – size of pixel row including padding
- Returns:
true if rowBytes is large enough to contain pixel row and is properly aligned
- ImageInfo.width(self: skia.ImageInfo) int
Returns pixel count in each row.
- Returns:
pixel width