Expand description
QOI descriptor value.
This value is parsed from image header during decoding.
Or provided by caller to drive encoding.
Fields
width: u32
Width of the image in pixels.
height: u32
Height of the image in pixels.
colors: Colors
Specifies image color space.
Implementations
sourceimpl Qoi
impl Qoi
sourcepub fn decoded_size(&self) -> usize
pub fn decoded_size(&self) -> usize
Returns bytes size for the decoded image.
sourcepub fn decode_header(bytes: &[u8]) -> Result<Self, DecodeError>
pub fn decode_header(bytes: &[u8]) -> Result<Self, DecodeError>
Reads header from encoded QOI image.
Returned header can be analyzed before proceeding parsing with Qoi::decode_skip_header
.
sourcepub fn decode(bytes: &[u8], output: &mut [u8]) -> Result<Self, DecodeError>
pub fn decode(bytes: &[u8], output: &mut [u8]) -> Result<Self, DecodeError>
Decode a QOI image from bytes slice.
Decoded raw RGB or RGBA pixels are written into output
slice.
On success this function returns Ok(qoi)
with qoi
describing image dimensions and color space.
On failure this function returns Err(err)
with err
describing cause of the error.
sourcepub fn decode_skip_header(
&self,
bytes: &[u8],
output: &mut [u8]
) -> Result<(), DecodeError>
pub fn decode_skip_header(
&self,
bytes: &[u8],
output: &mut [u8]
) -> Result<(), DecodeError>
Decode a QOI image from bytes slice.
bytes
does not include QOI header. Uses provided Qoi
value instead.
Decoded raw RGB or RGBA (depending on self.colors
value) pixels are written into output
slice.
On success this function returns Ok(())
.
On failure this function returns Err(err)
with err
describing cause of the error.
sourcepub fn decode_range<const N: usize>(
index: &mut [[u8; N]; 64],
ppx: &mut [u8; N],
prun: &mut usize,
bytes: &[u8],
pixels: &mut [u8]
) -> Result<usize, DecodeError> where
[u8; N]: Pixel,
pub fn decode_range<const N: usize>(
index: &mut [[u8; N]; 64],
ppx: &mut [u8; N],
prun: &mut usize,
bytes: &[u8],
pixels: &mut [u8]
) -> Result<usize, DecodeError> where
[u8; N]: Pixel,
Decode range of pixels into pixels slice.
sourcepub fn decode_alloc(bytes: &[u8]) -> Result<(Self, Vec<u8>), DecodeError>
pub fn decode_alloc(bytes: &[u8]) -> Result<(Self, Vec<u8>), DecodeError>
Decode a QOI image from bytes slice.
Decoded raw RGB or RGBA pixels are written into allocated Vec
.
On success this function returns Ok((qoi, vec))
with qoi
describing image dimensions and color space and vec
containing raw pixels data.
On failure this function returns Err(err)
with err
describing cause of the error.
sourceimpl Qoi
impl Qoi
sourcepub fn encode(
&self,
pixels: &[u8],
output: &mut [u8]
) -> Result<usize, EncodeError>
pub fn encode(
&self,
pixels: &[u8],
output: &mut [u8]
) -> Result<usize, EncodeError>
Encode raw RGB or RGBA pixels into a QOI image.
Encoded image is written into output
slice.
On success this function returns Ok(())
.
On failure this function returns Err(err)
with err
describing cause of the error.
sourcepub fn encode_range<const N: usize>(
index: &mut [[u8; N]; 64],
px_prev: &mut [u8; N],
run: &mut usize,
pixels: &[u8],
output: &mut [u8]
) -> Result<usize, EncodeError> where
[u8; N]: Pixel,
pub fn encode_range<const N: usize>(
index: &mut [[u8; N]; 64],
px_prev: &mut [u8; N],
run: &mut usize,
pixels: &[u8],
output: &mut [u8]
) -> Result<usize, EncodeError> where
[u8; N]: Pixel,
Encode range of pixels into output slice.
sourcepub fn encoded_size_limit(&self) -> usize
pub fn encoded_size_limit(&self) -> usize
Returns maximum size of the Qoi::encode
output size.
Using smaller slice may cause Qoi::encode
to return Err(EncodeError::OutputIsTooSmall)
.
sourcepub fn encode_alloc(&self, pixels: &[u8]) -> Result<Vec<u8>, EncodeError>
pub fn encode_alloc(&self, pixels: &[u8]) -> Result<Vec<u8>, EncodeError>
Encode raw RGB or RGBA pixels into a QOI image.
Encoded image is written into allocated Vec
.
On success this function returns Ok(vec)
with vec
containing encoded image.
On failure this function returns Err(err)
with err
describing cause of the error.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Qoi
impl Send for Qoi
impl Sync for Qoi
impl Unpin for Qoi
impl UnwindSafe for Qoi
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more