pub struct ImageEncoder<'a, W: 'a + Write + Seek, C: ColorType, K: TiffKind, D: Compression = Uncompressed> { /* private fields */ }
Expand description

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

Number of samples the next strip should have.

Write a single strip.

Write strips from data

Set image resolution

Set image resolution unit

Set image x-resolution

Set image y-resolution

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.

Get a reference of the underlying DirectoryEncoder

Write out image and ifd directory.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.