Struct datamatrix::placement::Bitmap[][src]

pub struct Bitmap<M> { /* fields omitted */ }

An abstract bitmap.

Contains helpers for rendering the content. For rendering targets which use something similar to pixels try pixels(), while vector formats might profit from path().

Implementations

impl Bitmap<bool>[src]

pub fn path(&self) -> Vec<PathSegment>[src]

Get vector path drawing instructions for this bitmap.

This function computes a sequence of relative draw, relative move, and close instructions. The resulting path shows the bitmap if filled properly (see below).

The coordinate system is identical to the one of the function pixels(). The starting position is not needed in this function because only relative coordinates are returned.

Filling rule

The even-odd filling rule (as known in vector graphics) must be used. It is supported by many vector graphic formats, including SVG and PDF.

Example

The examples/ directory contains a SVG and PDF code example using this helper.

Implementation

The outline is modeled as a graph which is then decomposed into Eulerian circuits. The worst case runtime is quadratic in the number of "pixels". This could be improved by using a hash set data structure or something similar.

impl<B: Bit> Bitmap<B>[src]

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

Return the width of the bitmap (no quiet zone included).

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

Return the height of the bitmap (no quiet zone included).

pub fn unicode(&self) -> String[src]

Compute a unicode representation ("ASCII art").

This is intended as a demo functionality. It might look weird if the line height is wrong or if you are not using a monospaced font.

pub fn pixels<'a>(&'a self) -> impl Iterator<Item = (usize, usize)> + 'a[src]

Get an iterator over the "black" pixels' coordinates (x, y).

A black pixel refers to one of the tiny black squares a Data Matrix is usually made of. Depending on your target, such a pixel may be rendered using multiple image pixels, or whatever you use to visualize the Data Matrix.

The coordinate system is centered in the top left corner starting in (0, 0) with a horizontal x-axis and vertical y-axis. The pixels are returned in order, incrementing x before y.

A quiet zone is not included in the coordinates but one must be added when rendering: The minimum free space required around the Data Matrix has to have the width/height of one "black" pixel. The quiet zone should have the background's color.

A Data Matrix can be either rendered using dark color on a light background, or the other way around. More details on contrast, size, etc. can be found in the referenced standards mentioned in the specification.

Example

let bitmap = datamatrix::encode(b"Foo", SymbolSize::Square10).unwrap();
for (x, y) in bitmap.pixels() {
    // place square/circle at (x, y) to render this Data Matrix
}

Auto Trait Implementations

impl<M> RefUnwindSafe for Bitmap<M> where
    M: RefUnwindSafe
[src]

impl<M> Send for Bitmap<M> where
    M: Send
[src]

impl<M> Sync for Bitmap<M> where
    M: Sync
[src]

impl<M> Unpin for Bitmap<M> where
    M: Unpin
[src]

impl<M> UnwindSafe for Bitmap<M> where
    M: UnwindSafe
[src]

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, 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.