ImageInfo

public struct ImageInfo

Describes pixel dimensions and encoding. Bitmap, Image, Pixmap, and Surface can be created from ImageInfo. ImageInfo 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 ImageInfo.

ImageInfo contains dimensions, the pixel integral width and height. It encodes how pixel bits describe alpha, transparency; color components red, blue, and green; and ColorSpace, the range and linearity of colors.

  • Returns pixel count in each row.

    Declaration

    Swift

    public var width: Int32
  • Returns pixel row count (height)

    Declaration

    Swift

    public var height: Int32
  • Returns the colortype for this ImageInfo

    Declaration

    Swift

    public var colorType: ColorType
  • Returns the alpha type

    Declaration

    Swift

    public var alphaType: AlphaType
  • Returns SkColorSpace, the range of colors - the returned value is immutable

    Declaration

    Swift

    public var colorSpace: ColorSpace?
  • Creates ImageInfo from integral dimensions width and height, ColorType, AlphaType, and optionally `ColorSpace.

    If ColorSpace cs is nil and ImageInfo is part of drawing source: ColorSpace defaults to sRGB, mapping into Surface ColorSpace.

    Parameters are not validated to see if their values are legal, or that the combination is supported.

    Declaration

    Swift

    public init(width: Int32, height: Int32, colorType: ColorType, alphaType: AlphaType, colorSpace: ColorSpace? = nil)

    Parameters

    width

    pixel column count; must be zero or greater

    height

    pixel row count; must be zero or greater

    colorType

    the colortype

    alphaType

    the alpha type

    colorSpace

    range of colors; may be nil

    Return Value

    created ImageInfo

  • Creates ImageInfo from integral dimensions width and height The returned imageInfo sets the colorType to the default platform color type (rgb8888) and the alphaType is set to .premul and the colorspace is set to nil

    Parameters are not validated to see if their values are legal, or that the combination is supported.

    Declaration

    Swift

    public init(_ width: Int32, _ height: Int32)

    Return Value

    created ImageInfo

  • Returns number of bytes per pixel required by the colorType (1, 2, 4 or 8 bytes) or zero if the colorType is set to .unknown

    Declaration

    Swift

    public var bytesPerPixel: Int32 { get }
  • Number of bits used by the colorType (this is bytesPerPixel multiplied by 8)

    Declaration

    Swift

    public var bitsPerPixel: Int32 { get }
  • Returns the number of bytes necesary to allocate the image of the widthxheight that uses bytesPerPixel to store the data.

    Declaration

    Swift

    public var bytesSize: Int { get }
  • Returns the number of bytes necessary to store one row of pixels

    Declaration

    Swift

    public var rowBytes: Int { get }
  • Returns if ImageInfo describes an empty area of pixels by checking if either width or height is zero or smaller.

    Declaration

    Swift

    public var isEmpty: Bool { get }
  • 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.

    Declaration

    Swift

    public var isOpaque: Bool { get }
  • Returns a new ImageInfo instance that has the width and height changed per the specified parameters

    Declaration

    Swift

    public func withDimensions(width: Int32, height: Int32) -> ImageInfo
  • Returns a new ImageInfo instance that has the colorType changed with the specified parameter

    Declaration

    Swift

    public func withColorType(_ colorType: ColorType) -> ImageInfo
  • Returns a new ImageInfo instance that has the colorSpace changed with the specified parameter

    Declaration

    Swift

    public func withColorSpace(_ colorSpace: ColorSpace?) -> ImageInfo
  • Returns a new ImageInfo instance that has the colorSpace changed with the specified parameter

    Declaration

    Swift

    public func withAlphaType(_ alphaType: AlphaType) -> ImageInfo