pub fn encode(
        &mut self,
        image: &[u8],
        width: u32,
        height: u32,
        color_type: ColorType,
    ) -> ImageResult<()> {
        match color_type {
            ColorType::L8 => {
                let image: ImageBuffer<Luma<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            ColorType::La8 => {
                let image: ImageBuffer<LumaA<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            ColorType::Rgb8 => {
                let image: ImageBuffer<Rgb<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            ColorType::Rgba8 => {
                let image: ImageBuffer<Rgba<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            ColorType::Bgr8 => {
                let image: ImageBuffer<Bgr<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            ColorType::Bgra8 => {
                let image: ImageBuffer<Bgra<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            _ => Err(ImageError::Unsupported(
                UnsupportedError::from_format_and_kind(
                    ImageFormat::Jpeg.into(),
                    UnsupportedErrorKind::Color(color_type.into()),
                ),
            )),
        }
    }
/// Encodes the image stored in the raw byte buffer ```image```
/// that has dimensions ```width``` and ```height```
/// and ```ColorType``` ```c```
///
/// The Image in encoded with subsampling ratio 4:2:2


The Image in encoded with subsampling ratio 4:2:2
The Image in encoded with subsampling ratio 4 : 2 : 2
pub fn encode(
        &mut self,
        image: &[u8],
        width: u32,
        height: u32,
        color_type: ColorType,
    ) -> ImageResult<()> {
        match color_type {
            ColorType::L8 => {
                let image: ImageBuffer<Luma<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            ColorType::La8 => {
                let image: ImageBuffer<LumaA<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            ColorType::Rgb8 => {
                let image: ImageBuffer<Rgb<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            ColorType::Rgba8 => {
                let image: ImageBuffer<Rgba<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            ColorType::Bgr8 => {
                let image: ImageBuffer<Bgr<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            ColorType::Bgra8 => {
                let image: ImageBuffer<Bgra<_>, _> =
                    ImageBuffer::from_raw(width, height, image).unwrap();
                self.encode_image(&image)
            }
            _ => Err(ImageError::Unsupported(
                UnsupportedError::from_format_and_kind(
                    ImageFormat::Jpeg.into(),
                    UnsupportedErrorKind::Color(color_type.into()),
                ),
            )),
        }
    }
pub fn encode ( & mut self , image : & [ u8 ] , width : u32 , height : u32 , color_type : ColorType , ) -> ImageResult < ( ) > { match color_type { ColorType :: L8 => { let image : ImageBuffer < Luma < _ > , _ > = ImageBuffer :: from_raw ( width , height , image ) . unwrap ( ) ; self . encode_image ( & image ) } ColorType :: La8 => { let image : ImageBuffer < LumaA < _ > , _ > = ImageBuffer :: from_raw ( width , height , image ) . unwrap ( ) ; self . encode_image ( & image ) } ColorType :: Rgb8 => { let image : ImageBuffer < Rgb < _ > , _ > = ImageBuffer :: from_raw ( width , height , image ) . unwrap ( ) ; self . encode_image ( & image ) } ColorType :: Rgba8 => { let image : ImageBuffer < Rgba < _ > , _ > = ImageBuffer :: from_raw ( width , height , image ) . unwrap ( ) ; self . encode_image ( & image ) } ColorType :: Bgr8 => { let image : ImageBuffer < Bgr < _ > , _ > = ImageBuffer :: from_raw ( width , height , image ) . unwrap ( ) ; self . encode_image ( & image ) } ColorType :: Bgra8 => { let image : ImageBuffer < Bgra < _ > , _ > = ImageBuffer :: from_raw ( width , height , image ) . unwrap ( ) ; self . encode_image ( & image ) } _ => Err ( ImageError :: Unsupported ( UnsupportedError :: from_format_and_kind ( ImageFormat :: Jpeg . into ( ) , UnsupportedErrorKind :: Color ( color_type . into ( ) ) , ) , ) ) , } }
Encodes the image stored in the raw byte buffer ```image```
that has dimensions ```width``` and ```height```
and ```ColorType``` ```c```
Encodes the image stored in the raw byte buffer ` ` ` image ` ` ` that has dimensions ` ` ` width ` ` ` and ` ` ` height ` ` ` and ` ` ` ColorType ` ` ` ` ` ` c ` ` `
&mut self
image
&[u8]
width
u32
height
u32
color_type
ColorType