pub trait Encoder<T, U, C>where
    U: Data<Elem = T>,
    T: Copy + Clone + Num + NumAssignOps + NumCast + PartialOrd + Display + PixelBound,
    C: ColourModel,{
    // Required method
    fn encode(&self, image: &ImageBase<U, C>) -> Vec<u8>;

    // Provided method
    fn encode_file<P: AsRef<Path>>(
        &self,
        image: &ImageBase<U, C>,
        filename: P
    ) -> Result<()> { ... }
}
Expand description

Trait for an image encoder

Required Methods§

source

fn encode(&self, image: &ImageBase<U, C>) -> Vec<u8>

Encode an image into a sequence of bytes for the given format

Provided Methods§

source

fn encode_file<P: AsRef<Path>>( &self, image: &ImageBase<U, C>, filename: P ) -> Result<()>

Encode an image saving it to the file at filename. This function shouldn’t add an extension preferring the user to do that instead.

Implementors§

source§

impl<T, U> Encoder<T, U, RGB> for PpmEncoderwhere U: Data<Elem = T>, T: Copy + Clone + Num + NumAssignOps + NumCast + PartialOrd + Display + PixelBound + FromPrimitive,

Implements the encoder trait for the PpmEncoder.

The ColourModel type argument is locked to RGB - this prevents calling RGB::into::() unnecessarily which is unavoidable until trait specialisation is stabilised.