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>
impl<Channels> Layer<Channels>
sourcepub fn absolute_bounds(&self) -> IntegerBounds
pub fn absolute_bounds(&self) -> IntegerBounds
Sometimes called “data window”
source§impl Layer<AnyChannels<FlatSamples>>
impl Layer<AnyChannels<FlatSamples>>
sourcepub fn sample_vec_at(&self, position: Vec2<usize>) -> FlatSamplesPixel
pub fn sample_vec_at(&self, position: Vec2<usize>) -> FlatSamplesPixel
Use samples_at
if you can borrow from this layer
sourcepub fn samples_at(&self, position: Vec2<usize>) -> FlatSampleIterator<'_> ⓘ
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>
impl<'s, ChannelData: 's> Layer<ChannelData>
sourcepub fn new(
dimensions: impl Into<Vec2<usize>>,
attributes: LayerAttributes,
encoding: Encoding,
channels: ChannelData,
) -> Selfwhere
ChannelData: WritableChannels<'s>,
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
.
Trait Implementations§
source§impl ApplyCroppedView for Layer<CroppedChannels<AnyChannels<FlatSamples>>>
impl ApplyCroppedView for Layer<CroppedChannels<AnyChannels<FlatSamples>>>
source§type Reallocated = Layer<AnyChannels<FlatSamples>>
type Reallocated = Layer<AnyChannels<FlatSamples>>
source§fn reallocate_cropped(self) -> Self::Reallocated
fn reallocate_cropped(self) -> Self::Reallocated
SpecificChannels
.source§impl<Channels> Crop for Layer<Channels>
impl<Channels> Crop for Layer<Channels>
source§type Cropped = Layer<CroppedChannels<Channels>>
type Cropped = Layer<CroppedChannels<Channels>>
source§fn crop(self, bounds: IntegerBounds) -> Self::Cropped
fn crop(self, bounds: IntegerBounds) -> Self::Cropped
reallocate_cropped()
on the return value to actually reduce the memory footprint.source§fn try_crop(
self,
bounds: Option<IntegerBounds>,
) -> CropResult<Self::Cropped, Self>
fn try_crop( self, bounds: Option<IntegerBounds>, ) -> CropResult<Self::Cropped, Self>
reallocate_cropped()
on the return value to actually reduce the memory footprint.source§impl<S> GetBounds for Layer<S>
impl<S> GetBounds for Layer<S>
source§fn bounds(&self) -> IntegerBounds
fn bounds(&self) -> IntegerBounds
source§impl InspectSample for Layer<AnyChannels<FlatSamples>>
impl InspectSample for Layer<AnyChannels<FlatSamples>>
source§impl<Samples, Channels> InspectSample for Layer<SpecificChannels<Samples, Channels>>where
Samples: GetPixel,
impl<Samples, Channels> InspectSample for Layer<SpecificChannels<Samples, Channels>>where
Samples: GetPixel,
source§impl<S> ValidateResult for Layer<AnyChannels<S>>
impl<S> ValidateResult for Layer<AnyChannels<S>>
source§fn validate_result(
&self,
other: &Self,
_overridden: ValidationOptions,
location: impl Fn() -> String,
) -> ValidationResult
fn validate_result( &self, other: &Self, _overridden: ValidationOptions, location: impl Fn() -> String, ) -> ValidationResult
source§fn assert_equals_result(&self, result: &Self)
fn assert_equals_result(&self, result: &Self)
source§impl<Px, Desc> ValidateResult for Layer<SpecificChannels<Px, Desc>>where
SpecificChannels<Px, Desc>: ValidateResult,
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
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)
fn assert_equals_result(&self, result: &Self)
source§impl<'slf, Channels: WritableChannels<'slf>> WritableLayers<'slf> for Layer<Channels>
impl<'slf, Channels: WritableChannels<'slf>> WritableLayers<'slf> for Layer<Channels>
source§fn infer_headers(&self, image_attributes: &ImageAttributes) -> Headers
fn infer_headers(&self, image_attributes: &ImageAttributes) -> Headers
source§type Writer = LayerWriter<<Channels as WritableChannels<'slf>>::Writer>
type Writer = LayerWriter<<Channels as WritableChannels<'slf>>::Writer>
source§fn create_writer(&'slf self, headers: &[Header]) -> Self::Writer
fn create_writer(&'slf self, headers: &[Header]) -> Self::Writer
impl<Channels> StructuralPartialEq for Layer<Channels>
Auto Trait Implementations§
impl<Channels> Freeze for Layer<Channels>where
Channels: Freeze,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CropWhere<<T as InspectSample>::Sample> for Twhere
T: Crop + InspectSample,
impl<T> CropWhere<<T as InspectSample>::Sample> for Twhere
T: Crop + InspectSample,
source§type Cropped = <T as Crop>::Cropped
type Cropped = <T as Crop>::Cropped
source§fn crop_where(
self,
discard_if: impl Fn(<T as InspectSample>::Sample) -> bool,
) -> CropResult<<T as CropWhere<<T as InspectSample>::Sample>>::Cropped, T>
fn crop_where( self, discard_if: impl Fn(<T as InspectSample>::Sample) -> bool, ) -> CropResult<<T as CropWhere<<T as InspectSample>::Sample>>::Cropped, T>
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>
fn crop_where_eq( self, discard_color: impl Into<<T as InspectSample>::Sample>, ) -> CropResult<<T as CropWhere<<T as InspectSample>::Sample>>::Cropped, T>
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.