Skip to main content

ImageDecode

Trait ImageDecode 

Source
pub trait ImageDecode<'a>:
    ImageCodec
    + Sized
    + 'a {
    type View: 'a;

    // Required methods
    fn inspect(input: &'a [u8]) -> Result<Info, Self::Error>;
    fn parse(input: &'a [u8]) -> Result<Self::View, Self::Error>;
    fn from_view(view: Self::View) -> Result<Self, Self::Error>;
    fn decode_into(
        &mut self,
        out: &mut [u8],
        stride: usize,
        fmt: PixelFormat,
    ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>;
    fn decode_into_with_scratch(
        &mut self,
        pool: &mut Self::Pool,
        out: &mut [u8],
        stride: usize,
        fmt: PixelFormat,
    ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>;
    fn decode_region_into(
        &mut self,
        pool: &mut Self::Pool,
        out: &mut [u8],
        stride: usize,
        fmt: PixelFormat,
        roi: Rect,
    ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>;
    fn decode_scaled_into(
        &mut self,
        pool: &mut Self::Pool,
        out: &mut [u8],
        stride: usize,
        fmt: PixelFormat,
        scale: Downscale,
    ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>;
    fn decode_region_scaled_into(
        &mut self,
        pool: &mut Self::Pool,
        out: &mut [u8],
        stride: usize,
        fmt: PixelFormat,
        roi: Rect,
        scale: Downscale,
    ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>;
}
Expand description

Borrowed-image decode API for codecs that parse compressed bytes directly.

Required Associated Types§

Source

type View: 'a

Borrowed parse product that can later construct a decoder.

Required Methods§

Source

fn inspect(input: &'a [u8]) -> Result<Info, Self::Error>

Inspect metadata without decoding pixels.

§Errors

Returns the codec-specific ImageCodec::Error when the compressed input is invalid or unsupported.

Source

fn parse(input: &'a [u8]) -> Result<Self::View, Self::Error>

Parse compressed bytes into a borrowed view.

§Errors

Returns the codec-specific ImageCodec::Error when the compressed input cannot be parsed.

Source

fn from_view(view: Self::View) -> Result<Self, Self::Error>

Build a decoder from a parsed view.

§Errors

Returns the codec-specific ImageCodec::Error when the parsed view is unsupported or inconsistent.

Source

fn decode_into( &mut self, out: &mut [u8], stride: usize, fmt: PixelFormat, ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>

Decode the full image into caller-owned output.

§Errors

Returns the codec-specific ImageCodec::Error for invalid input, unsupported output, or an undersized or invalid output layout.

Source

fn decode_into_with_scratch( &mut self, pool: &mut Self::Pool, out: &mut [u8], stride: usize, fmt: PixelFormat, ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>

Decode the full image into caller-owned output with reusable scratch.

§Errors

Returns the codec-specific ImageCodec::Error for invalid input, unsupported output, scratch failure, or an invalid output layout.

Source

fn decode_region_into( &mut self, pool: &mut Self::Pool, out: &mut [u8], stride: usize, fmt: PixelFormat, roi: Rect, ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>

Decode a source-coordinate region into caller-owned output.

§Errors

Returns the codec-specific ImageCodec::Error when the input, region, output layout, or scratch state cannot be decoded.

Source

fn decode_scaled_into( &mut self, pool: &mut Self::Pool, out: &mut [u8], stride: usize, fmt: PixelFormat, scale: Downscale, ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>

Decode the full image at reduced resolution into caller-owned output.

§Errors

Returns the codec-specific ImageCodec::Error when the input, scale, output layout, or scratch state cannot be decoded.

Source

fn decode_region_scaled_into( &mut self, pool: &mut Self::Pool, out: &mut [u8], stride: usize, fmt: PixelFormat, roi: Rect, scale: Downscale, ) -> Result<DecodeOutcome<Self::Warning>, Self::Error>

Decode a source-coordinate region at reduced resolution into caller-owned output.

§Errors

Returns the codec-specific ImageCodec::Error when the input, region, scale, output layout, or scratch state cannot be decoded.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§