[go: up one dir, main page]

Struct qoi::Decoder[][src]

pub struct Decoder<R> { /* fields omitted */ }
Expand description

Decode QOI images from slices or from streams.

Implementations

Creates a new decoder from a slice of bytes.

The header will be decoded immediately upon construction.

Note: this provides the most efficient decoding, but requires the source data to be loaded in memory in order to decode it. In order to decode from a generic stream, use Decoder::from_stream instead.

Returns the undecoded tail of the input slice of bytes.

Creates a new decoder from a generic reader that implements Read.

The header will be decoded immediately upon construction.

Note: while it’s possible to pass a &[u8] slice here since it implements Read, it would be more efficient to use a specialized constructor instead: Decoder::new.

Returns an immutable reference to the underlying reader.

Consumes the decoder and returns the underlying reader back.

Returns a new decoder with modified number of channels.

By default, the number of channels in the decoded image will be equal to whatever is specified in the header. However, it is also possible to decode RGB into RGBA (in which case the alpha channel will be set to 255), and vice versa (in which case the alpha channel will be ignored).

Returns the number of channels in the decoded image.

Note: this may differ from the number of channels specified in the header.

Returns the decoded image header.

The number of bytes the decoded image will take.

Can be used to pre-allocate the buffer to decode the image into.

Decodes the image to a pre-allocated buffer and returns the number of bytes written.

The minimum size of the buffer can be found via Decoder::required_buf_len.

Decodes the image into a newly allocated vector of bytes and returns it.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.