Static Methodswift-png 4.4.5PNG

    convolve(_:dereference:kernel:)

    Converts an image data buffer to a pixel array, using the given pixel kernel and dereferencing function.

    PNG.swift:387
    static func convolve<A, T, C>(_ buffer: [UInt8], dereference: (Int) -> (A, A, A), kernel: ((T, T, T)) -> C) -> [C] where A : FixedWidthInteger, A : UnsignedInteger, T : FixedWidthInteger, T : UnsignedInteger

    Parameters

    buffer

    An image data buffer.

    dereference

    A dereferencing function.

    kernel

    A pixel kernel.

    Returns

    An array of pixels constructed by the given kernel function. This array has the same number of elements as buffer.

    This function casts each byte in buffer to an Int index, and passes each index to the given dereference function, receiving triplets of atoms of type A in return. It then scales the atoms to the range of T, and constructs instances of C by mapping the given kernel function over each (T, T, T) triplet.

    A worked example of how to use this function to implement a custom color target can be found in the custom color targets tutorial.

    Other members in extension

    Protocols

    Types

    Show obsolete interfaces (2)

    Hide obsolete interfaces

    Type members