[−][src]Struct tiff::encoder::ImageEncoder
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]
[T::Inner]: TiffValue,
Write a single strip.
pub fn write_data(self, data: &[T::Inner]) -> TiffResult<()> where
[T::Inner]: TiffValue,
[src]
[T::Inner]: TiffValue,
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
Auto Trait Implementations
impl<'a, W, C> RefUnwindSafe for ImageEncoder<'a, W, C> where
C: RefUnwindSafe,
W: RefUnwindSafe,
C: RefUnwindSafe,
W: RefUnwindSafe,
impl<'a, W, C> Send for ImageEncoder<'a, W, C> where
C: Send,
W: Send,
C: Send,
W: Send,
impl<'a, W, C> Sync for ImageEncoder<'a, W, C> where
C: Sync,
W: Sync,
C: Sync,
W: Sync,
impl<'a, W, C> Unpin for ImageEncoder<'a, W, C> where
C: Unpin,
C: Unpin,
impl<'a, W, C> !UnwindSafe for ImageEncoder<'a, W, C>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,