Skip to main content

HalfBlockImage

Struct HalfBlockImage 

Source
pub struct HalfBlockImage {
    pub width: u32,
    pub height: u32,
    pub pixels: Vec<(Color, Color)>,
}
Expand description

A terminal-renderable image stored as a grid of Color values.

Each cell contains a foreground color (upper pixel) and background color (lower pixel), rendered using the half-block character.

Create from an [image::DynamicImage] with [HalfBlockImage::from_dynamic] (requires image feature), or construct manually from raw RGB data with HalfBlockImage::from_rgb.

Fields§

§width: u32

Width in terminal columns.

§height: u32

Height in terminal rows (each row = 2 image pixels).

§pixels: Vec<(Color, Color)>

Row-major pairs of (upper_color, lower_color) for each cell.

Implementations§

Source§

impl HalfBlockImage

Source

pub fn from_rgb(rgb_data: &[u8], width: u32, height: u32) -> Self

Create a half-block image from raw RGB pixel data.

rgb_data must contain width x pixel_height x 3 bytes in row-major RGB order, where pixel_height = height * 2.

Auto Trait Implementations§

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

Source§

type Error = Infallible

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.