Initializerswift-png 4.4.5PNG
init(case:pixel:palette:)
Creates a transparency descriptor.
PNG.Transparency.swift:56init(case: Case, pixel: PNG.Format.Pixel, palette: PNG.Palette?)
Parameters
- case
A transparency descriptor value.
If this parameter is a
v(key:)
orrgb(key:)
case, the samples in its chroma key payload must fall within the range determined by the image color depth. Passing an enumeration case with an invalid chroma key sample will result in a precondition failure.- pixel
The pixel format of the image this transparency descriptor is to be used for. Passing a mismatched enumeration
case
will result in a precondition failure.Transparency descriptors are not allowed for grayscale-alpha or RGBA images, so setting
pixel
to one of those pixel formats will always result in a precondition failure.- palette
The palette of the image this transparency descriptor is to be used for.
If
case
is apalette(alpha:)
case, this palette must not benil
, and must contain at least as many entries as the number of alpha samples in thepalette(alpha:)
payload. Otherwise, this initializer will suffer a precondition failure.If
case
is av(key:)
orrgb(key:)
case, this parameter is ignored.
This initializer validates the transparency information against the given pixel format and image palette. Some pixel
formats imply that palette
must be nil
. This initializer does not check this assumption, as it is expected to have been verified by Palette.init(entries:pixel:)
.
Other members in extension
Types
enum Case
A transparency case. This is a separate type for validation purposes.
Type members
init(parsing: [UInt8], pixel: PNG.Format.Pixel, palette: PNG.Palette?
) throws Creates a transparency descriptor by parsing the given chunk data, interpreting and validating it according to the given
pixel
format and imagepalette
.
Instance members
let `case`: Case
The value of this transparency descriptor.
var serialized: [UInt8]
Encodes this transparency descriptor as the contents of a
tRNS
chunk.