pub struct Image888Fixed<const W: usize, const H: usize, const N: usize> {
pub pixels: [[u8; 3]; N],
}Expand description
A fixed-size RGB888 source image stored directly in the value.
W and H are the image dimensions and N is the pixel count (W * H).
Use tga! to embed and decode an image
file at compile time, then convert it to display-ready RGB565 storage or a
visibility mask. See the visual MaskFixed example for
color-key transparency.
§Example
use device_envoy_core::cyd::display::{Image565Fixed, Image888Fixed, tga};
const SOURCE: Image888Fixed<45, 73, { 45 * 73 }> = tga!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/docs/assets/cyd_fill_contiguous.tga"
));
const IMAGE: Image565Fixed<45, 73, { 45 * 73 }> = SOURCE.to_565();
assert_eq!(SOURCE.pixels.len(), 45 * 73);
assert_eq!(IMAGE.pixels.len(), 45 * 73);Fields§
§pixels: [[u8; 3]; N]Row-major, top-left-origin pixels stored as [red, green, blue].
Implementations§
Source§impl<const W: usize, const H: usize, const N: usize> Image888Fixed<W, H, N>
impl<const W: usize, const H: usize, const N: usize> Image888Fixed<W, H, N>
Sourcepub const fn from_tga(bytes: &[u8]) -> Self
pub const fn from_tga(bytes: &[u8]) -> Self
Decodes a supported TGA at compile time, preserving RGB and discarding alpha.
Prefer the public tga! macro shown in
its compiled example. This constructor powers that macro when raw TGA
bytes are already available.
Panics during const evaluation if N != W * H or the bytes do not
contain a supported TGA with matching dimensions.
Sourcepub const fn to_565(&self) -> Image565Fixed<W, H, N>
pub const fn to_565(&self) -> Image565Fixed<W, H, N>
Converts this source image to RGB565.
Each channel is reduced to the RGB565 bit depth. See the
Image565Fixed example.
Sourcepub const fn to_mask_magenta<const MASK_N: usize>(
&self,
) -> MaskFixed<W, H, MASK_N>
pub const fn to_mask_magenta<const MASK_N: usize>( &self, ) -> MaskFixed<W, H, MASK_N>
Derives a binary visibility mask using magenta as the transparent color.
Pixels with red and blue at least 200 and green at most 60 become
transparent; all other pixels remain visible. See the
MaskFixed example.
Panics during const evaluation if MASK_N does not equal
mask_byte_count(W, H).