Mirrored return value of read_tile to read_strip
This commit is contained in:
1 parent
4ce3c2f41f
commit
8f34748d01
1 file changed
+5
-11
+5
-11
@@ -1,8 +1,8 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::io::{self, Cursor, Read, Seek};
|
use std::io::{self, Cursor, Read, Seek};
|
||||||
|
use std::ops::Range;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{cmp, ops::Range};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bytecast, ColorType, TiffError, TiffFormatError, TiffResult, TiffUnsupportedError, UsageError,
|
bytecast, ColorType, TiffError, TiffFormatError, TiffResult, TiffUnsupportedError, UsageError,
|
||||||
@@ -1484,22 +1484,16 @@ impl<R: Read + Seek> Decoder<R> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Read a single strip from the image and return it as a Vector
|
/// Read a single strip from the image and return it as a Vector
|
||||||
pub fn read_strip(&mut self) -> TiffResult<DecodingResult> {
|
pub fn read_strip(&mut self) -> TiffResult<(DecodingResult, ChunkInfo)> {
|
||||||
self.check_chunk_type(ChunkType::Strip)?;
|
self.check_chunk_type(ChunkType::Strip)?;
|
||||||
let index = self.current_chunk;
|
let index = self.current_chunk;
|
||||||
|
|
||||||
let rows_per_strip =
|
let chunk_info = self.chunk_info(index).unwrap();
|
||||||
usize::try_from(self.image().strip_decoder.as_ref().unwrap().rows_per_strip)?;
|
|
||||||
|
|
||||||
let strip_height = cmp::min(
|
let mut result = self.result_buffer(chunk_info.data_width, chunk_info.data_height)?;
|
||||||
rows_per_strip,
|
|
||||||
usize::try_from(self.image().height)? - index * rows_per_strip,
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut result = self.result_buffer(usize::try_from(self.image().width)?, strip_height)?;
|
|
||||||
self.read_strip_to_buffer(result.as_buffer(0))?;
|
self.read_strip_to_buffer(result.as_buffer(0))?;
|
||||||
|
|
||||||
Ok(result)
|
Ok((result, chunk_info))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read a single tile from the image and return it as a Vector
|
/// Read a single tile from the image and return it as a Vector
|
||||||
|
|||||||
Reference in new issue
Block a user