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>
impl<const W: usize, const H: usize, const N: usize> Image565Fixed<W, H, N>
Sourcepub const fn at(
&self,
top_left: Point,
) -> impl MaskedDrawable<W, H, Color = Rgb565> + '_
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.
Sourcepub const fn view(&'static self) -> Image565View
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.
Sourcepub const fn view_rect(&'static self, source: Rectangle) -> Image565View
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.
Sourcepub fn copy_to<F: CydFrame>(&self, frame: &mut F) -> Result<()>
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)
}