Required Static Methodswift-png 4.4.5PNG

    pack(_:as:)

    Packs an array of this color target to an image data storage buffer.

    PNG.Color.swift:154
    static func pack(_ pixels: [Self], as format: PNG.Format) -> [UInt8]

    Parameters

    pixels

    A pixel array containing instances of this color target.

    format

    The color format to pack the given pixels as in the returned data buffer.

    When the library uses an implementation of this function to construct a Image image, this color format will be stored in its format property.

    Returns

    An image data buffer. The packed samples in this buffer should appear in the same order as the pixels in the pixels array. (But not necessarily in the same order within each individual pixel.)

    When the library uses an implementation of this function to construct a Image image, this data buffer will be stored in its storage property.

    If Aggregate is (UInt8, UInt8), the default implementation of this function will search for a matching palette entry by treating the first member of the palette aggregate as the red, green, and blue components, and the second member as the alpha component, when packing to an indexed color format.

    If Aggregate is (UInt8, UInt8, UInt8, UInt8), the default implementation of this function will search for a matching palette entry by treating the first member of the palette aggregate as the red component, the second member as the green component, the third member as the blue component, and the fourth member as the alpha component, when packing to an indexed color format.

    In either case, if more than one palette entry matches, the matching entry is chosen arbitrarily. If there is no matching palette entry, it chooses the first palette entry.

    See the indexed color tutorial for more about the semantics of the default implementations.

    Other requirements

    Type members

    Citizens in PNG

    Default implementations