DEWQ

Struct BitMap

Source
pub struct BitMap { /* private fields */ }

Implementations§

Source§

impl BitMap

Source

pub fn new(size: usize) -> Self

Creates a new bitmap with specified size

§Arguments
  • size - The width and height of the bitmap (must be square)
§Returns

A new BitMap initialized with zeros

Source

pub fn set<B>(&mut self, i: usize, j: usize, bit: B)
where B: Into<Bit>,

Sets a specific bit in the bitmap

§Arguments
  • i - Row index
  • j - Column index
  • bit - Bit value to set (can be Bit::One or Bit::Zero)
Source

pub fn invert_bit(&mut self, i: usize, j: usize)

Inverts the bit at the specified location

§Arguments
  • i - Row index
  • j - Column index
Source

pub fn get(&self, i: usize, j: usize) -> Bit

Retrieves the bit value at a specific location

§Arguments
  • i - Row index
  • j - Column index
§Returns

The Bit value at the specified location

Source

pub fn size(&self) -> usize

Returns the size of the bitmap

§Returns

The width/height of the bitmap

Source

pub fn save_to_file<P>(&self, path: P)
where P: AsRef<Path>,

Saves the bitmap to a file in BMP format

§Arguments
  • path - File path to save the bitmap
§Remarks

Creates a 1bpp bitmap image with a black and white color palette

Trait Implementations§

Source§

impl Display for BitMap

Implements a text-based display of the bitmap

Renders the bitmap using block characters, where:

  • ██ represents a black/set bit
  • represents a white/unset bit
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for BitMap

§

impl RefUnwindSafe for BitMap

§

impl Send for BitMap

§

impl Sync for BitMap

§

impl Unpin for BitMap

§

impl UnwindSafe for BitMap

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.