Gernatch
Gernatch

Reputation: 185

Convert Monochrome 1bpp TIFF to byte array

I created a 1bpp image in Photoshop, and I am trying to read the bytes into a byte array. Later I will be storing these monochrome bytes under a font descriptor to make a bitmap font.

So I get the image like this:

  var bitmap = new Bitmap(filePath);

I later write the image to a byte array like this:

    public byte[] imageToByteArray(Image imageIn)
    {
        MemoryStream ms = new MemoryStream();
        imageIn.Save(ms, ImageFormat.Bmp);
        return ms.ToArray();
    }

When I write the file to a byte array, it is no longer monochrome 1bpp, rather I think it is 24bpp or 32bpp (not sure which but I'm certain it is not 1bpp). Any idea how to write the bytes as 1bpp instead of 8/16/24/32? This is for a laser jet printer, and they can only read 1bpp byte streams when printing raster data. Hopefully this is clear.

Upvotes: 0

Views: 341

Answers (0)

Related Questions