init(packing:size:layout:metadata:)

    Creates an image from a pixel array.

    PNG.Image.swift:1034
    init<Color>(packing pixels: [Color], size: (x: Int, y: Int), layout: PNG.Layout, metadata: PNG.Metadata = .init()) where Color : PNG.Color

    Parameters

    pixels

    A pixel array. Its elements are arranged in row-major order. The first pixel in this array corresponds to the top-left corner of the image. The Color type provides the pack(_:as:) implementation used to pack the image data.

    The length of this array must match size.x * size.y. Passing an array of the wrong length will result in a precondition failure.

    size

    The size of the image. Both dimensions must be greater than zero. Passing an invalid image size will result in a precondition failure.

    layout

    An image layout.

    metadata

    A metadata structure. The default value is an empty metadata structure.

    Other members in extension

    Type members

    Instance members