bitmap_writer/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]
2
3//! Convert monochrome pixel data to text for displaying in terminal or
4//! transfer.
5
6
7/// The style determines the character set used to convert the bitmap.
8///
9/// The style's name denotes how many pixels can be displayed per character.
10/// `1x1` indicates that each character equals one pixel.
11/// `2x3` encodes a total of six pixels in one character.
12///
13/// The quality of the output is highly depended on the font used in the
14/// terminal that displays the result.
15///
16/// Most modern fonts are taller than they are wide. To achieve a natural
17/// looking width-to-height ratio, use `1x2` or `1x3` fonts.
18///
19/// The `ASCII` style is the most compatible and easily transferable.
20///
21/// The `Unicode` styles can fail to display correctly if the font used in
22/// the terminal has missing or misaligned characters.
23///
24/// The `2x3` style is the most space-efficient style but fails on most
25/// Unicode fonts due to misaligned character shapes.
26///
27/// On the `ASCII1x1`, a style character must be provided which will be used
28/// to display the set pixels, while an unset pixel is represented by a blank
29/// space.
30#[repr(usize)]
31pub enum Style {
32 ASCII1x1(char) = 0,
33 UnicodeBlock1x1 = 1,
34 UnicodeBlock1x2 = 2,
35 UnicodeBlock2x2 = 3,
36 UnicodeSextant1x3 = 4,
37 UnicodeSextant2x3 = 5
38}
39
40/// A decorative frame can be drawn around the bitmap to better indicate
41/// where the edges of the bitmap are located.
42///
43/// Much like with the styles, the results are depended on the font used.
44/// The `ASCII` frame should always work. The `Unicode` frames are nicer
45/// but support is more spotty.
46#[repr(usize)]
47pub enum Frame {
48 NoFrame = 0,
49 ASCIIFrame = 1,
50 UnicodeFrame = 2,
51 UnicodeBoldFrame = 3,
52 UnicodeDoubleUFrame = 4,
53 UnicodeBlockFrame = 5,
54 UnicodeShadeFrame = 6
55}
56
57
58mod bitmap;
59pub use self::bitmap::Bitmap;
60
61mod writer;
62pub use self::writer::Writer;