Skip to main content

write_pbm

Function write_pbm 

Source
pub fn write_pbm<P: Pixel, W: Write>(
    bitmap: &Bitmap<P>,
    out: W,
) -> Result<(), EncodeError>
Expand description

Write bitmap to out as a binary PBM (P4) image.

Input pixels are Gray8: 0 โ†’ white (0 bit), 1โ€“255 โ†’ black (1 bit). Rows are MSB-packed and padded to whole bytes, matching the P4 spec.

ยงErrors

Returns EncodeError::UnsupportedMode for non-grayscale modes. Returns EncodeError::Io on any I/O failure.