Struct exr::image::Layer

source ·
pub struct Layer<Channels> {
    pub channel_data: Channels,
    pub attributes: LayerAttributes,
    pub size: Vec2<usize>,
    pub encoding: Encoding,
}
Expand description

A single Layer, including fancy attributes and compression settings. Channels can be either SpecificChannels or AnyChannels

Fields§

§channel_data: Channels

The actual pixel data. Either SpecificChannels or AnyChannels

§attributes: LayerAttributes

Attributes that apply to this layer. May still contain attributes that should be considered global for an image file. Excludes technical meta data: Does not contain data window size, line order, tiling, or compression attributes. The image also has attributes, which do not differ per layer.

§size: Vec2<usize>

The pixel resolution of this layer. See layer.attributes for more attributes, like for example layer position.

§encoding: Encoding

How the pixels are split up and compressed.

Implementations§

source§

impl<Channels> Layer<Channels>

source

pub fn absolute_bounds(&self) -> IntegerBounds

Sometimes called “data window”

source§

impl Layer<AnyChannels<FlatSamples>>

source

pub fn sample_vec_at(&self, position: Vec2<usize>) -> FlatSamplesPixel

Use samples_at if you can borrow from this layer

source

pub fn samples_at(&self, position: Vec2<usize>) -> FlatSampleIterator<'_>

Lookup all channels of a single pixel in the image

source§

impl<'s, ChannelData: 's> Layer<ChannelData>

source

pub fn new( dimensions: impl Into<Vec2<usize>>, attributes: LayerAttributes, encoding: Encoding, channels: ChannelData ) -> Selfwhere ChannelData: WritableChannels<'s>,

Create a layer with the specified size, attributes, encoding and channels. The channels can be either SpecificChannels or AnyChannels.

source

pub fn levels_with_resolution<'l, L>( &self, levels: &'l Levels<L> ) -> Box<dyn Iterator<Item = (&'l L, Vec2<usize>)> + 'l>

Panics for images with Scanline encoding.

Trait Implementations§

source§

impl ApplyCroppedView for Layer<CroppedChannels<AnyChannels<FlatSamples>>>

§

type Reallocated = Layer<AnyChannels<FlatSamples>>

The simpler type after cropping is realized
source§

fn reallocate_cropped(self) -> Self::Reallocated

Make the cropping real by reallocating the underlying storage, with the goal of reducing total memory usage. Currently not supported for SpecificChannels.
source§

impl<Channels: Clone> Clone for Layer<Channels>

source§

fn clone(&self) -> Layer<Channels>

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<Channels> Crop for Layer<Channels>

§

type Cropped = Layer<CroppedChannels<Channels>>

The type of this image after cropping (probably the same as before)
source§

fn crop(self, bounds: IntegerBounds) -> Self::Cropped

Crop the image to exclude unwanted pixels. Panics for invalid (larger than previously) bounds. The bounds are specified in absolute coordinates. Does not reduce allocation size of the current image, but instead only adjust a few boundary numbers. Use reallocate_cropped() on the return value to actually reduce the memory footprint.
source§

fn try_crop( self, bounds: Option<IntegerBounds> ) -> CropResult<Self::Cropped, Self>

Reduce your image to a smaller part, usually to save memory. Crop if bounds are specified, return the original if no bounds are specified. Does not reduce allocation size of the current image, but instead only adjust a few boundary numbers. Use reallocate_cropped() on the return value to actually reduce the memory footprint.
source§

impl<Channels: Debug> Debug for Layer<Channels>

source§

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

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

impl<S> GetBounds for Layer<S>

source§

fn bounds(&self) -> IntegerBounds

The bounding rectangle of this pixel grid.
source§

impl InspectSample for Layer<AnyChannels<FlatSamples>>

§

type Sample = SmallVec<[Sample; 8]>

The type of pixel in this pixel grid.
source§

fn inspect_sample(&self, local_index: Vec2<usize>) -> FlatSamplesPixel

Index is not in world coordinates, but within the data window. Position (0,0) always represents the top left pixel.
source§

impl<Samples, Channels> InspectSample for Layer<SpecificChannels<Samples, Channels>>where Samples: GetPixel,

§

type Sample = <Samples as GetPixel>::Pixel

The type of pixel in this pixel grid.
source§

fn inspect_sample(&self, local_index: Vec2<usize>) -> Samples::Pixel

Index is not in world coordinates, but within the data window. Position (0,0) always represents the top left pixel.
source§

impl<Channels: PartialEq> PartialEq<Layer<Channels>> for Layer<Channels>

source§

fn eq(&self, other: &Layer<Channels>) -> 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<S> ValidateResult for Layer<AnyChannels<S>>where AnyChannel<S>: ValidateResult, S: for<'a> WritableSamples<'a>,

source§

fn validate_result( &self, other: &Self, _overridden: ValidationOptions, location: impl Fn() -> String ) -> ValidationResult

Compare self with the other. Exceptional behaviour: Read more
source§

fn assert_equals_result(&self, result: &Self)

Compare self with the other. Panics if not equal. Read more
source§

impl<Px, Desc> ValidateResult for Layer<SpecificChannels<Px, Desc>>where SpecificChannels<Px, Desc>: ValidateResult,

source§

fn validate_result( &self, other: &Self, _overridden: ValidationOptions, location: impl Fn() -> String ) -> ValidationResult

This does an approximate comparison for all channels, even if some channels can be compressed without loss.

source§

fn assert_equals_result(&self, result: &Self)

Compare self with the other. Panics if not equal. Read more
source§

impl<'slf, Channels: WritableChannels<'slf>> WritableLayers<'slf> for Layer<Channels>

source§

fn infer_headers(&self, image_attributes: &ImageAttributes) -> Headers

Generate the file meta data for this list of layers
§

type Writer = LayerWriter<<Channels as WritableChannels<'slf>>::Writer>

The type of temporary writer
source§

fn create_writer(&'slf self, headers: &[Header]) -> Self::Writer

Create a temporary writer for this list of layers
source§

impl<Channels> StructuralPartialEq for Layer<Channels>

Auto Trait Implementations§

§

impl<Channels> RefUnwindSafe for Layer<Channels>where Channels: RefUnwindSafe,

§

impl<Channels> Send for Layer<Channels>where Channels: Send,

§

impl<Channels> Sync for Layer<Channels>where Channels: Sync,

§

impl<Channels> Unpin for Layer<Channels>where Channels: Unpin,

§

impl<Channels> UnwindSafe for Layer<Channels>where Channels: UnwindSafe,

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> CropWhere<<T as InspectSample>::Sample> for Twhere T: Crop + InspectSample,

§

type Cropped = <T as Crop>::Cropped

The type of the cropped image (probably the same as the original image).
source§

fn crop_where( self, discard_if: impl Fn(<T as InspectSample>::Sample) -> bool ) -> CropResult<<T as CropWhere<<T as InspectSample>::Sample>>::Cropped, T>

Crop away unwanted pixels from the border if they match the specified rule. Does not reduce allocation size of the current image, but instead only adjust a few boundary numbers. Use reallocate_cropped() on the return value to actually reduce the memory footprint.
source§

fn crop_where_eq( self, discard_color: impl Into<<T as InspectSample>::Sample> ) -> CropResult<<T as CropWhere<<T as InspectSample>::Sample>>::Cropped, T>where <T as InspectSample>::Sample: PartialEq<<T as InspectSample>::Sample>,

Crop away unwanted pixels from the border if they match the specified color. If you want discard based on a rule, use crop_where with a closure instead. Does not reduce allocation size of the current image, but instead only adjust a few boundary numbers. Use reallocate_cropped() on the return value to actually reduce the memory footprint.
source§

fn crop_nowhere(self) -> <T as CropWhere<<T as InspectSample>::Sample>>::Cropped

Convert this data to cropped data without discarding any pixels.
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.