Static Methodswift-png 4.4.5PNG
unpack(_:of:deindexer:)
Unpacks an image data storage buffer to an array of RGBA pixels.
PNG.RGBA.swift:259static func unpack(_ interleaved: [UInt8], of format: PNG.Format, deindexer: ([(r: UInt8, g: UInt8, b: UInt8, a: UInt8)]) -> (Int) -> Aggregate) -> [`Self`]
Parameters
- interleaved
An image data buffer. It is expected to be obtained from the
storage
property of aImage
image.- format
The color format associated with the given data buffer. It is expected to be obtained from the the
layout.format
property of aImage
image.- deindexer
A function which uses the palette entries in the color
format
to generate a dereferencing function. This function is only invoked if the colorformat
is an indexed format. Its palette aggregates will be interpreted as (red, green, blue, alpha) quadruplets.
Returns
An array of RGBA pixels. The pixels appear in the same order as they do in the image data buffer.
For a grayscale color format
, this function expands pixels of the form (v) to RGBA quadruplets (v, v, v, T.max
).
For a grayscale-alpha color format
, this function expands pixels of the form (v, a) to RGBA quadruplets (v, v, v, a).
For an RGB color format
, this function expands pixels of the form (r, g, b) to RGBA quadruplets (r, g, b, T.max
).
For a BGR color format
, this function expands pixels of the form (b, g, r) to RGBA quadruplets (r, g, b, T.max
).
For a BGRA color format
, this function shuffles pixels of the form (b, g, r, a) into RGBA quadruplets (r, g, b, a).
This function will apply chroma keys if present. The unpacked components are scaled to fill the range of T
, according to the color depth computed from the color format
.
See the indexed color tutorial for more about the semantics of this function.
Other members in extension
Typealiases
typealias Aggregate
Palette aggregates are (red, green, blue, alpha) quadruplets.
Type members
init(PNG.VA<T>
) Creates an RGBA color from a grayscale-alpha color.
init(T
) Creates an opaque, monochromatic RGBA color.
init(T, T
) Creates a monochromatic RGBA color.
init(T, T, T
) Creates an opaque RGBA color.
init(T, T, T, T
) Creates an RGBA color.
static func pack([`Self`], as: PNG.Format, indexer: ([(r: UInt8, g: UInt8, b: UInt8, a: UInt8)]) -> (Aggregate) -> Int
) -> [UInt8] Packs an array of RGBA pixels to an image data storage buffer.
Instance members
var premultiplied: `Self`
The color obtained by premultiplying the red, green, and blue components of this color with its alpha channel.
var straightened: `Self`
The color obtained by straightening the red, green, and blue components of this color according to its alpha channel.
var va: PNG.VA<T>
The grayscale-alpha color obtained by discarding the green and blue components of this color.
func premultiplied<U>(as: U.Type
) -> PNG.RGBA<T> The color obtained by premultiplying the red, green, and blue components of this color with its alpha channel, performing the premultiplication in the given integer type.
func straightened<U>(as: U.Type
) -> PNG.RGBA<T> The color obtained by straightening the red, green, and blue components of this color according to its alpha channel, performing the straightening in the given integer type.