Search code examples
c#asp.netzxing

How to encode ZXING barcode to image


Good day all,

I want encode ZXING barcode in image format.The reason is want store at DB the image. Below is my code.

      var brcode = new ZXing.BarcodeWriter();
                    var encOptions = new ZXing.Common.EncodingOptions() { Width = 2, Height = 2, Margin = 0 };
                    brcode.Options = encOptions;
                    brcode.Format = ZXing.BarcodeFormat.CODE_128;
                    Bitmap result = new Bitmap(brcode.Write(barcode));

it prompt error this error "Index was outside the bounds of the array."

Please advise.

Advance thanks.


Solution

  • After long hour testing and search, i found that the issue is ZXing.BarcodeFormat.CODE_128;

    if i use brcode.Format = ZXing.BarcodeFormat.QR_Code; it working fine. barcode cannot transform to image in ZXING