pub enum DisplayMode {
HalfColor,
FullColor,
FullNoColor,
Ascii,
WezTerm,
WezTermNoColor,
Kitty,
KittyNoColor,
Iterm2,
Iterm2NoColor,
SixelHalf,
SixelFull,
}Expand description
The protocol of display
Variants§
HalfColor
FullColor
FullNoColor
Ascii
WezTerm
WezTermNoColor
Kitty
KittyNoColor
Iterm2
Iterm2NoColor
SixelHalf
SixelFull
Implementations§
Source§impl DisplayMode
impl DisplayMode
Sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Check if the display mode is a full block mode
Returns true for modes that use full blocks to display pixels, which includes:
DisplayMode::FullColorDisplayMode::FullNoColorDisplayMode::WezTermDisplayMode::WezTermNoColorDisplayMode::KittyDisplayMode::KittyNoColorDisplayMode::Iterm2DisplayMode::Iterm2NoColorDisplayMode::SixelFull
Returns false for modes that use half blocks or ASCII characters:
DisplayMode::HalfColorDisplayMode::AsciiDisplayMode::SixelHalf
Sourcepub fn is_color(&self) -> bool
pub fn is_color(&self) -> bool
Check if the display mode supports color output
Returns true for modes that can display colors:
DisplayMode::FullColorDisplayMode::HalfColorDisplayMode::WezTermDisplayMode::KittyDisplayMode::Iterm2DisplayMode::SixelHalfDisplayMode::SixelFull
Returns false for modes that only support grayscale/luminance output:
DisplayMode::FullNoColorDisplayMode::AsciiDisplayMode::WezTermNoColorDisplayMode::KittyNoColorDisplayMode::Iterm2NoColor
Sourcepub fn is_luma(&self) -> bool
pub fn is_luma(&self) -> bool
Check if the display mode supports only luminance/grayscale output
This is the inverse of is_color(). Returns true for modes that only display
grayscale images and false for color-capable modes.
Sourcepub fn is_normal(&self) -> bool
pub fn is_normal(&self) -> bool
Check if the display mode uses standard terminal capabilities
Returns true for basic terminal display modes that don’t require special
terminal features:
DisplayMode::HalfColorDisplayMode::FullColorDisplayMode::AsciiDisplayMode::FullNoColor
Returns false for modes that require special terminal protocols:
- WezTerm-specific modes
- Kitty-specific modes
- iTerm2-specific modes
- Sixel modes (when
sixelfeature is enabled)
Sourcepub fn is_wezterm(&self) -> bool
pub fn is_wezterm(&self) -> bool
Check if the display mode is WezTerm-specific
Returns true for both color and non-color WezTerm modes:
DisplayMode::WezTermDisplayMode::WezTermNoColor
Sourcepub fn is_iterm2(&self) -> bool
pub fn is_iterm2(&self) -> bool
Check if the display mode is iTerm2-specific
Returns true for both color and non-color iTerm2 modes:
DisplayMode::Iterm2DisplayMode::Iterm2NoColor
Sourcepub fn is_sixel(&self) -> bool
pub fn is_sixel(&self) -> bool
Check if the display mode uses Sixel graphics protocol
Available only when the sixel feature is enabled.
Returns true for Sixel modes:
DisplayMode::SixelHalfDisplayMode::SixelFull
Sourcepub fn mode(&self) -> &'static str
pub fn mode(&self) -> &'static str
Get the name of the display mode as a static string slice
This method returns a human-readable name for each display mode variant, which can be useful for debugging, logging, or user interface purposes.
§Returns
A static string slice representing the name of the display mode:
- “HalfColor” - For half-block color mode
- “FullColor” - For full-block color mode
- “FullNoColor” - For full-block grayscale mode
- “Ascii” - For ASCII character-based rendering
- “WezTerm” - For WezTerm terminal protocol (color)
- “WezTermNoColor” - For WezTerm terminal protocol (grayscale)
- “Kitty” - For Kitty terminal protocol (color)
- “KittyNoColor” - For Kitty terminal protocol (grayscale)
- “Iterm2” - For iTerm2 terminal protocol (color)
- “Iterm2NoColor” - For iTerm2 terminal protocol (grayscale)
- “SixelHalf” - For Sixel graphics protocol (half-block, when
sixelfeature is enabled) - “SixelFull” - For Sixel graphics protocol (full-block, when
sixelfeature is enabled)
§Examples
use image_to_console_core::DisplayMode;
assert_eq!(DisplayMode::HalfColor.mode(), "HalfColor");
assert_eq!(DisplayMode::Ascii.mode(), "Ascii");Sourcepub fn check_image_type(&self, img_type: &ProcessedImage) -> bool
pub fn check_image_type(&self, img_type: &ProcessedImage) -> bool
Check if the given processed image type is compatible with this display mode
This method verifies whether a ProcessedImage has been processed in a format that is suitable for display with the current DisplayMode. Different display modes require different image formats - some need color information, others work with grayscale, and some need both.
§Arguments
img_type- A reference to the ProcessedImage to check for compatibility
§Returns
true- If the image type is compatible with this display modefalse- If the image type is not compatible with this display mode
§Compatibility Rules
FullColormode requires images with both color and grayscale data (ProcessedImage::Both)SixelHalfandSixelFullmodes require RGB image data (ProcessedImage::Color2)HalfColor,Kitty,Iterm2, andWezTermmodes require color image data (ProcessedImage::Color)Ascii,FullNoColor,KittyNoColor,Iterm2NoColor, andWezTermNoColormodes require grayscale data (ProcessedImage::NoColor)
§Examples
use image_to_console_core::{DisplayMode, ProcessedImage};
use image::DynamicImage;
let img = DynamicImage::new_rgba8(10, 10);
let color_image = ProcessedImage::new(DisplayMode::HalfColor, &img);
let ascii_image = ProcessedImage::new(DisplayMode::Ascii, &img);
assert!(DisplayMode::HalfColor.check_image_type(&color_image));
assert!(!DisplayMode::HalfColor.check_image_type(&ascii_image));
assert!(DisplayMode::Ascii.check_image_type(&ascii_image));Sourcepub fn expect_image_type(&self) -> &'static str
pub fn expect_image_type(&self) -> &'static str
Get the expected image type name for this display mode
This method returns a human-readable string indicating what type of processed image data is required for this display mode. This can be useful for debugging, validation, or user interface purposes.
§Returns
A static string slice representing the expected image type:
- “Both” - For modes requiring both color and grayscale data (FullColor)
- “Color2” - For modes requiring RGB data (SixelHalf, SixelFull)
- “Color” - For modes requiring RGBA color data (HalfColor, Kitty, Iterm2, WezTerm)
- “NoColor” - For modes requiring grayscale data (Ascii, FullNoColor, KittyNoColor, Iterm2NoColor, WezTermNoColor)
§Examples
use image_to_console_core::DisplayMode;
assert_eq!(DisplayMode::HalfColor.expect_image_type(), "Color");
assert_eq!(DisplayMode::Ascii.expect_image_type(), "NoColor");
#[cfg(feature = "sixel")]
assert_eq!(DisplayMode::SixelHalf.expect_image_type(), "Color2");Trait Implementations§
Source§impl Clone for DisplayMode
impl Clone for DisplayMode
Source§fn clone(&self) -> DisplayMode
fn clone(&self) -> DisplayMode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DisplayMode
impl Debug for DisplayMode
Source§impl Default for DisplayMode
impl Default for DisplayMode
Source§impl PartialEq for DisplayMode
impl PartialEq for DisplayMode
impl Copy for DisplayMode
impl Eq for DisplayMode
impl StructuralPartialEq for DisplayMode
Auto Trait Implementations§
impl Freeze for DisplayMode
impl RefUnwindSafe for DisplayMode
impl Send for DisplayMode
impl Sync for DisplayMode
impl Unpin for DisplayMode
impl UnwindSafe for DisplayMode
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more