Struct ImageEncoder

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

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

# extern crate tiff;
# fn main() {
# let mut file = std::io::Cursor::new(Vec::new());
# let image_data = vec![0; 100*100*3];
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, K: TiffKind> ImageEncoder<'a, W, T, K>

fn extra_samples(&mut self, extra: &[ExtraSamples]) -> Result<(), TiffError>
fn next_strip_sample_count(&self) -> u64

Number of samples the next strip should have.

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

Write a single strip.

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

Write strips from data

fn resolution(&mut self, unit: ResolutionUnit, value: Rational)

Set image resolution

fn resolution_unit(&mut self, unit: ResolutionUnit)

Set image resolution unit

fn x_resolution(&mut self, value: Rational)

Set image x-resolution

fn y_resolution(&mut self, value: Rational)

Set image y-resolution

fn rows_per_strip(&mut self, value: u32) -> TiffResult<()>

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.

fn encoder(&mut self) -> &mut DirectoryEncoder<'a, W, K>

Get a reference of the underlying DirectoryEncoder

fn finish(self) -> TiffResult<()>

Write out image and ifd directory.

Trait Implementations

impl<'a, W: Write + Seek, C: ColorType, K: TiffKind> Drop for ImageEncoder<'a, W, C, K>

fn drop(&mut self)

Auto Trait Implementations

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

impl<'a, W, C, K> Freeze for ImageEncoder<'a, W, C, K> where DirectoryEncoder<'a, W, K>: Freeze, Vec<<K as TiffKind>::OffsetType>: Freeze + Freeze, PhantomData<C>: Freeze,

impl<'a, W, C, K> RefUnwindSafe for ImageEncoder<'a, W, C, K> where DirectoryEncoder<'a, W, K>: RefUnwindSafe, Vec<<K as TiffKind>::OffsetType>: RefUnwindSafe + RefUnwindSafe, PhantomData<C>: RefUnwindSafe,

impl<'a, W, C, K> Send for ImageEncoder<'a, W, C, K> where DirectoryEncoder<'a, W, K>: Send, Vec<<K as TiffKind>::OffsetType>: Send + Send, PhantomData<C>: Send,

impl<'a, W, C, K> Sync for ImageEncoder<'a, W, C, K> where DirectoryEncoder<'a, W, K>: Sync, Vec<<K as TiffKind>::OffsetType>: Sync + Sync, PhantomData<C>: Sync,

impl<'a, W, C, K> Unpin for ImageEncoder<'a, W, C, K> where DirectoryEncoder<'a, W, K>: Unpin, Vec<<K as TiffKind>::OffsetType>: Unpin + Unpin, PhantomData<C>: Unpin,

impl<'a, W, C, K> UnsafeUnpin for ImageEncoder<'a, W, C, K> where DirectoryEncoder<'a, W, K>: UnsafeUnpin, Vec<<K as TiffKind>::OffsetType>: UnsafeUnpin + UnsafeUnpin, PhantomData<C>: UnsafeUnpin,

Blanket Implementations

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for ImageEncoder<'a, W, C, K> where ST: ?Sized, DT: ?Sized,

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for ImageEncoder<'a, W, C, K> where ST: ?Sized, DT: ?Sized,

impl<T> Any for ImageEncoder<'a, W, C, K> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for ImageEncoder<'a, W, C, K> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for ImageEncoder<'a, W, C, K> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for ImageEncoder<'a, W, C, K>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Read<Exclusive, BecauseExclusive> for ImageEncoder<'a, W, C, K> where T: ?Sized,

impl<T, U> Into<U> for ImageEncoder<'a, W, C, K> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for ImageEncoder<'a, W, C, K> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for ImageEncoder<'a, W, C, K> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>