Describe the bug
When exporting or previewing an image as a 1-bpp Monochromatic BMP with a custom width that is not a multiple of 32 bits (such as 10px × 16px), the pixel layout becomes corrupted and shifted in the preview window (and potentially in the exported file).
It appears that the DIB scanline padding bytes (4-byte alignment requirement for BMP) are being incorrectly parsed or treated as active pixels during the stride/offset calculation for the next row.
Steps to reproduce the behavior
- Create a new image with a size of 10 x 16 pixels.
- Use the Pencil tool (with antialiasing turned off) to draw a clean diagonal line.
- Go to File -> Save As -> Choose BMP.
- In the BMP options dialog, select:
- Color model: Grayscale
- Depth: 1-bpp
- Look at the
after preview window. The smooth diagonal line becomes jagged, disconnected, and shifted horizontally near the bottom.
Expected behavior
The 1-bpp preview/export should perfectly retain the original pixel connectivity and positioning without any horizontal shifting, regardless of whether the canvas width matches the 4-byte (32-bit) stride alignment.
Environment
- PhotoDemon Version: 2025.12 (as seen in the title bar)
- OS: Windows 11 / Windows 10

Describe the bug
When exporting or previewing an image as a 1-bpp Monochromatic BMP with a custom width that is not a multiple of 32 bits (such as 10px × 16px), the pixel layout becomes corrupted and shifted in the preview window (and potentially in the exported file).
It appears that the DIB scanline padding bytes (4-byte alignment requirement for BMP) are being incorrectly parsed or treated as active pixels during the stride/offset calculation for the next row.
Steps to reproduce the behavior
afterpreview window. The smooth diagonal line becomes jagged, disconnected, and shifted horizontally near the bottom.Expected behavior
The 1-bpp preview/export should perfectly retain the original pixel connectivity and positioning without any horizontal shifting, regardless of whether the canvas width matches the 4-byte (32-bit) stride alignment.
Environment