Struct png_framing::Png [] [src]

pub struct Png<T> { /* fields omitted */ }

A raw RGBA image that can be converted easily to/from a PNG.

Methods

impl Png<Native>
[src]

Decodes the image which has been encoded in the given bytes.

Loads the PNG at the given file path.

impl<T> Png<T>
[src]

Borrows the buffer that the PNG was created with.

Recovers the buffer that the PNG was created with.

This operation destroys the PNG, since mutations to the buffer could alter the length of the buffer, and thus lead to undefined behavior.

impl<T> Png<T> where
    T: AsRef<[u8]>, 
[src]

Creates a new PNG given the width, height, and raw RGBA image data.

Panics

Panics if the buffer's length is not exactly width * height * 4.

Saves the PNG to the given file path.

Any existing file at the path will be overwritten. This is basically the same as encoding the image and writing it yourself, but is a lot more convenient.

Encodes the PNG, allocating the necessary memory for the encoded data.

The output is an array of bytes with the compressed PNG data, suitable for sending over a network or writing to a file.

impl Png<Bytes>
[src]

Creates a new image from the given frame.

Note that this function allocates, since the underlying library, lodepng, can unfortunately only operate on a contiguous buffer. Maybe when I get good enough to write my own encoder, this won't have to allocate any memory.

Trait Implementations

impl From<ChunkyFrame<Rgba>> for Png<Bytes>
[src]

Performs the conversion.

impl<T> AsRef<[u8]> for Png<T> where
    T: AsRef<[u8]>, 
[src]

Performs the conversion.

impl<T> AsMut<[u8]> for Png<T> where
    T: AsMut<[u8]>, 
[src]

Performs the conversion.

impl<T> VideoFrame for Png<T> where
    T: AsRef<[u8]>, 
[src]

The kind of pixel that the frame is made of.

The width of the frame in pixels.

The height of the frame in pixels.

Gets the pixel at the specified zero-indexed coordinates. Read more