Struct JpegEncoder
struct JpegEncoder<W> { ... }
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(self: &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(self: &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>(self: &mut Self, image: &I) -> ImageResult<()> where <I as >::Pixel: PixelWithColorTypeEncodes 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
impl<T> Any for JpegEncoder<W>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for JpegEncoder<W>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for JpegEncoder<W>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for JpegEncoder<W>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Pointable for JpegEncoder<W>
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, U> Into for JpegEncoder<W>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for JpegEncoder<W>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for JpegEncoder<W>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<W> Freeze for JpegEncoder<W>
impl<W> RefUnwindSafe for JpegEncoder<W>
impl<W> Send for JpegEncoder<W>
impl<W> Sync for JpegEncoder<W>
impl<W> Unpin for JpegEncoder<W>
impl<W> UnsafeUnpin for JpegEncoder<W>
impl<W> UnwindSafe for JpegEncoder<W>
impl<W: Write> ImageEncoder for JpegEncoder<W>
fn write_image(self: Self, buf: &[u8], width: u32, height: u32, color_type: ExtendedColorType) -> ImageResult<()>