[][src]Struct tiff::encoder::ImageEncoder

pub struct ImageEncoder<'a, W: 'a + Write + Seek, C: ColorType> { /* fields omitted */ }

Type to encode images strip by strip.

You should call finish on this when you are finished with it. Encoding can silently fail while this is dropping.

Examples

use tiff::encoder::*;
use tiff::tags::Tag;

let mut tiff = TiffEncoder::new(&mut file).unwrap();
let mut image = tiff.new_image::<colortype::RGB8>(100, 100).unwrap();

// You can encode tags here
image.encoder().write_tag(Tag::Artist, "Image-tiff").unwrap();

// Strip size can be configured before writing data
image.rows_per_strip(2).unwrap();

let mut idx = 0;
while image.next_strip_sample_count() > 0 {
    let sample_count = image.next_strip_sample_count() as usize;
    image.write_strip(&image_data[idx..idx+sample_count]).unwrap();
    idx += sample_count;
}
image.finish().unwrap();

You can also call write_data function wich will encode by strip and finish

Implementations

impl<'a, W: 'a + Write + Seek, T: ColorType> ImageEncoder<'a, W, T>[src]

pub fn next_strip_sample_count(&self) -> u64[src]

Number of samples the next strip should have.

pub fn write_strip(&mut self, value: &[T::Inner]) -> TiffResult<()> where
    [T::Inner]: TiffValue
[src]

Write a single strip.

pub fn write_data(self, data: &[T::Inner]) -> TiffResult<()> where
    [T::Inner]: TiffValue
[src]

Write strips from data

pub fn resolution(&mut self, unit: ResolutionUnit, value: Rational)[src]

Set image resolution

pub fn resolution_unit(&mut self, unit: ResolutionUnit)[src]

Set image resolution unit

pub fn x_resolution(&mut self, value: Rational)[src]

Set image x-resolution

pub fn y_resolution(&mut self, value: Rational)[src]

Set image y-resolution

pub fn rows_per_strip(&mut self, value: u32) -> TiffResult<()>[src]

Set image number of lines per strip

This function needs to be called before any calls to write_data or write_strip and will return an error otherwise.

pub fn encoder(&mut self) -> &mut DirectoryEncoder<'a, W>[src]

Get a reference of the underlying DirectoryEncoder

pub fn finish(self) -> TiffResult<()>[src]

Write out image and ifd directory.

Trait Implementations

impl<'a, W: Write + Seek, C: ColorType> Drop for ImageEncoder<'a, W, C>[src]

Auto Trait Implementations

impl<'a, W, C> RefUnwindSafe for ImageEncoder<'a, W, C> where
    C: RefUnwindSafe,
    W: RefUnwindSafe

impl<'a, W, C> Send for ImageEncoder<'a, W, C> where
    C: Send,
    W: Send

impl<'a, W, C> Sync for ImageEncoder<'a, W, C> where
    C: Sync,
    W: Sync

impl<'a, W, C> Unpin for ImageEncoder<'a, W, C> where
    C: Unpin

impl<'a, W, C> !UnwindSafe for ImageEncoder<'a, W, C>

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.