Skip to main content

ImageFrame

Struct ImageFrame 

Source
pub struct ImageFrame {
    pub skip_encoding: bool,
    /* private fields */
}
Expand description

A container for image data with support for various color formats and spaces.

Stores pixel data as a 3D array with height, width, and channel dimensions. Supports RGB/RGBA formats and different color spaces (sRGB, Linear, Gamma). Can import/export various image formats and convert between color spaces.

Fields§

§skip_encoding: bool

If true, tells encoders to not encode this image, to instead send “blank”

Implementations§

Source§

impl ImageFrame

Source

pub const INTERNAL_MEMORY_LAYOUT: MemoryOrderLayout = MemoryOrderLayout::HeightsWidthsChannels

The internal memory layout used for storing pixel data

Source

pub fn new( channel_format: &ColorChannelLayout, color_space: &ColorSpace, xy_resolution: &ImageXYResolution, ) -> Result<ImageFrame, FeagiDataError>

Creates a new ImageFrame with zero-filled pixel data.

Source

pub fn new_from_image_frame_properties( image_frame_properties: &ImageFrameProperties, ) -> Result<ImageFrame, FeagiDataError>

Creates a new ImageFrame from ImageFrameProperties.

Source

pub fn from_array( input: ArrayBase<OwnedRepr<u8>, Dim<[usize; 3]>>, color_space: &ColorSpace, source_memory_order: &MemoryOrderLayout, ) -> Result<ImageFrame, FeagiDataError>

Creates an ImageFrame from a 3D array with specified memory layout.

Source

pub fn new_from_dynamic_image( img: DynamicImage, color_space: &ColorSpace, ) -> Result<ImageFrame, FeagiDataError>

Source

pub fn new_from_png_bytes( input: &[u8], color_space: &ColorSpace, ) -> Result<ImageFrame, FeagiDataError>

Source

pub fn new_from_bmp_bytes( input: &[u8], color_space: &ColorSpace, ) -> Result<ImageFrame, FeagiDataError>

Source

pub fn new_from_jpeg_bytes( input: &[u8], color_space: &ColorSpace, ) -> Result<ImageFrame, FeagiDataError>

Source

pub fn new_from_tiff_bytes( input: &[u8], color_space: &ColorSpace, ) -> Result<ImageFrame, FeagiDataError>

Source

pub fn get_image_frame_properties(&self) -> ImageFrameProperties

Returns the properties of this image frame.

Creates an ImageFrameProperties struct that describes this frame’s resolution, color space, and channel layout.

§Returns

An ImageFrameProperties struct containing this frame’s properties.

Source

pub fn get_channel_layout(&self) -> &ColorChannelLayout

Returns a reference to the channel layout of this image.

§Returns

A reference to the ChannelLayout enum value representing the image’s color channel format.

Source

pub fn get_color_space(&self) -> &ColorSpace

Returns a reference to the color space of this image.

§Returns

A reference to the ColorSpace enum value representing the image’s color space.

Source

pub fn get_color_channel_count(&self) -> usize

Returns the number of color channels in this ImageFrame.

§Returns

The number of color channels as an usize:

  • 1 for GrayScale
  • 2 for RG
  • 3 for RGB
  • 4 for RGBA
Source

pub fn get_pixels_view(&self) -> ArrayBase<ViewRepr<&u8>, Dim<[usize; 3]>>

Returns a read-only view of the pixel data.

This provides access to the underlying 3D ndarray of pixel values.

§Returns

An ArrayView3 containing the pixel data.

Source

pub fn get_pixels_view_mut( &mut self, ) -> ArrayBase<ViewRepr<&mut u8>, Dim<[usize; 3]>>

Returns a mutable view of the pixel data as a 3D array.

Source

pub fn get_xy_resolution(&self) -> ImageXYResolution

Returns the resolution of the image in cartesian space (width, height)

§Returns

A tuple of (width, height) representing the image dimensions in pixels.

Source

pub fn get_number_elements(&self) -> usize

Returns the total number of elements (height × width × channels).

Source

pub fn get_dimensions(&self) -> ImageXYZDimensions

Returns the 3D dimensions (height, width, channels) of the image.

Source

pub fn get_internal_data(&self) -> &ArrayBase<OwnedRepr<u8>, Dim<[usize; 3]>>

Returns a reference to the internal pixel data array.

Provides direct access to the underlying 3D array containing the pixel data. The array is organized as (height, width, channels) following row-major ordering.

§Returns

A reference to the Array3 containing the raw pixel data.

§Safety

This method provides direct access to internal data. Modifying the array through this reference could break invariants. Use get_internal_data_mut() for safe mutable access.

Source

pub fn get_internal_data_mut( &mut self, ) -> &mut ArrayBase<OwnedRepr<u8>, Dim<[usize; 3]>>

Returns a mutable reference to the internal pixel data array.

Provides mutable access to the underlying 3D array containing the pixel data. Be cautious when using this as you can easily set the data to an invalid state!

§Returns

A mutable reference to the Array3 containing the raw pixel data.

Source

pub fn get_internal_byte_data(&self) -> &[u8]

Source

pub fn get_internal_byte_data_mut(&mut self) -> &mut [u8]

Source

pub fn export_as_dynamic_image(&self) -> Result<DynamicImage, FeagiDataError>

Exports the ImageFrame as a DynamicImage from the image crate.

This converts the internal pixel data back to a format that can be used with the image crate for further processing or saving.

§Returns

A DynamicImage containing the pixel data from this ImageFrame.

Source

pub fn export_as_png_bytes(&self) -> Result<Vec<u8>, FeagiDataError>

Exports the ImageFrame as PNG bytes.

§Returns

A Vec containing the PNG-encoded image data.

Source

pub fn export_as_bmp_bytes(&self) -> Result<Vec<u8>, FeagiDataError>

Exports the ImageFrame as BMP bytes.

§Returns

A Vec containing the BMP-encoded image data.

Source

pub fn export_as_jpeg_bytes(&self) -> Result<Vec<u8>, FeagiDataError>

Exports the ImageFrame as JPEG bytes.

Note: JPEG format does not support transparency, so RGBA images will be converted to RGB by discarding the alpha channel.

§Returns

A Vec containing the JPEG-encoded image data.

Source

pub fn export_as_tiff_bytes(&self) -> Result<Vec<u8>, FeagiDataError>

Exports the ImageFrame as TIFF bytes.

§Returns

A Vec containing the TIFF-encoded image data.

Source

pub fn change_brightness(&mut self, value: i32)

Apply in-place brightness adjustment value = signed integer added to each channel (only in gamma space)

Source

pub fn change_contrast(&mut self, factor: f32)

Apply in-place contrast adjustment factor = multiplier (>1 = increase contrast, <1 = reduce)

Trait Implementations§

Source§

impl Clone for ImageFrame

Source§

fn clone(&self) -> ImageFrame

Returns a duplicate 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 ImageFrame

Source§

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

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

impl Display for ImageFrame

Source§

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

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

impl From<ImageFrame> for WrappedIOData

Source§

fn from(value: ImageFrame) -> WrappedIOData

Converts to this type from the input type.
Source§

impl<'a> TryFrom<&'a WrappedIOData> for &'a ImageFrame

Source§

type Error = FeagiDataError

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

fn try_from( value: &'a WrappedIOData, ) -> Result<&'a ImageFrame, <&'a ImageFrame as TryFrom<&'a WrappedIOData>>::Error>

Performs the conversion.
Source§

impl TryFrom<&WrappedIOData> for ImageFrame

Source§

type Error = FeagiDataError

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

fn try_from( value: &WrappedIOData, ) -> Result<ImageFrame, <ImageFrame as TryFrom<&WrappedIOData>>::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a mut WrappedIOData> for &'a mut ImageFrame

Source§

type Error = FeagiDataError

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

fn try_from( value: &'a mut WrappedIOData, ) -> Result<&'a mut ImageFrame, <&'a mut ImageFrame as TryFrom<&'a mut WrappedIOData>>::Error>

Performs the conversion.
Source§

impl TryFrom<WrappedIOData> for ImageFrame

Source§

type Error = FeagiDataError

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

fn try_from( value: WrappedIOData, ) -> Result<ImageFrame, <ImageFrame as TryFrom<WrappedIOData>>::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more