Skip to main content

step_filter_normal

Function step_filter_normal 

Source
pub fn step_filter_normal(threshold: u8, length: u32, bytes: Vec<u8>) -> Matrix
Expand description

Convert grayscale image to 1-bit bitmap for normal-width printers (720 pixels).

This function processes grayscale image data and converts it to the 1-bit bitmap format required by Brother P-Touch printers. Pixels are packed 8 per byte with proper bit ordering for the printer.

§Arguments

  • threshold - Grayscale threshold (0-255). Pixels below this become black (1)
  • length - Image height in pixels
  • bytes - Grayscale image data (width × height bytes)

§Returns

Matrix containing 1-bit bitmap data (Vec<Vec<u8>>)

§Example

let width = 720;
let height = 100;
let grayscale_data = vec![128u8; (width * height) as usize]; // Gray image
 
let bitmap = step_filter_normal(80, height, grayscale_data);
assert_eq!(bitmap.len(), height as usize);
assert_eq!(bitmap[0].len(), 90); // 720 pixels / 8 = 90 bytes