Rewrite _to_buffer variants
We previously handed it a wrapper that was supposedly type-safe but really internally cast the buffer to bytes. That was rather pointless as the `_bytes` method could always be used instead. We replace the semantics by a utility which allocates an appropriate buffer with the internal limits, wrapping the exact sequence identified previously in the example as a pattern.
This commit is contained in:
1 parent
5150e91bbb
commit
5a3b11314e
2 files changed
+66
-29
No files matched your search
+1
-5
@@ -11,15 +11,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut reader = Decoder::new(io)?;
|
||||
|
||||
let mut data = DecodingResult::I8(vec![]);
|
||||
let limits = tiff::decoder::Limits::unlimited();
|
||||
|
||||
for i in 0u32.. {
|
||||
let layout = reader.image_buffer_layout()?;
|
||||
let colortype = reader.colortype()?;
|
||||
let dimensions = reader.dimensions()?;
|
||||
|
||||
data.resize_to(&layout, &limits)?;
|
||||
reader.read_image_bytes(data.as_buffer(0).as_bytes_mut())?;
|
||||
let layout = reader.read_image_to_buffer(&mut data)?;
|
||||
|
||||
debug_planes(i, &mut data, &layout, &colortype, dimensions);
|
||||
|
||||
|
||||
Reference in new issue
Block a user