ImageInfo
- class ImageInfo
Describes pixel dimensions and encoding.
Bitmap,Image,Pixmap, andSurfacecan be created fromImageInfo.ImageInfocan be retrieved fromBitmapandPixmap, but not fromImageandSurface. For example,ImageandSurfaceimplementations may defer pixel depth, so may not completely specifyImageInfo.ImageInfocontains 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
ByteSizeOverflowed(byteSize: int) -> bool
MakeN32(width: int, height: int, at: skia.AlphaType, cs: skia.ColorSpace = None) -> skia.ImageInfo
MakeS32(width: int, height: int, at: skia.AlphaType) -> skia.ImageInfo
__init__(self: skia.ImageInfo) -> None
alphaType(self: skia.ImageInfo) -> skia.AlphaType
bounds(self: skia.ImageInfo) -> skia.IRect
bytesPerPixel(self: skia.ImageInfo) -> int
colorInfo(self: skia.ImageInfo) -> skia.ColorInfo
colorSpace(self: skia.ImageInfo) -> skia.ColorSpace
colorType(self: skia.ImageInfo) -> skia.ColorType
computeByteSize(self: skia.ImageInfo, rowBytes: int) -> int
computeMinByteSize(self: skia.ImageInfo) -> int
computeOffset(self: skia.ImageInfo, x: int, y: int, rowBytes: int) -> int
dimensions(self: skia.ImageInfo) -> skia.ISize
gammaCloseToSRGB(self: skia.ImageInfo) -> bool
height(self: skia.ImageInfo) -> int
isEmpty(self: skia.ImageInfo) -> bool
isOpaque(self: skia.ImageInfo) -> bool
makeAlphaType(self: skia.ImageInfo, newAlphaType: skia.AlphaType) -> skia.ImageInfo
makeColorSpace(self: skia.ImageInfo, cs: skia.ColorSpace) -> skia.ImageInfo
makeColorType(self: skia.ImageInfo, newColorType: skia.ColorType) -> skia.ImageInfo
makeDimensions(self: skia.ImageInfo, newSize: skia.ISize) -> skia.ImageInfo
makeWH(self: skia.ImageInfo, newWidth: int, newHeight: int) -> skia.ImageInfo
minRowBytes(self: skia.ImageInfo) -> int
minRowBytes64(self: skia.ImageInfo) -> int
refColorSpace(self: skia.ImageInfo) -> skia.ColorSpace
reset(self: skia.ImageInfo) -> None
shiftPerPixel(self: skia.ImageInfo) -> int
validRowBytes(self: skia.ImageInfo, rowBytes: int) -> bool
width(self: skia.ImageInfo) -> int
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
ImageInfofrom integral dimensions width and height,ColorTypect,AlphaTypeat, and optionallyColorSpacecs.If
ColorSpacecs is nullptr andImageInfois part of drawing source:ColorSpacedefaults to sRGB, mapping intoSurfaceColorSpace.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
ImageInfofrom integral dimensions andColorInfocolorInfo,.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:
ColorInfothe 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
ImageInfofrom integral dimensions width and height,kAlpha_8_ColorType,kPremul_AlphaType, withColorSpaceset 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
ImageInfofrom integral dimensions,kAlpha_8_ColorType,kPremul_AlphaType, withColorSpaceset 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
ImageInfofrom integral dimensions width and height,kN32_ColorType,AlphaTypeat, and optionallyColorSpacecs.kN32_ColorTypewill equal eitherkBGRA_8888_ColorTypeorkRGBA_8888_ColorType, whichever is optimal.If
ColorSpacecs is nullptr andImageInfois part of drawing source:ColorSpacedefaults to sRGB, mapping intoSurfaceColorSpace.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
ImageInfofrom integral dimensions width and height,kN32_ColorType,kPremul_AlphaType, with optionalColorSpace.If
ColorSpacecs is nullptr andImageInfois part of drawing source:ColorSpacedefaults to sRGB, mapping intoSurfaceColorSpace.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
ImageInfofrom integral dimensions width and height,kN32_ColorType,kPremul_AlphaType, with optionalColorSpace.If
ColorSpacecs is nullptr andImageInfois part of drawing source:ColorSpacedefaults to sRGB, mapping intoSurfaceColorSpace.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
ImageInfofrom integral dimensions width and height,kN32_ColorType,AlphaTypeat, 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
ImageInfofrom integral dimensions width and height,kUnknown_ColorType,kUnknown_AlphaType, withColorSpaceset to nullptr.Returned
ImageInfoas 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
ImageInfofrom integral dimensions width and height set to zero,kUnknown_ColorType,kUnknown_AlphaType, withColorSpaceset to nullptr.Returned
ImageInfoas 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
ImageInfowithkUnknown_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
ColorInfothat 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
ColorSpaceis unchanged. The returnedColorSpaceis 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
ImageInfodimensions,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
ImageInfodimensions, 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
ColorSpaceis not nullptr, andColorSpacegamma is approximately the same as sRGB.- Returns:
true if
ColorSpacegamma 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
ImageInfodescribes 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
AlphaTypeis 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
ColorTypeallows alpha, or if any pixel value has transparency.- Returns:
true if
AlphaTypeiskOpaque_AlphaType
- ImageInfo.makeAlphaType(self: skia.ImageInfo, newAlphaType: skia.AlphaType) skia.ImageInfo
Creates
ImageInfowith sameColorType,ColorSpace, width, and height, withAlphaTypeset to newAlphaType.Created
ImageInfocontains newAlphaType even if it is incompatible withColorType, in which caseAlphaTypeinImageInfois ignored.- Parameters:
newAlphaType (skia.AlphaType) – new alpha type
- Returns:
created
ImageInfo
- ImageInfo.makeColorSpace(self: skia.ImageInfo, cs: skia.ColorSpace) skia.ImageInfo
Creates
ImageInfowith sameAlphaType,ColorType, width, and height, withColorSpaceset 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
ImageInfowith sameAlphaType,ColorSpace, width, and height, withColorTypeset to newColorType.- Parameters:
newColorType (skia.ColorType) – new color type
- Returns:
created
ImageInfo
- ImageInfo.makeDimensions(self: skia.ImageInfo, newSize: skia.ISize) skia.ImageInfo
Creates
ImageInfowith 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
ImageInfowith 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().Bitmapmaximum 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().Bitmapmaximum 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
ColorSpacereference so the memory is released when the owners destruct.The returned
ColorSpaceis immutable.- Returns:
ColorSpacewrapped in a smart pointer
- ImageInfo.reset(self: skia.ImageInfo) None
Creates an empty
ImageInfowithkUnknown_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