Struct turbojpeg::Compressor[][src]

pub struct Compressor { /* fields omitted */ }

Compresses raw pixel data into JPEG.

Implementations

impl Compressor[src]

pub fn new() -> Result<Compressor>[src]

Create a new compressor instance.

pub fn set_quality(&mut self, quality: i32)[src]

Set the quality of the compressed JPEG images.

The quality ranges from 1 (worst) to 100 (best).

pub fn set_subsamp(&mut self, subsamp: Subsamp)[src]

Set the level of chrominance subsampling of the compressed JPEG images.

Chrominance subsampling can reduce the compressed image size without noticeable loss of quality (see Subsamp for more).

pub fn compress_to_vec(&mut self, image: Image<&[u8]>) -> Result<Vec<u8>>[src]

Compress the image into a new Vec<u8>.

This method is simpler than compress_to_slice, but it requires multiple allocations and copies the output data from internal buffer to a Vec.

pub fn compress_to_slice(
    &mut self,
    image: Image<&[u8]>,
    dest: &mut [u8]
) -> Result<usize>
[src]

Compress the image into the buffer dest.

Returns the size of the compressed image. If the compressed image does not fit into dest, this method returns an error. Use buf_len to determine buffer size that is guaranteed to be large enough to compress the image.

pub fn buf_len(&self, width: usize, height: usize) -> Result<usize>[src]

Compute the maximum size of a compressed image.

This depends on image width and height, and also on the current setting of chrominance subsampling (see set_subsamp().

Trait Implementations

impl Debug for Compressor[src]

impl Drop for Compressor[src]

impl Send for Compressor[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.