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:154static func pack(_ pixels: [Self], as format: PNG.Format) -> [UInt8]
Parameters
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
associatedtype Aggregate
A palette aggregate type.
static func pack([Self], as: PNG.Format, indexer: ([(r: UInt8, g: UInt8, b: UInt8, a: UInt8)]) -> (Aggregate) -> Int
) -> [UInt8] Packs an array of this color target to an image data storage buffer, using a custom indexing function.
static func unpack([UInt8], of: PNG.Format
) -> [Self] Unpacks an image data storage buffer to an array of this color target.
static func unpack([UInt8], of: PNG.Format, deindexer: ([(r: UInt8, g: UInt8, b: UInt8, a: UInt8)]) -> (Int) -> Aggregate
) -> [Self] Unpacks an image data storage buffer to an array of this color target, using a custom deindexing function.