In python, I'm using the following code to create a 1bpp image:
import Image
img = Image.open(filename)
img = img.convert('1')
pix = img.load()
I found this code on Stack here: Can't format BMP image data to 1 bit per pixel in PIL
This code generates what appears to be a monochrome bitmap, but when you look at the data in a hex editor, black is FF is a single pixel and white 00 is a single white pixel. This means the data is 8bpp and not 1bpp like the PIL documentation suggests (https://pillow.readthedocs.org/en/3.1.x/handbook/concepts.html?highlight=bit). I've confirmed this to be true because when I replace FF (255) with 80 (128), grey is introduced into the image. With a true monochrome bitmap image, this would not have caused any grey.
This is because a true monochrome image is 1 bit per pixel. Meaning these 2 bytes for example, AA AA, would produce a checker black/white pattern of 16 pixels, while in 8bpp, it would produce two grey pixels.
I'm finding that PIL's 1 bit per pixel mode always generates greyscale. Does anyone know of another library that can help me generate true 1bpp, or know a way to convert the 8bit to 1bit efficiently?
The reason I need this is because I'm attempting to create an image that can be stored on a laser printer. The printer requires 1bpp because laser printers can't actually print grey. It uses dithering to make the appearance of grey.