[][src]Struct bmp_monochrome::Bmp

pub struct Bmp { /* fields omitted */ }

The Bmp struct contains the data as a vector of boolean, each representing a pixel. In data the first element is the upper-left pixel, then proceed in the row. Last element of data is the lower-right pixel. Note in the serialized format the first element is the lower-left pixel see BMP file format

Implementations

impl Bmp[src]

pub fn read<T: Read>(from: T) -> Result<Self, BmpError>[src]

Read the monochrome bitmap from a Read type, such a File note that File read are not buffered and may be slow, see Read Trait

impl Bmp[src]

pub fn write<T: Write>(&self, to: T) -> Result<(), BmpError>[src]

Write the monochrome bitmap to a Write type, such a File

impl Bmp[src]

pub fn new(data: Vec<bool>, width: usize) -> Result<Bmp, BmpError>[src]

Creates a new DataMatrix, failing if data is empty or its length not a multiple of width

pub fn height(&self) -> usize[src]

return the Bmp height in pixel

pub fn width(&self) -> usize[src]

return the Bmp width in pixel

pub fn pixel(&self, i: usize, j: usize) -> bool[src]

return the pixel situated at (i,j), where (0,0) is the upper-left corner could panic if (i * self.height() + j) >= self.data.len()

pub fn get(&self, x: usize, y: usize) -> bool[src]

return the pixel situated at (x,y) where (0,0) is the lower-left corner could panic if (i * self.height() + j) >= self.data.len()

pub fn mul(&self, mul: usize) -> Result<Bmp, BmpError>[src]

return a new Bmp where every pixel is multiplied by mul

pub fn div(&self, div: usize) -> Result<Bmp, BmpError>[src]

return a new Bmp where every square is divided by div if all the square is not of the same color it errors

pub fn normalize(&self) -> Bmp[src]

normalize removes the white border if any, and reduce the module pixel size to 1 (the module must be smaller than 10x10 pixel)

pub fn add_white_border(&self, border_size: usize) -> Result<Bmp, BmpError>[src]

return a new Bmp with border_size pixels around

pub fn remove_white_border(&self) -> Bmp[src]

remove all the white border, if any

Trait Implementations

impl Clone for Bmp[src]

impl Debug for Bmp[src]

impl Eq for Bmp[src]

impl PartialEq<Bmp> for Bmp[src]

impl StructuralEq for Bmp[src]

impl StructuralPartialEq for Bmp[src]

Auto Trait Implementations

impl RefUnwindSafe for Bmp

impl Send for Bmp

impl Sync for Bmp

impl Unpin for Bmp

impl UnwindSafe for Bmp

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.