| 1 | //! The last wrapper of image readers, finally containing the [`from_file(path)`] method. |
| 2 | //! This completes the builder and reads a complete image. |
| 3 | |
| 4 | use craterust-analyzer cargo exr 1.74.0 crate/::imagerust-analyzer cargo exr 1.74.0 image/::*; |
| 5 | use craterust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::headerrust-analyzer cargo exr 1.74.0 meta/header/::{Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#, ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#}; |
| 6 | use craterust-analyzer cargo exr 1.74.0 crate/::errorrust-analyzer cargo exr 1.74.0 error/::{Resultrust-analyzer cargo exr 1.74.0 error/Result#, UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult#}; |
| 7 | use craterust-analyzer cargo exr 1.74.0 crate/::blockrust-analyzer cargo exr 1.74.0 block/::{UncompressedBlockrust-analyzer cargo exr 1.74.0 block/UncompressedBlock#, BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#}; |
| 8 | use craterust-analyzer cargo exr 1.74.0 crate/::blockrust-analyzer cargo exr 1.74.0 block/::chunkrust-analyzer cargo exr 1.74.0 block/chunk/::TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#; |
| 9 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#; |
| 10 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#}; |
| 11 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#; |
| 12 | use craterust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#; |
| 13 | use craterust-analyzer cargo exr 1.74.0 crate/::blockrust-analyzer cargo exr 1.74.0 block/::readerrust-analyzer cargo exr 1.74.0 block/reader/::ChunksReaderrust-analyzer cargo exr 1.74.0 block/reader/ChunksReader#; |
| 14 | |
| 15 | /// Specify whether to read the image in parallel, |
| 16 | /// whether to use pedantic error handling, |
| 17 | /// and a callback for the reading progress. |
| 18 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 19 | pub struct ReadImagerust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#<OnProgress, ReadLayers> { |
| 20 | on_progressrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#on_progress.: OnProgress, |
| 21 | read_layersrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#read_layers.: ReadLayers, |
| 22 | pedanticrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#pedantic.: bool, |
| 23 | parallelrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#parallel.: bool, |
| 24 | } |
| 25 | |
| 26 | impl<F, L> ReadImagerust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#<F, L> where F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(f64) |
| 27 | { |
| 28 | /// Uses relaxed error handling and parallel decompression. |
| 29 | pub fn newrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]new().(read_layers: L, on_progress: F) -> Selfrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`] { |
| 30 | Selfrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`] { |
| 31 | on_progressrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#on_progress., read_layersrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#read_layers., |
| 32 | pedanticrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#pedantic.: false, |
| 33 | #[cfg(not(feature = "rayon"))] |
| 34 | parallelrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#parallel.: false, |
| 35 | #[cfg(feature = "rayon")] |
| 36 | parallelrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#parallel.: true, |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | /// Specify that any missing or unusual information should result in an error. |
| 41 | /// Otherwise, `exrs` will try to compute or ignore missing information. |
| 42 | /// |
| 43 | /// If pedantic is true, then an error will be returned as soon as anything is missing in the file, |
| 44 | /// or two values in the image contradict each other. If pedantic is false, |
| 45 | /// then only fatal errors will be thrown. By default, reading an image is not pedantic, |
| 46 | /// which means that slightly invalid files might still be readable. |
| 47 | /// For example, if some attribute is missing but can be recomputed, this flag decides whether an error is thrown. |
| 48 | /// Or if the pedantic flag is true and there are still bytes left after the decompression algorithm finished, |
| 49 | /// an error is thrown, because this should not happen and something might be wrong with the file. |
| 50 | /// Or if your application is a target of attacks, or if you want to emulate the original C++ library, |
| 51 | /// you might want to switch to pedantic reading. |
| 52 | pub fn pedanticrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]pedantic().(self) -> Selfrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`] { Selfrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`] { pedanticrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#pedantic.: true, ..self } } |
| 53 | |
| 54 | /// Specify that multiple pixel blocks should never be decompressed using multiple threads at once. |
| 55 | /// This might be slower but uses less memory and less synchronization. |
| 56 | pub fn non_parallelrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]non_parallel().(self) -> Selfrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`] { Selfrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`] { parallelrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#parallel.: false, ..self } } |
| 57 | |
| 58 | /// Specify a function to be called regularly throughout the loading process. |
| 59 | /// Replaces all previously specified progress functions in this reader. |
| 60 | pub fn on_progressrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]on_progress().<OnProgress>(self, on_progress: OnProgress) -> ReadImagerust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#<OnProgress, L> |
| 61 | where OnProgress: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(f64) |
| 62 | { |
| 63 | ReadImagerust-analyzer cargo exr 1.74.0 image/read/image/ReadImage# { |
| 64 | on_progressrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#on_progress., |
| 65 | read_layersrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#read_layers.: self.read_layersrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#read_layers., |
| 66 | pedanticrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#pedantic.: self.pedanticrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#pedantic., |
| 67 | parallelrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#parallel.: self.parallelrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#parallel. |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | |
| 72 | /// Read the exr image from a file. |
| 73 | /// Use [`ReadImage::read_from_unbuffered`] instead, if you do not have a file. |
| 74 | #[inline] |
| 75 | #[must_use] |
| 76 | pub fn from_filerust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_file().<Layers>(self, path: impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Imagerust-analyzer cargo exr 1.74.0 image/Image#<Layers>> |
| 77 | where for<'s> L: ReadLayersrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#<'s, Layersrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#Layers# = Layers> |
| 78 | { |
| 79 | self.from_unbufferedrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_unbuffered().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().(path)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) |
| 80 | } |
| 81 | |
| 82 | /// Buffer the reader and then read the exr image from it. |
| 83 | /// Use [`ReadImage::read_from_buffered`] instead, if your reader is an in-memory reader. |
| 84 | /// Use [`ReadImage::read_from_file`] instead, if you have a file path. |
| 85 | #[inline] |
| 86 | #[must_use] |
| 87 | pub fn from_unbufferedrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_unbuffered().<Layers>(self, unbuffered: impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Imagerust-analyzer cargo exr 1.74.0 image/Image#<Layers>> |
| 88 | where for<'s> L: ReadLayersrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#<'s, Layersrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#Layers# = Layers> |
| 89 | { |
| 90 | self.from_bufferedrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_buffered().(BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]new().(unbuffered)) |
| 91 | } |
| 92 | |
| 93 | /// Read the exr image from a buffered reader. |
| 94 | /// Use [`ReadImage::read_from_file`] instead, if you have a file path. |
| 95 | /// Use [`ReadImage::read_from_unbuffered`] instead, if this is not an in-memory reader. |
| 96 | // TODO Use Parallel<> Wrapper to only require sendable byte source where parallel decompression is required |
| 97 | #[must_use] |
| 98 | pub fn from_bufferedrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_buffered().<Layers>(self, buffered: impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Imagerust-analyzer cargo exr 1.74.0 image/Image#<Layers>> |
| 99 | where for<'s> L: ReadLayersrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#<'s, Layersrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#Layers# = Layers> |
| 100 | { |
| 101 | let chunks = craterust-analyzer cargo exr 1.74.0 crate/::blockrust-analyzer cargo exr 1.74.0 block/::readrust-analyzer cargo exr 1.74.0 block/read().(buffered, self.pedanticrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#pedantic.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 102 | self.from_chunksrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_chunks().(chunks) |
| 103 | } |
| 104 | |
| 105 | /// Read the exr image from an initialized chunks reader |
| 106 | /// that has already extracted the meta data from the file. |
| 107 | /// Use [`ReadImage::read_from_file`] instead, if you have a file path. |
| 108 | /// Use [`ReadImage::read_from_buffered`] instead, if this is an in-memory reader. |
| 109 | // TODO Use Parallel<> Wrapper to only require sendable byte source where parallel decompression is required |
| 110 | #[must_use] |
| 111 | pub fn from_chunksrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]from_chunks().<Layers>(mut self, chunks_reader: craterust-analyzer cargo exr 1.74.0 crate/::blockrust-analyzer cargo exr 1.74.0 block/::readerrust-analyzer cargo exr 1.74.0 block/reader/::Readerrust-analyzer cargo exr 1.74.0 block/reader/Reader#<impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#>) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Imagerust-analyzer cargo exr 1.74.0 image/Image#<Layers>> |
| 112 | where for<'s> L: ReadLayersrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#<'s, Layersrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#Layers# = Layers> |
| 113 | { |
| 114 | let Selfrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`] { pedanticrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#pedantic., parallelrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#parallel., ref mut on_progressrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#on_progress., ref mut read_layersrust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#read_layers. } = self; |
| 115 | |
| 116 | let layers_reader = read_layers.create_layers_readerrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#create_layers_reader().(chunks_reader.headersrust-analyzer cargo exr 1.74.0 block/reader/impl#[`Reader<R>`]headers().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 117 | let mut image_collector = ImageWithAttributesReaderrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader#::newrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ImageWithAttributesReader<L>`]new().(chunks_reader.headersrust-analyzer cargo exr 1.74.0 block/reader/impl#[`Reader<R>`]headers().(), layers_reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 118 | |
| 119 | let block_reader = chunks_reader |
| 120 | .filter_chunksrust-analyzer cargo exr 1.74.0 block/reader/impl#[`Reader<R>`]filter_chunks().(pedantic, |meta, tile, block| { |
| 121 | image_collector.filter_blockrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ImageWithAttributesReader<L>`]filter_block().(meta, tile, block) |
| 122 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 123 | .on_progressrust-analyzer cargo exr 1.74.0 block/reader/ChunksReader#on_progress().(on_progress); |
| 124 | |
| 125 | // TODO propagate send requirement further upwards |
| 126 | if parallel { |
| 127 | #[cfg(not(feature = "rayon"))] |
| 128 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(craterust-analyzer cargo exr 1.74.0 crate/::errorrust-analyzer cargo exr 1.74.0 error/::Errorrust-analyzer cargo exr 1.74.0 error/Error#::unsupported("parallel decompression requires the rayon feature")); |
| 129 | |
| 130 | #[cfg(feature = "rayon")] |
| 131 | block_reader.decompress_parallelrust-analyzer cargo exr 1.74.0 block/reader/ChunksReader#decompress_parallel().(pedantic, |meta_data, block|{ |
| 132 | image_collector.read_blockrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ImageWithAttributesReader<L>`]read_block().(&meta_data.headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers., block) |
| 133 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 134 | } |
| 135 | else { |
| 136 | block_reader.decompress_sequentialrust-analyzer cargo exr 1.74.0 block/reader/ChunksReader#decompress_sequential().(pedantic, |meta_data, block|{ |
| 137 | image_collector.read_blockrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ImageWithAttributesReader<L>`]read_block().(&meta_data.headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers., block) |
| 138 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 139 | } |
| 140 | |
| 141 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(image_collector.into_imagerust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ImageWithAttributesReader<L>`]into_image().()) |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /// Processes blocks from a file and collects them into a complete `Image`. |
| 146 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 147 | pub struct ImageWithAttributesReaderrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader#<L> { |
| 148 | image_attributesrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader#image_attributes.: ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#, |
| 149 | layers_readerrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader#layers_reader.: L, |
| 150 | } |
| 151 | |
| 152 | impl<L> ImageWithAttributesReaderrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader#<L> where L: LayersReaderrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader# { |
| 153 | |
| 154 | /// A new image reader with image attributes. |
| 155 | pub fn newrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ImageWithAttributesReader<L>`]new().(headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#], layers_reader: L) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ImageWithAttributesReader<L>`]> |
| 156 | { |
| 157 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ImageWithAttributesReaderrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader# { |
| 158 | image_attributesrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader#image_attributes.: headers.firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().().as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("invalid headers").shared_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#shared_attributes..clonerust-analyzer cargo exr 1.74.0 meta/header/impl#[ImageAttributes][Clone]clone().(), |
| 159 | layers_readerrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader#layers_reader., |
| 160 | }) |
| 161 | } |
| 162 | |
| 163 | /// Specify whether a single block of pixels should be loaded from the file |
| 164 | fn filter_blockrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ImageWithAttributesReader<L>`]filter_block().(&self, meta: &MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#, tile: TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#, block: BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#) -> bool { |
| 165 | self.layers_readerrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader#layers_reader..filter_blockrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader#filter_block().(meta, tile, block) |
| 166 | } |
| 167 | |
| 168 | /// Load a single pixel block, which has not been filtered, into the reader, accumulating the image |
| 169 | fn read_blockrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ImageWithAttributesReader<L>`]read_block().(&mut self, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#], block: UncompressedBlockrust-analyzer cargo exr 1.74.0 block/UncompressedBlock#) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# { |
| 170 | self.layers_readerrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader#layers_reader..read_blockrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader#read_block().(headers, block) |
| 171 | } |
| 172 | |
| 173 | /// Deliver the complete accumulated image |
| 174 | fn into_imagerust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ImageWithAttributesReader<L>`]into_image().(self) -> Imagerust-analyzer cargo exr 1.74.0 image/Image#<L::Layersrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader#Layers#> { |
| 175 | Imagerust-analyzer cargo exr 1.74.0 image/Image# { |
| 176 | attributesrust-analyzer cargo exr 1.74.0 image/Image#attributes.: self.image_attributesrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader#image_attributes., |
| 177 | layer_datarust-analyzer cargo exr 1.74.0 image/Image#layer_data.: self.layers_readerrust-analyzer cargo exr 1.74.0 image/read/image/ImageWithAttributesReader#layers_reader..into_layersrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader#into_layers().() |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | |
| 183 | /// A template that creates a `LayerReader` for each layer in the file. |
| 184 | pub trait ReadLayersrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#<'s> { |
| 185 | |
| 186 | /// The type of the resulting Layers |
| 187 | type Layersrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#Layers#; |
| 188 | |
| 189 | /// The type of the temporary layer reader |
| 190 | type Readerrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#Reader#: LayersReaderrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader#<Layersrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader#Layers# = Self::Layersrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#Layers#>; |
| 191 | |
| 192 | /// Create a single reader for a single layer |
| 193 | fn create_layers_readerrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#create_layers_reader().(&'s self, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#]) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Self::Readerrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#Reader#>; |
| 194 | |
| 195 | /// Specify that all attributes should be read from an image. |
| 196 | /// Use `from_file(path)` on the return value of this method to actually decode an image. |
| 197 | fn all_attributesrust-analyzer cargo exr 1.74.0 image/read/image/ReadLayers#all_attributes().(self) -> ReadImagerust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#<fn(f64), Self> where Self: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# { |
| 198 | ReadImagerust-analyzer cargo exr 1.74.0 image/read/image/ReadImage#::newrust-analyzer cargo exr 1.74.0 image/read/image/impl#[`ReadImage<F, L>`]new().(self, ignore_progressrust-analyzer cargo exr 1.74.0 image/ignore_progress().) |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | /// Processes pixel blocks from a file and accumulates them into a single image layer. |
| 203 | pub trait LayersReaderrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader# { |
| 204 | |
| 205 | /// The type of resulting layers |
| 206 | type Layersrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader#Layers#; |
| 207 | |
| 208 | /// Specify whether a single block of pixels should be loaded from the file |
| 209 | fn filter_blockrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader#filter_block().(&self, meta: &MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#, tile: TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#, block: BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#) -> bool; |
| 210 | |
| 211 | /// Load a single pixel block, which has not been filtered, into the reader, accumulating the layer |
| 212 | fn read_blockrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader#read_block().(&mut self, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#], block: UncompressedBlockrust-analyzer cargo exr 1.74.0 block/UncompressedBlock#) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult#; |
| 213 | |
| 214 | /// Deliver the final accumulated layers for the image |
| 215 | fn into_layersrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader#into_layers().(self) -> Self::Layersrust-analyzer cargo exr 1.74.0 image/read/image/LayersReader#Layers#; |
| 216 | } |
| 217 |