weixin_39789399
weixin_39789399
2020-12-31 02:02

How to get BW image as output - barcode.write() outputs 24 bit (Format24bppRgb) color image

How can I get a black and white image from barcode.write(). What I get is 24 bit 1.03MB big full color image.

I convert it to 1bpp with this


  var x = ZXing.QrCode.Internal.ErrorCorrectionLevel.H;

           var barcodeWriter = new BarcodeWriter 
            {

                Format = barcodeFormat,
                Options = new ZXing.QrCode.QrCodeEncodingOptions
                {
                    CharacterSet = "ISO-8859-2",
                    Width = 600,
                    Height = 600,
                    ErrorCorrection = x,
                    QrVersion = 15
                }
            };

var bitmap = barcodeWriter.Write("ASDASD");
Console.Out.WriteLine(bitmap.PixelFormat);

var targetBmp = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), pixelFormat.Format1bppIndexed);`
Console.Out.WriteLine(targetBmp.PixelFormat);

But barcodewriter first creates 24bit color 1MB big image, and then I convert it to 1 bit per pixel image which is 43Kb. Is there a parameter where I can set QR code to be just black and white? I have to create 2000 QR codes, and this is just too slow... :(

该提问来源于开源项目:micjahn/ZXing.Net

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

4条回答

为你推荐

换一换