Skip to main content

ImageFrame

Struct ImageFrame 

Source
pub struct ImageFrame<P, E, D> { /* private fields */ }
Expand description

A decoded still image. Not on the timeline — no pts, no duration (the same fact AttachmentPacket states on the packet side).

The fourth household, and the only one with no timestamps. Cover art, an embedded thumbnail, a poster frame: one picture, present for the whole file or not at all. Giving it pts / duration seats that are always None would invite a caller to read them and a backend to invent them, which is why they are absent rather than empty.

Generic parameters — the same three VideoFrame carries:

  • P — pixel-format identifier.
  • E — backend-specific frame extras (EXIF, ICC, side data).
  • D — plane data buffer type (D: AsRef<[u8]> at the use site).

dimensions is the coded size and visible_rect (when present) the displayable subregion — the distinction is not academic for a still: a JPEG’s coded dimensions are rounded up to its MCU grid (8 or 16 pixels), so a 30×30 photograph is coded 32×32 and only visible_rect says which of those pixels are the picture.

plane_count is the number of populated entries in planes, and the four slots are the video household’s cap for the same reasons: packed RGB = 1, MJPEG’s YUV = 3, either of those plus alpha = 4.

Implementations§

Source§

impl<P, E, D> ImageFrame<P, E, D>

Source

pub const fn new( dimensions: Dimensions, pixel_format: P, planes: [Plane<D>; 4], plane_count: u8, extra: E, ) -> Self

Constructs an ImageFrame. visible_rect defaults to None, color to ColorInfo::UNSPECIFIED.

dimensions is the coded width/height pair (see Dimensions and Self::dimensions for the visible-vs-coded distinction).

§Panics

Panics if plane_count > 4. The fixed-size planes array has four slots; passing a larger plane_count would later trip the slice indexing inside Self::planes far from the construction site. Asserting here fails fast with a clear message instead. Prefer Self::try_new when plane_count can’t be statically proven <= 4.

Source

pub fn try_new( dimensions: Dimensions, pixel_format: P, planes: [Plane<D>; 4], plane_count: u8, extra: E, ) -> Result<Self, FrameError>

Fallible counterpart to Self::new. Returns FrameError::TooManyImagePlanes when plane_count > 4 (the fixed plane array’s capacity) rather than panicking.

Not const fn — see the rationale on VideoFrame::try_new.

Source

pub const fn dimensions(&self) -> Dimensions

Returns the coded dimensions.

Source

pub const fn width(&self) -> u32

Returns the coded width.

Source

pub const fn height(&self) -> u32

Returns the coded height.

Source

pub const fn visible_rect(&self) -> Option<Rect>

Returns the visible / true-picture rectangle, if any.

Source

pub const fn pixel_format(&self) -> &P

Returns a reference to the pixel format identifier.

Source

pub const fn plane_count(&self) -> u8

Returns the populated plane count.

Source

pub fn planes(&self) -> &[Plane<D>]

Returns the populated planes as a slice.

Source

pub fn plane(&self, i: usize) -> Option<&Plane<D>>

Returns one plane by index, or None if out of range.

Source

pub fn color(&self) -> ColorInfo

Returns the color metadata.

Not const, for the same reason as VideoFrame::color.

Source

pub const fn extra(&self) -> &E

Returns the backend extras.

Source

pub const fn extra_mut(&mut self) -> &mut E

Returns a mutable reference to the backend extras.

Source

pub const fn with_visible_rect(self, v: Option<Rect>) -> Self

Sets the visible rect (consuming builder).

Source

pub fn with_color(self, v: ColorInfo) -> Self

Sets the color metadata (consuming builder).

Not const, for the same reason as VideoFrame::with_color.

Source

pub const fn set_visible_rect(&mut self, v: Option<Rect>) -> &mut Self

Sets the visible rect in place.

Source

pub fn set_color(&mut self, v: ColorInfo) -> &mut Self

Sets the color metadata in place.

Not const, for the same reason as VideoFrame::with_color.

Trait Implementations§

Source§

impl<P: Clone, E: Clone, D: Clone> Clone for ImageFrame<P, E, D>

Source§

fn clone(&self) -> ImageFrame<P, E, D>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<P, E, D> Freeze for ImageFrame<P, E, D>
where P: Freeze, [Plane<D>; 4]: Freeze, E: Freeze,

§

impl<P, E, D> RefUnwindSafe for ImageFrame<P, E, D>

§

impl<P, E, D> Send for ImageFrame<P, E, D>
where P: Send, [Plane<D>; 4]: Send, E: Send,

§

impl<P, E, D> Sync for ImageFrame<P, E, D>
where P: Sync, [Plane<D>; 4]: Sync, E: Sync,

§

impl<P, E, D> Unpin for ImageFrame<P, E, D>
where P: Unpin, [Plane<D>; 4]: Unpin, E: Unpin,

§

impl<P, E, D> UnsafeUnpin for ImageFrame<P, E, D>
where P: UnsafeUnpin, [Plane<D>; 4]: UnsafeUnpin, E: UnsafeUnpin,

§

impl<P, E, D> UnwindSafe for ImageFrame<P, E, D>
where P: UnwindSafe, [Plane<D>; 4]: UnwindSafe, E: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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, 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

Source§

type Error = !

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.