Struct exr::meta::header::Header

source ·
pub struct Header {
    pub channels: ChannelList,
    pub compression: Compression,
    pub blocks: BlockDescription,
    pub line_order: LineOrder,
    pub layer_size: Vec2<usize>,
    pub deep: bool,
    pub deep_data_version: Option<i32>,
    pub chunk_count: usize,
    pub max_samples_per_pixel: Option<usize>,
    pub shared_attributes: ImageAttributes,
    pub own_attributes: LayerAttributes,
}
Expand description

Describes a single layer in a file. A file can have any number of layers. The meta data contains one header per layer.

Fields§

§channels: ChannelList

List of channels in this layer.

§compression: Compression

How the pixel data of all channels in this layer is compressed. May be Compression::Uncompressed.

§blocks: BlockDescription

Describes how the pixels of this layer are divided into smaller blocks. A single block can be loaded without processing all bytes of a file.

Also describes whether a file contains multiple resolution levels: mip maps or rip maps. This allows loading not the full resolution, but the smallest sensible resolution.

§line_order: LineOrder

In what order the tiles of this header occur in the file.

§layer_size: Vec2<usize>

The resolution of this layer. Equivalent to the size of the DataWindow.

§deep: bool

Whether this layer contains deep data.

§deep_data_version: Option<i32>

This library supports only deep data version 1.

§chunk_count: usize

Number of chunks, that is, scan line blocks or tiles, that this image has been divided into. This number is calculated once at the beginning of the read process or when creating a header object.

This value includes all chunks of all resolution levels.

Warning This value is relied upon. You should probably use Header::with_encoding, which automatically updates the chunk count.

§max_samples_per_pixel: Option<usize>

Maximum number of samples in a single pixel in a deep image.

§shared_attributes: ImageAttributes

Includes mandatory fields like pixel aspect or display window which must be the same for all layers.

§own_attributes: LayerAttributes

Does not include the attributes required for reading the file contents. Excludes standard fields that must be the same for all headers.

Implementations§

source§

impl Header

source

pub fn new( name: Text, data_size: impl Into<Vec2<usize>>, channels: SmallVec<[ChannelDescription; 5]> ) -> Self

Create a new Header with the specified name, display window and channels. Use Header::with_encoding and the similar methods to add further properties to the header.

The other settings are left to their default values:

  • RLE compression
  • display window equal to data window
  • tiles (64 x 64 px)
  • unspecified line order
  • no custom attributes
source

pub fn with_display_window(self, display_window: IntegerBounds) -> Self

Set the display window, that is, the global clipping rectangle. Must be the same for all headers of a file.

source

pub fn with_position(self, position: Vec2<i32>) -> Self

Set the offset of this layer.

source

pub fn with_encoding( self, compression: Compression, blocks: BlockDescription, line_order: LineOrder ) -> Self

Set compression, tiling, and line order. Automatically computes chunk count.

source

pub fn with_attributes(self, own_attributes: LayerAttributes) -> Self

Set all attributes of the header that are not shared with all other headers in the image.

source

pub fn with_shared_attributes(self, shared_attributes: ImageAttributes) -> Self

Set all attributes of the header that are shared with all other headers in the image.

source

pub fn enumerate_ordered_blocks( &self ) -> impl Iterator<Item = (usize, TileIndices)> + Send

Iterate over all blocks, in the order specified by the headers line order attribute. Unspecified line order is treated as increasing line order. Also enumerates the index of each block in the header, as if it were sorted in increasing line order.

source

pub fn blocks_increasing_y_order( &self ) -> impl Iterator<Item = TileIndices> + ExactSizeIterator + DoubleEndedIterator

Iterate over all tile indices in this header in LineOrder::Increasing order.

source

pub fn max_block_pixel_size(&self) -> Vec2<usize>

The default pixel resolution of a single block (tile or scan line block). Not all blocks have this size, because they may be cutoff at the end of the image.

source

pub fn get_block_data_window_pixel_coordinates( &self, tile: TileCoordinates ) -> Result<IntegerBounds>

Calculate the position of a block in the global infinite 2D space of a file. May be negative.

source

pub fn get_absolute_block_pixel_coordinates( &self, tile: TileCoordinates ) -> Result<IntegerBounds>

Calculate the pixel index rectangle inside this header. Is not negative. Starts at 0.

source

pub fn get_block_data_indices( &self, block: &CompressedBlock ) -> Result<TileCoordinates>

Return the tile index, converting scan line block coordinates to tile indices. Starts at 0 and is not negative.

source

pub fn get_scan_line_block_tile_coordinates( &self, block_y_coordinate: i32 ) -> Result<TileCoordinates>

Computes the absolute tile coordinate data indices, which start at 0.

source

pub fn max_block_byte_size(&self) -> usize

Maximum byte length of an uncompressed or compressed block, used for validation.

source

pub fn total_pixel_bytes(&self) -> usize

Returns the number of bytes that the pixels of this header will require when stored without compression. Respects multi-resolution levels and subsampling.

source

pub fn max_pixel_file_bytes(&self) -> usize

Approximates the maximum number of bytes that the pixels of this header will consume in a file. Due to compression, the actual byte size may be smaller.

source

pub fn validate( &self, is_multilayer: bool, long_names: &mut bool, strict: bool ) -> UnitResult

Validate this instance.

source

pub fn read_all( read: &mut PeekRead<impl Read>, version: &Requirements, pedantic: bool ) -> Result<Headers>

Read the headers without validating them.

source

pub fn write_all( headers: &[Header], write: &mut impl Write, is_multilayer: bool ) -> UnitResult

Without validation, write the headers to the byte stream.

source

pub fn read( read: &mut PeekRead<impl Read>, requirements: &Requirements, pedantic: bool ) -> Result<Self>

Read the value without validating.

source

pub fn write(&self, write: &mut impl Write) -> UnitResult

Without validation, write this instance to the byte stream.

source

pub fn data_window(&self) -> IntegerBounds

The rectangle describing the bounding box of this layer within the infinite global 2D space of the file.

Trait Implementations§

source§

impl Clone for Header

source§

fn clone(&self) -> Header

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Header

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<Header> for Header

source§

fn eq(&self, other: &Header) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Header

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.