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) -> u64Number 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_dataorwrite_stripand will return an error otherwise.fn encoder(&mut self) -> &mut DirectoryEncoder<'a, W, K>Get a reference of the underlying
DirectoryEncoderfn 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)