Skip to main content

Image565Fixed

Struct Image565Fixed 

Source
pub struct Image565Fixed<const W: usize, const H: usize, const N: usize> {
    pub pixels: [u16; N],
}
Expand description

A fixed-size RGB565 image stored directly in the value.

W and H are the image dimensions and N is the pixel count (W * H). The image has no alpha channel. Use MaskFixed and MaskedDrawable::draw_masked when color-key transparency is needed. The visual MaskFixed example shows the opaque source and masked result side by side. Convert a compile-time Image888Fixed with Image888Fixed::to_565.

Use Image565Fixed::view to borrow the complete image as an Image565View, or Image565Fixed::view_rect to borrow a crop without copying pixels.

§Example

Fields§

§pixels: [u16; N]

Row-major, top-left-origin pixels packed as RRRRR_GGGGGG_BBBBB.

Implementations§

Source§

impl<const W: usize, const H: usize, const N: usize> Image565Fixed<W, H, N>

Source

pub const fn at( &self, top_left: Point, ) -> impl MaskedDrawable<W, H, Color = Rgb565> + '_

Returns a lightweight value that draws this image at top_left.

Drawing the image directly places it at Point::zero. This method changes that drawing position without copying or modifying the image. The returned value supports Drawable::draw and MaskedDrawable::draw_masked. See the visual MaskFixed example for the positioned output.

Source

pub const fn view(&'static self) -> Image565View

View the complete image as RGB565 pixels.

This is a zero-copy view over the complete image. See the Image565View example.

Source

pub const fn view_rect(&'static self, source: Rectangle) -> Image565View

View a validated rectangular crop of the image without copying pixels.

source uses coordinates in the full image. Coordinates used through the returned view are local to that rectangle. See the Image565View example.

Panics if source has a negative origin or extends outside the image.

Source

pub fn copy_to<F: CydFrame>(&self, frame: &mut F) -> Result<()>

Bulk-copies the complete image into a frame with matching dimensions.

This uses CydFrame::copy_from_565 and does not flush the frame. Returns crate::Error::CopySize if the image and frame pixel counts differ.

use device_envoy_core::cyd::display::{CydFrame, Image565Fixed};

fn copy<const W: usize, const H: usize, const N: usize, F: CydFrame>(
    image: &Image565Fixed<W, H, N>,
    frame: &mut F,
) -> device_envoy_core::Result<()> {
    image.copy_to(frame)
}

Trait Implementations§

Source§

impl<const W: usize, const H: usize, const N: usize> Drawable for Image565Fixed<W, H, N>

Source§

type Color = Rgb565

The pixel color type.
Source§

type Output = ()

The return type of the draw method. Read more
Source§

fn draw<D>(&self, target: &mut D) -> Result<(), D::Error>
where D: DrawTarget<Color = Rgb565>,

Draw the graphics object using the supplied DrawTarget.
Source§

impl<const W: usize, const H: usize, const N: usize> MaskedDrawable<W, H> for Image565Fixed<W, H, N>

Source§

fn draw_masked<const MASK_N: usize, D>( &self, mask: &MaskFixed<W, H, MASK_N>, target: &mut D, ) -> Result<(), D::Error>
where D: DrawTarget<Color = Self::Color>,

Draws the image, skipping pixels whose corresponding mask bits are clear. Read more

Auto Trait Implementations§

§

impl<const W: usize, const H: usize, const N: usize> Freeze for Image565Fixed<W, H, N>
where [u16; N]: Freeze,

§

impl<const W: usize, const H: usize, const N: usize> RefUnwindSafe for Image565Fixed<W, H, N>
where [u16; N]: RefUnwindSafe,

§

impl<const W: usize, const H: usize, const N: usize> Send for Image565Fixed<W, H, N>
where [u16; N]: Send,

§

impl<const W: usize, const H: usize, const N: usize> Sync for Image565Fixed<W, H, N>
where [u16; N]: Sync,

§

impl<const W: usize, const H: usize, const N: usize> Unpin for Image565Fixed<W, H, N>
where [u16; N]: Unpin,

§

impl<const W: usize, const H: usize, const N: usize> UnsafeUnpin for Image565Fixed<W, H, N>
where [u16; N]: UnsafeUnpin,

§

impl<const W: usize, const H: usize, const N: usize> UnwindSafe for Image565Fixed<W, H, N>
where [u16; N]: 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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.