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: boolIf true, tells encoders to not encode this image, to instead send “blank”
Implementations§
Source§impl ImageFrame
impl ImageFrame
Sourcepub const INTERNAL_MEMORY_LAYOUT: MemoryOrderLayout = MemoryOrderLayout::HeightsWidthsChannels
pub const INTERNAL_MEMORY_LAYOUT: MemoryOrderLayout = MemoryOrderLayout::HeightsWidthsChannels
The internal memory layout used for storing pixel data
Sourcepub fn new(
channel_format: &ColorChannelLayout,
color_space: &ColorSpace,
xy_resolution: &ImageXYResolution,
) -> Result<ImageFrame, FeagiDataError>
pub fn new( channel_format: &ColorChannelLayout, color_space: &ColorSpace, xy_resolution: &ImageXYResolution, ) -> Result<ImageFrame, FeagiDataError>
Creates a new ImageFrame with zero-filled pixel data.
Sourcepub fn new_from_image_frame_properties(
image_frame_properties: &ImageFrameProperties,
) -> Result<ImageFrame, FeagiDataError>
pub fn new_from_image_frame_properties( image_frame_properties: &ImageFrameProperties, ) -> Result<ImageFrame, FeagiDataError>
Creates a new ImageFrame from ImageFrameProperties.
Sourcepub fn from_array(
input: ArrayBase<OwnedRepr<u8>, Dim<[usize; 3]>>,
color_space: &ColorSpace,
source_memory_order: &MemoryOrderLayout,
) -> Result<ImageFrame, FeagiDataError>
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.
pub fn new_from_dynamic_image( img: DynamicImage, color_space: &ColorSpace, ) -> Result<ImageFrame, FeagiDataError>
pub fn new_from_png_bytes( input: &[u8], color_space: &ColorSpace, ) -> Result<ImageFrame, FeagiDataError>
pub fn new_from_bmp_bytes( input: &[u8], color_space: &ColorSpace, ) -> Result<ImageFrame, FeagiDataError>
pub fn new_from_jpeg_bytes( input: &[u8], color_space: &ColorSpace, ) -> Result<ImageFrame, FeagiDataError>
pub fn new_from_tiff_bytes( input: &[u8], color_space: &ColorSpace, ) -> Result<ImageFrame, FeagiDataError>
Sourcepub fn get_image_frame_properties(&self) -> ImageFrameProperties
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.
Sourcepub fn get_channel_layout(&self) -> &ColorChannelLayout
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.
Sourcepub fn get_color_space(&self) -> &ColorSpace
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.
Sourcepub fn get_color_channel_count(&self) -> usize
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
Sourcepub fn get_pixels_view(&self) -> ArrayBase<ViewRepr<&u8>, Dim<[usize; 3]>>
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
Sourcepub fn get_pixels_view_mut(
&mut self,
) -> ArrayBase<ViewRepr<&mut u8>, Dim<[usize; 3]>>
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.
Sourcepub fn get_xy_resolution(&self) -> ImageXYResolution
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.
Sourcepub fn get_number_elements(&self) -> usize
pub fn get_number_elements(&self) -> usize
Returns the total number of elements (height × width × channels).
Sourcepub fn get_dimensions(&self) -> ImageXYZDimensions
pub fn get_dimensions(&self) -> ImageXYZDimensions
Returns the 3D dimensions (height, width, channels) of the image.
Sourcepub fn get_internal_data(&self) -> &ArrayBase<OwnedRepr<u8>, Dim<[usize; 3]>>
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
§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.
Sourcepub fn get_internal_data_mut(
&mut self,
) -> &mut ArrayBase<OwnedRepr<u8>, Dim<[usize; 3]>>
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
pub fn get_internal_byte_data(&self) -> &[u8] ⓘ
pub fn get_internal_byte_data_mut(&mut self) -> &mut [u8] ⓘ
Sourcepub fn export_as_dynamic_image(&self) -> Result<DynamicImage, FeagiDataError>
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.
Sourcepub fn export_as_png_bytes(&self) -> Result<Vec<u8>, FeagiDataError>
pub fn export_as_png_bytes(&self) -> Result<Vec<u8>, FeagiDataError>
Sourcepub fn export_as_bmp_bytes(&self) -> Result<Vec<u8>, FeagiDataError>
pub fn export_as_bmp_bytes(&self) -> Result<Vec<u8>, FeagiDataError>
Sourcepub fn export_as_jpeg_bytes(&self) -> Result<Vec<u8>, FeagiDataError>
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
Sourcepub fn export_as_tiff_bytes(&self) -> Result<Vec<u8>, FeagiDataError>
pub fn export_as_tiff_bytes(&self) -> Result<Vec<u8>, FeagiDataError>
Sourcepub fn change_brightness(&mut self, value: i32)
pub fn change_brightness(&mut self, value: i32)
Apply in-place brightness adjustment
value = signed integer added to each channel (only in gamma space)
Sourcepub fn change_contrast(&mut self, factor: f32)
pub fn change_contrast(&mut self, factor: f32)
Apply in-place contrast adjustment
factor = multiplier (>1 = increase contrast, <1 = reduce)
pub fn blink_image(&mut self)
Trait Implementations§
Source§impl Clone for ImageFrame
impl Clone for ImageFrame
Source§fn clone(&self) -> ImageFrame
fn clone(&self) -> ImageFrame
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImageFrame
impl Debug for ImageFrame
Source§impl Display for ImageFrame
impl Display for ImageFrame
Source§impl From<ImageFrame> for WrappedIOData
impl From<ImageFrame> for WrappedIOData
Source§fn from(value: ImageFrame) -> WrappedIOData
fn from(value: ImageFrame) -> WrappedIOData
Source§impl<'a> TryFrom<&'a WrappedIOData> for &'a ImageFrame
impl<'a> TryFrom<&'a WrappedIOData> for &'a ImageFrame
Source§type Error = FeagiDataError
type Error = FeagiDataError
Source§fn try_from(
value: &'a WrappedIOData,
) -> Result<&'a ImageFrame, <&'a ImageFrame as TryFrom<&'a WrappedIOData>>::Error>
fn try_from( value: &'a WrappedIOData, ) -> Result<&'a ImageFrame, <&'a ImageFrame as TryFrom<&'a WrappedIOData>>::Error>
Source§impl TryFrom<&WrappedIOData> for ImageFrame
impl TryFrom<&WrappedIOData> for ImageFrame
Source§type Error = FeagiDataError
type Error = FeagiDataError
Source§fn try_from(
value: &WrappedIOData,
) -> Result<ImageFrame, <ImageFrame as TryFrom<&WrappedIOData>>::Error>
fn try_from( value: &WrappedIOData, ) -> Result<ImageFrame, <ImageFrame as TryFrom<&WrappedIOData>>::Error>
Source§impl<'a> TryFrom<&'a mut WrappedIOData> for &'a mut ImageFrame
impl<'a> TryFrom<&'a mut WrappedIOData> for &'a mut ImageFrame
Source§type Error = FeagiDataError
type Error = FeagiDataError
Source§fn try_from(
value: &'a mut WrappedIOData,
) -> Result<&'a mut ImageFrame, <&'a mut ImageFrame as TryFrom<&'a mut WrappedIOData>>::Error>
fn try_from( value: &'a mut WrappedIOData, ) -> Result<&'a mut ImageFrame, <&'a mut ImageFrame as TryFrom<&'a mut WrappedIOData>>::Error>
Source§impl TryFrom<WrappedIOData> for ImageFrame
impl TryFrom<WrappedIOData> for ImageFrame
Source§type Error = FeagiDataError
type Error = FeagiDataError
Source§fn try_from(
value: WrappedIOData,
) -> Result<ImageFrame, <ImageFrame as TryFrom<WrappedIOData>>::Error>
fn try_from( value: WrappedIOData, ) -> Result<ImageFrame, <ImageFrame as TryFrom<WrappedIOData>>::Error>
Auto Trait Implementations§
impl Freeze for ImageFrame
impl RefUnwindSafe for ImageFrame
impl Send for ImageFrame
impl Sync for ImageFrame
impl Unpin for ImageFrame
impl UnwindSafe for ImageFrame
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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.