pub struct TwoColorMatrix {
pub black: Matrix,
pub red: Matrix,
}Expand description
Container for two-color (black and red) bitmap data.
This structure holds separate bitmap matrices for black and red colors, used for two-color printing on compatible printers like QL-820NWB.
Both matrices must have identical dimensions and represent 1-bit bitmap data packed into bytes (8 pixels per byte).
Fields§
§black: Matrix§red: MatrixImplementations§
Source§impl TwoColorMatrix
impl TwoColorMatrix
Sourcepub fn new(black: Matrix, red: Matrix) -> Result<Self, String>
pub fn new(black: Matrix, red: Matrix) -> Result<Self, String>
Create a new TwoColorMatrix from black and red bitmap data.
§Arguments
black- Matrix containing black pixel datared- Matrix containing red pixel data
§Returns
Ok(TwoColorMatrix)- Successfully created two-color matrixErr(String)- Error message if dimensions don’t match
§Example
let black_data: Matrix = vec![vec![0xFF; 90]; 300]; // 300 lines, 90 bytes each
let red_data: Matrix = vec![vec![0x00; 90]; 300]; // Same dimensions
let two_color = TwoColorMatrix::new(black_data, red_data)?;Sourcepub fn to_alternating_matrix(&self) -> Matrix
pub fn to_alternating_matrix(&self) -> Matrix
Convert two-color data to alternating matrix format for printing.
This method interleaves black and red rows to create a single matrix where black and red lines alternate. This format is required by the printer’s two-color raster commands.
§Returns
Matrix with double the height, alternating between black and red rows
§Example
let two_color = TwoColorMatrix::new(black_data, red_data)?;
let alternating = two_color.to_alternating_matrix();
assert_eq!(alternating.len(), 4); // 2 * 2 original rowsTrait Implementations§
Source§impl Clone for TwoColorMatrix
impl Clone for TwoColorMatrix
Source§fn clone(&self) -> TwoColorMatrix
fn clone(&self) -> TwoColorMatrix
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TwoColorMatrix
impl RefUnwindSafe for TwoColorMatrix
impl Send for TwoColorMatrix
impl Sync for TwoColorMatrix
impl Unpin for TwoColorMatrix
impl UnsafeUnpin for TwoColorMatrix
impl UnwindSafe for TwoColorMatrix
Blanket Implementations§
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
Mutably borrows from an owned value. Read more