Struct JpegEncoder
pub struct JpegEncoder<W> { /* private fields */ }
The representation of a JPEG encoder
Implementations
impl<W: Write> JpegEncoder<W>
fn new(w: W) -> JpegEncoder<W>Create a new encoder that writes its output to
wfn new_with_quality(w: W, quality: u8) -> JpegEncoder<W>Create a new encoder that writes its output to
w, and has the quality parameterqualitywith a value in the range 1-100 where 1 is the worst and 100 is the best.fn set_pixel_density(&mut self, pixel_density: PixelDensity)Set the pixel density of the images the encoder will encode. If this method is not called, then a default pixel aspect ratio of 1x1 will be applied, and no DPI information will be stored in the image.
fn encode(&mut self, image: &[u8], width: u32, height: u32, color_type: ExtendedColorType) -> ImageResult<()>Encodes the image stored in the raw byte buffer
imagethat has dimensionswidthandheightandColorTypecThe Image in encoded with subsampling ratio 4:2:2
Panics
Panics if
width * height * color_type.bytes_per_pixel() != image.len().fn encode_image<I: GenericImageView>(&mut self, image: &I) -> ImageResult<()> where I::Pixel: PixelWithColorType,Encodes the given image.
As a special feature this does not require the whole image to be present in memory at the same time such that it may be computed on the fly, which is why this method exists on this encoder but not on others. Instead the encoder will iterate over 8-by-8 blocks of pixels at a time, inspecting each pixel exactly once. You can rely on this behaviour when calling this method.
The Image in encoded with subsampling ratio 4:2:2
Trait Implementations
impl<W: Write> ImageEncoder for JpegEncoder<W>
fn write_image(self, buf: &[u8], width: u32, height: u32, color_type: ExtendedColorType) -> ImageResult<()>fn set_icc_profile(&mut self, icc_profile: Vec<u8>) -> Result<(), UnsupportedError>fn set_exif_metadata(&mut self, exif: Vec<u8>) -> Result<(), UnsupportedError>
Auto Trait Implementations
impl<W> Freeze for JpegEncoder<W>
where
BitWriter<W>: Freeze,
impl<W> RefUnwindSafe for JpegEncoder<W>
where
BitWriter<W>: RefUnwindSafe,
impl<W> Send for JpegEncoder<W>
where
BitWriter<W>: Send,
impl<W> Sync for JpegEncoder<W>
where
BitWriter<W>: Sync,
impl<W> Unpin for JpegEncoder<W>
where
BitWriter<W>: Unpin,
impl<W> UnsafeUnpin for JpegEncoder<W>
where
BitWriter<W>: UnsafeUnpin,
impl<W> UnwindSafe for JpegEncoder<W>
where
BitWriter<W>: UnwindSafe,
Blanket Implementations
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for JpegEncoder<W>
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for JpegEncoder<W>
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for JpegEncoder<W>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for JpegEncoder<W>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for JpegEncoder<W>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for JpegEncoder<W>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> IntoEither for JpegEncoder<W>
impl<T> Pointable for JpegEncoder<W>
const ALIGN: usize = _;type Init = T;unsafe fn init(init: <T as Pointable>::Init) -> usizeunsafe fn deref<'a>(ptr: usize) -> &'a Tunsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tunsafe fn drop(ptr: usize)
impl<T> Read<Exclusive, BecauseExclusive> for JpegEncoder<W>
where
T: ?Sized,
impl<T, U> Into<U> for JpegEncoder<W>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for JpegEncoder<W>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for JpegEncoder<W>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>