Create 8-bit depth BMP
Posted: 2019-09-23T03:26:25-07:00
I asked a question on StackOverflow, but will probably get a faster response here. I want to create a BMP file with 8 bits per pixel. I use file Properties > Details to verify the result. If Bit depth is 8 there then I got my picture. This is code that I have:
Here I'm converting from existing image, but I also tried to create a new image, and still can't make it 8 bpp bitmap. Is this even possible?
Code: Select all
byte[] input = <existing TIFF image>;
using (var image = new MagickImage(input))
{
image.Grayscale();
image.ColorType = ColorType.Palette;
image.Depth = 8;
image.Quantize(new QuantizeSettings() { Colors = 256, DitherMethod = DitherMethod.No });
byte[] result = image.ToByteArray(MagickFormat.Bmp);
return result;
}