Initializerswift-png 4.4.5PNG
init(case:pixel:palette:)
Creates a background descriptor.
PNG.Background.swift:53init(case: Case, pixel: PNG.Format.Pixel, palette: PNG.Palette?)
Parameters
- case
A background descriptor value.
If this parameter is a
v(_:)
orrgb(_:)
case, the samples in its background color payload must fall within the range determined by the image color depth. Passing an enumeration case with an invalid background sample will result in a precondition failure.- pixel
The pixel format of the image this background descriptor is to be used for. Passing a mismatched enumeration
case
will result in a precondition failure.- palette
The palette of the image this background descriptor is to be used for.
If
case
is apalette(index:)
case, this palette must not benil
, and the number of entries in it must be at least1
greater than the value of thepalette(index:)
payload. If the index payload is out of range, this function will suffer a precondition failure.If
case
is av(_:)
orrgb(_:)
case, this parameter is ignored.
This initializer validates the background 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 background case. This is a separate type for validation purposes.
Type members
init(parsing: [UInt8], pixel: PNG.Format.Pixel, palette: PNG.Palette?
) throws Creates a background 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 background descriptor.
var serialized: [UInt8]
Encodes this background descriptor as the contents of a
bKGD
chunk.