Instance Methodswift-png 4.4.5PNG

    unpack(as:deindexer:)

    Unpacks this image to a scalar pixel array, using a custom deindexing function.

    PNG.Image.swift:902
    func unpack<T>(as _: T.Type, deindexer: ([(r: UInt8, g: UInt8, b: UInt8, a: UInt8)]) -> (Int) -> UInt8) -> [T] where T : FixedWidthInteger, T : UnsignedInteger

    Parameters

    _

    A scalar color target type.

    deindexer

    A function which uses the palette entries in the color format to generate a dereferencing function. This function will only be invoked if layout.format is an indexed format.

    See the indexed color tutorial for more about the semantics of this function.

    Returns

    A scalar pixel array. Its elements are arranged in row-major order. The first pixel in this array corresponds to the top-left corner of the image. Its length is equal to size.x multiplied by size.y.

    For an image with a grayscale-alpha color format, this function selects the v component from pixels of the form (v, a)

    For an image with an RGB color format, this function selects the r component from pixels of the form (r, g, b).

    For an image with an RGBA color format, this function selects the r component from pixels of the form (r, g, b, a).

    For an image with a BGR color format, this function selects the r component from pixels of the form (b, g, r).

    For an image with a BGRA color format, this function selects the r component from pixels of the form (b, g, r, a).

    This function ignores chroma keys, as its scalar color target is not capable of representing transparency. The unpacked components are scaled to fill the range of T, according to the color depth computed from the color format.

    Other members in extension

    Type members

    Instance members