Removed unused functions and make InvalidChunkIndex a UsageError

This commit is contained in:
Alan Race committed 2022-07-08 11:08:30 +02:00
1 parent 8c0c13f022
commit e1f4161e0b
5 files changed
+21 -95

No files matched your search

+4 -84
View File
@@ -1064,31 +1064,6 @@ impl<R: Read + Seek> Decoder<R> {
Ok(())
}
#[deprecated = "Use read_chunk_to_buffer instead"]
fn read_tile_to_buffer(
&mut self,
mut buffer: DecodingBuffer,
tile_index: usize,
output_width: usize,
) -> TiffResult<()> {
self.check_chunk_type(ChunkType::Tile)?;
let offset = self.image.chunk_file_range(tile_index)?.0;
self.goto_offset_u64(offset)?;
let byte_order = self.reader.byte_order;
self.image.expand_chunk(
&mut self.reader,
buffer.copy(),
output_width,
byte_order,
tile_index,
)?;
Ok(())
}
fn read_chunk_to_buffer(
&mut self,
mut buffer: DecodingBuffer,
@@ -1168,74 +1143,19 @@ impl<R: Read + Seek> Decoder<R> {
/// information on the size of the strip read and so the caller must take care of the final
/// strip in the image as the data read may be less than the expected strip size. This interface
/// may change at a future date to reflect this.
///
/// `read_strip_at` can be used to get both the strip data and the strip size.
///
#[deprecated = "Use read_chunk instead"]
#[deprecated = "Use read_chunk_at instead"]
pub fn read_strip(&mut self) -> TiffResult<DecodingResult> {
let result = self.read_strip_at(self.current_chunk)?;
let result = self.read_chunk_at(self.current_chunk)?;
Ok(result.0)
}
/// Read the specified strip (at index `strip_index`) and return the binary data as a Vector and
/// `ChunkInfo` describing the size of the strip.
///
#[deprecated = "Use read_chunk instead"]
pub fn read_strip_at(&mut self, strip_index: usize) -> TiffResult<(DecodingResult, ChunkInfo)> {
self.check_chunk_type(ChunkType::Strip)?;
let chunk_info = self
.image()
.chunk_info(strip_index)
.ok_or(TiffFormatError::InvalidChunkIndex(strip_index))?;
let mut result = self.result_buffer(chunk_info.data_width, chunk_info.data_height)?;
self.read_strip_to_buffer(result.as_buffer(0))?;
Ok((result, chunk_info))
}
/// Read a single tile from the image and return it as a Vector. This method does not return
/// information on the size of the tile read and so the caller must take care of tiles on the
/// rightmost column and the bottommost row in the image as the data read may be less than the
/// expected tile size. This interface may change at a future date to reflect this.
///
/// `read_tile_at` can be used to get both the tile data and the tile size.
#[deprecated = "Use read_chunk instead"]
pub fn read_tile(&mut self) -> TiffResult<DecodingResult> {
let result = self.read_tile_at(self.current_chunk)?;
self.current_chunk += 1;
Ok(result.0)
}
/// Read the specified tile (at index `tile_index`) and return the binary data as a Vector and
/// `ChunkInfo` describing the size of the tile.
#[deprecated = "Use read_chunk_at instead"]
pub fn read_tile_at(&mut self, tile_index: usize) -> TiffResult<(DecodingResult, ChunkInfo)> {
self.check_chunk_type(ChunkType::Tile)?;
let chunk_info = self
.image()
.chunk_info(tile_index)
.ok_or(TiffFormatError::InvalidChunkIndex(tile_index))?;
let mut result = self.result_buffer(chunk_info.data_width, chunk_info.data_height)?;
self.read_tile_to_buffer(result.as_buffer(0), tile_index, chunk_info.data_width)?;
Ok((result, chunk_info))
}
/// Read a single chunk from the image and return it as a Vector. This method does not return
/// information on the size of the chunk read and so the caller must take care of chunks on the
/// rightmost column and the bottommost row in the image as the data read may be less than the
/// expected chunk size. This interface may change at a future date to reflect this.
///
/// `read_chunk_at` can be used to get both the chunk data and the tile size.
pub fn read_chunk(&mut self) -> TiffResult<DecodingResult> {
pub fn read_tile(&mut self) -> TiffResult<DecodingResult> {
let result = self.read_chunk_at(self.current_chunk)?;
self.current_chunk += 1;
@@ -1249,7 +1169,7 @@ impl<R: Read + Seek> Decoder<R> {
let chunk_info = self
.image()
.chunk_info(chunk_index)
.ok_or(TiffFormatError::InvalidChunkIndex(chunk_index))?;
.ok_or(UsageError::InvalidChunkIndex(chunk_index))?;
let mut result = self.result_buffer(chunk_info.data_width, chunk_info.data_height)?;