Static Methodswift-png 4.4.5PNG
decompress(path:)
Decompresses and decodes a PNG from a file at the given file path.
System.swift:249static func decompress(path: String) throws -> `Self`?
Parameters
- path
A path to a PNG file.
Returns
The decoded image, or nil
if the file at the given path
could not be opened.
This interface is only available on MacOS and Linux. The decompress(stream:)
function provides a platform-independent decoding interface.
Other members in extension
Type members
init<Color>(packing: [Color], size: (x: Int, y: Int), layout: PNG.Layout, metadata: PNG.Metadata
) Creates an image from a pixel array.
init<T>(packing: [T], size: (x: Int, y: Int), layout: PNG.Layout, metadata: PNG.Metadata
) Creates an image from a scalar pixel array.
init<Color>(packing: [Color], size: (x: Int, y: Int), layout: PNG.Layout, metadata: PNG.Metadata, indexer: ([(r: UInt8, g: UInt8, b: UInt8, a: UInt8)]) -> (Color.Aggregate) -> Int
) Creates an image from a pixel array, using a custom indexing function.
init<T>(packing: [T], size: (x: Int, y: Int), layout: PNG.Layout, metadata: PNG.Metadata, indexer: ([(r: UInt8, g: UInt8, b: UInt8, a: UInt8)]) -> (UInt8) -> Int
) Creates an image from a scalar pixel array, using a custom indexing function.
static func decompress<Source>(stream: inout Source
) throws -> PNG.Image Decompresses and decodes a PNG from the given bytestream.
Instance members
let layout: PNG.Layout
The layout of this image.
var metadata: PNG.Metadata
The metadata in this image.
let size: (x: Int, y: Int)
The size of this image, measured in pixels.
var storage: [UInt8]
The raw backing storage of the image content.
func bindStorage(to: PNG.Layout
) -> PNG.Image Rebinds this image to a compatible layout.
func compress(path: String, level: Int, hint: Int
) throws -> Void? Encodes and compresses a PNG to a file at the given file path.
func compress<Destination>(stream: inout Destination, level: Int, hint: Int
) throws Encodes and compresses a PNG to the given bytestream.
func unpack<Color>(as: Color.Type
) -> [Color] Unpacks this image to a pixel array.
func unpack<T>(as: T.Type
) -> [T] Unpacks this image to a scalar pixel array.
func unpack<Color>(as: Color.Type, deindexer: ([(r: UInt8, g: UInt8, b: UInt8, a: UInt8)]) -> (Int) -> Color.Aggregate
) -> [Color] Unpacks this image to a pixel array, using a custom deindexing function.
func unpack<T>(as: T.Type, deindexer: ([(r: UInt8, g: UInt8, b: UInt8, a: UInt8)]) -> (Int) -> UInt8
) -> [T] Unpacks this image to a scalar pixel array, using a custom deindexing function.