ZXing.Net icon indicating copy to clipboard operation
ZXing.Net copied to clipboard

Add possibility to set for BitmapRenderer to output monochrome images at a color depth of 1 bit per pixel?

Open yankarinRG opened this issue 3 years ago • 2 comments

Currently BitmapRenderer output images having a PixelFormat of Format24bppRgb, but since barcodes are 99% of the times black & white (monochrome), it would be nice to set the format to Format1bppIndexed.
As a bonus, it would be nice to have the RawFormat property of Bitmap (Image) to a value different than ImageFormat.MemoryBmp since the method ImageFormat.FindEncoder can't find an encoder for MemoryBmp and I experience crashes when using POS for .NET and printing that barcode with the PosPrinter.PrintMemoryBarcode method. Thanks!

yankarinRG avatar Nov 17 '22 09:11 yankarinRG

Do you know a way to change the RawFormat value? It is a readonly-property.

Enabling changing the pixel format means a complete rewrite of the main method of the renderer. Perhaps you can use the following code snippet meanwhile: var bmp1bpp = bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height), PixelFormat.Format1bppIndexed);

micjahn avatar Nov 17 '22 17:11 micjahn

That's exactly the same workaround/hack i am using at the moment. If this won't get implemented by nobody else and I'll come up with an elegant and performant way to do so I'll open a CR

yankarinRG avatar Nov 17 '22 18:11 yankarinRG