pub struct Decoder<R>{
reader: SmartReader<R>,
bigtiff: bool,
limits: Limits,
next_ifd: Option<u64>,
ifd_offsets: Vec<u64>,
seen_ifds: HashSet<u64>,
image: Image,
}
Expand description
The representation of a TIFF decoder
Currently does not support decoding of interlaced images
Fields§
§reader: SmartReader<R>
§bigtiff: bool
§limits: Limits
§next_ifd: Option<u64>
§ifd_offsets: Vec<u64>
§seen_ifds: HashSet<u64>
§image: Image
Implementations§
source§impl<R: Read + Seek> Decoder<R>
impl<R: Read + Seek> Decoder<R>
sourcepub fn new(r: R) -> TiffResult<Decoder<R>>
pub fn new(r: R) -> TiffResult<Decoder<R>>
Create a new decoder that decodes from the stream r
pub fn with_limits(self, limits: Limits) -> Decoder<R>
pub fn dimensions(&mut self) -> TiffResult<(u32, u32)>
pub fn colortype(&mut self) -> TiffResult<ColorType>
fn image(&self) -> &Image
sourcepub fn seek_to_image(&mut self, ifd_index: usize) -> TiffResult<()>
pub fn seek_to_image(&mut self, ifd_index: usize) -> TiffResult<()>
Loads the IFD at the specified index in the list, if one exists
fn next_ifd(&mut self) -> TiffResult<(Directory, Option<u64>)>
sourcepub fn next_image(&mut self) -> TiffResult<()>
pub fn next_image(&mut self) -> TiffResult<()>
Reads in the next image.
If there is no further image in the TIFF file a format error is returned.
To determine whether there are more images call TIFFDecoder::more_images
instead.
sourcepub fn more_images(&self) -> bool
pub fn more_images(&self) -> bool
Returns true
if there is at least one more image available.
sourcepub fn byte_order(&self) -> ByteOrder
pub fn byte_order(&self) -> ByteOrder
Returns the byte_order
pub fn read_ifd_offset(&mut self) -> Result<u64, Error>
sourcepub fn read_short(&mut self) -> Result<u16, Error>
pub fn read_short(&mut self) -> Result<u16, Error>
Reads a TIFF short value
sourcepub fn read_sshort(&mut self) -> Result<i16, Error>
pub fn read_sshort(&mut self) -> Result<i16, Error>
Reads a TIFF sshort value
sourcepub fn read_slong(&mut self) -> Result<i32, Error>
pub fn read_slong(&mut self) -> Result<i32, Error>
Reads a TIFF slong value
sourcepub fn read_float(&mut self) -> Result<f32, Error>
pub fn read_float(&mut self) -> Result<f32, Error>
Reads a TIFF float value
sourcepub fn read_double(&mut self) -> Result<f64, Error>
pub fn read_double(&mut self) -> Result<f64, Error>
Reads a TIFF double value
pub fn read_long8(&mut self) -> Result<u64, Error>
pub fn read_slong8(&mut self) -> Result<i64, Error>
sourcepub fn read_string(&mut self, length: usize) -> TiffResult<String>
pub fn read_string(&mut self, length: usize) -> TiffResult<String>
Reads a string
sourcepub fn read_offset(&mut self) -> TiffResult<[u8; 4]>
pub fn read_offset(&mut self) -> TiffResult<[u8; 4]>
Reads a TIFF IFA offset/value field
sourcepub fn read_offset_u64(&mut self) -> Result<[u8; 8], Error>
pub fn read_offset_u64(&mut self) -> Result<[u8; 8], Error>
Reads a TIFF IFA offset/value field
sourcepub fn goto_offset(&mut self, offset: u32) -> Result<()>
pub fn goto_offset(&mut self, offset: u32) -> Result<()>
Moves the cursor to the specified offset
pub fn goto_offset_u64(&mut self, offset: u64) -> Result<()>
sourcefn read_entry(
reader: &mut SmartReader<R>,
bigtiff: bool,
) -> TiffResult<Option<(Tag, Entry)>>
fn read_entry( reader: &mut SmartReader<R>, bigtiff: bool, ) -> TiffResult<Option<(Tag, Entry)>>
Reads a IFD entry.
sourcefn read_ifd(
reader: &mut SmartReader<R>,
bigtiff: bool,
ifd_location: u64,
) -> TiffResult<(Directory, Option<u64>)>
fn read_ifd( reader: &mut SmartReader<R>, bigtiff: bool, ifd_location: u64, ) -> TiffResult<(Directory, Option<u64>)>
Reads the IFD starting at the indicated location.
sourcepub fn find_tag(&mut self, tag: Tag) -> TiffResult<Option<Value>>
pub fn find_tag(&mut self, tag: Tag) -> TiffResult<Option<Value>>
Tries to retrieve a tag.
Return Ok(None)
if the tag is not present.
sourcepub fn find_tag_unsigned<T: TryFrom<u64>>(
&mut self,
tag: Tag,
) -> TiffResult<Option<T>>
pub fn find_tag_unsigned<T: TryFrom<u64>>( &mut self, tag: Tag, ) -> TiffResult<Option<T>>
Tries to retrieve a tag and convert it to the desired unsigned type.
sourcepub fn find_tag_unsigned_vec<T: TryFrom<u64>>(
&mut self,
tag: Tag,
) -> TiffResult<Option<Vec<T>>>
pub fn find_tag_unsigned_vec<T: TryFrom<u64>>( &mut self, tag: Tag, ) -> TiffResult<Option<Vec<T>>>
Tries to retrieve a vector of all a tag’s values and convert them to the desired unsigned type.
sourcepub fn get_tag_unsigned<T: TryFrom<u64>>(&mut self, tag: Tag) -> TiffResult<T>
pub fn get_tag_unsigned<T: TryFrom<u64>>(&mut self, tag: Tag) -> TiffResult<T>
Tries to retrieve a tag and convert it to the desired unsigned type. Returns an error if the tag is not present.
sourcepub fn get_tag(&mut self, tag: Tag) -> TiffResult<Value>
pub fn get_tag(&mut self, tag: Tag) -> TiffResult<Value>
Tries to retrieve a tag. Returns an error if the tag is not present
sourcepub fn get_tag_u32(&mut self, tag: Tag) -> TiffResult<u32>
pub fn get_tag_u32(&mut self, tag: Tag) -> TiffResult<u32>
Tries to retrieve a tag and convert it to the desired type.
pub fn get_tag_u64(&mut self, tag: Tag) -> TiffResult<u64>
sourcepub fn get_tag_f32(&mut self, tag: Tag) -> TiffResult<f32>
pub fn get_tag_f32(&mut self, tag: Tag) -> TiffResult<f32>
Tries to retrieve a tag and convert it to the desired type.
sourcepub fn get_tag_f64(&mut self, tag: Tag) -> TiffResult<f64>
pub fn get_tag_f64(&mut self, tag: Tag) -> TiffResult<f64>
Tries to retrieve a tag and convert it to the desired type.
sourcepub fn get_tag_u32_vec(&mut self, tag: Tag) -> TiffResult<Vec<u32>>
pub fn get_tag_u32_vec(&mut self, tag: Tag) -> TiffResult<Vec<u32>>
Tries to retrieve a tag and convert it to the desired type.
pub fn get_tag_u16_vec(&mut self, tag: Tag) -> TiffResult<Vec<u16>>
pub fn get_tag_u64_vec(&mut self, tag: Tag) -> TiffResult<Vec<u64>>
sourcepub fn get_tag_f32_vec(&mut self, tag: Tag) -> TiffResult<Vec<f32>>
pub fn get_tag_f32_vec(&mut self, tag: Tag) -> TiffResult<Vec<f32>>
Tries to retrieve a tag and convert it to the desired type.
sourcepub fn get_tag_f64_vec(&mut self, tag: Tag) -> TiffResult<Vec<f64>>
pub fn get_tag_f64_vec(&mut self, tag: Tag) -> TiffResult<Vec<f64>>
Tries to retrieve a tag and convert it to the desired type.
sourcepub fn get_tag_u8_vec(&mut self, tag: Tag) -> TiffResult<Vec<u8>>
pub fn get_tag_u8_vec(&mut self, tag: Tag) -> TiffResult<Vec<u8>>
Tries to retrieve a tag and convert it to a 8bit vector.
sourcepub fn get_tag_ascii_string(&mut self, tag: Tag) -> TiffResult<String>
pub fn get_tag_ascii_string(&mut self, tag: Tag) -> TiffResult<String>
Tries to retrieve a tag and convert it to a ascii vector.
fn check_chunk_type(&self, expected: ChunkType) -> TiffResult<()>
sourcepub fn get_chunk_type(&self) -> ChunkType
pub fn get_chunk_type(&self) -> ChunkType
The chunk type (Strips / Tiles) of the image
sourcepub fn strip_count(&mut self) -> TiffResult<u32>
pub fn strip_count(&mut self) -> TiffResult<u32>
Number of strips in image
sourcepub fn tile_count(&mut self) -> TiffResult<u32>
pub fn tile_count(&mut self) -> TiffResult<u32>
Number of tiles in image
pub fn read_chunk_to_buffer( &mut self, buffer: DecodingBuffer<'_>, chunk_index: u32, output_width: usize, ) -> TiffResult<()>
fn result_buffer( &self, width: usize, height: usize, ) -> TiffResult<DecodingResult>
sourcepub fn read_chunk(&mut self, chunk_index: u32) -> TiffResult<DecodingResult>
pub fn read_chunk(&mut self, chunk_index: u32) -> TiffResult<DecodingResult>
Read the specified chunk (at index chunk_index
) and return the binary data as a Vector.
sourcepub fn chunk_dimensions(&self) -> (u32, u32)
pub fn chunk_dimensions(&self) -> (u32, u32)
Returns the default chunk size for the current image. Any given chunk in the image is at most as large as
the value returned here. For the size of the data (chunk minus padding), use chunk_data_dimensions
.
sourcepub fn chunk_data_dimensions(&self, chunk_index: u32) -> (u32, u32)
pub fn chunk_data_dimensions(&self, chunk_index: u32) -> (u32, u32)
Returns the size of the data in the chunk with the specified index. This is the default size of the chunk, minus any padding.
sourcepub fn read_image(&mut self) -> TiffResult<DecodingResult>
pub fn read_image(&mut self) -> TiffResult<DecodingResult>
Decodes the entire image and return it as a Vector
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for Decoder<R>where
R: Freeze,
impl<R> RefUnwindSafe for Decoder<R>where
R: RefUnwindSafe,
impl<R> Send for Decoder<R>where
R: Send,
impl<R> Sync for Decoder<R>where
R: Sync,
impl<R> Unpin for Decoder<R>where
R: Unpin,
impl<R> UnwindSafe for Decoder<R>where
R: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more