How to hide user readable text in code 128?

Oct 9, 2012 at 5:55 AM
Edited Oct 9, 2012 at 5:57 AM

I am using zxingnet to generate code 128 bar code, but it was showing user readable data at the bottom. How can I hide the user readable data?

 

Oct 9, 2012 at 1:20 PM

I encode the image and then crop it.

Coordinator
Oct 9, 2012 at 6:09 PM

With version 0.9 you have two options:

  1. crop it like gjennings66 wrote
  2. derive a new Renderer class from BitmapRenderer and use it with the BarcodeWriter
    public class PureBarcodeRenderer : ZXing.Rendering.BitmapRenderer
    {
       public override Bitmap Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options)
       {
          return base.Render(matrix, format, null, options);
       }
    }
    
    var writer = new BarcodeWriter
                    {
                       Renderer = new PureBarcodeRenderer(),
                       Format = BarcodeFormat.CODE_128,
                       Options = new EncodingOptions
                                      {
                                         Height = 100,
                                         Width = 300
                                      }
                                };
    var image = writer.Write(content);
    

 

With the next version of ZXing.Net I will include a new encoding option which avoids the output of the data at the bottom.

var writer = new BarcodeWriter
                {
                   Format = BarcodeFormat.CODE_128,
                   Options = new EncodingOptions
                                  {
PureBarcode = true,
 Height = 100, Width = 300 } }; var image = writer.Write(content);
Oct 10, 2012 at 10:14 AM

Thank you for the update.

Dec 10, 2012 at 9:15 AM

I am using IBarcodeReader to read the bar code in a Image.

If the bar code is available in the Image I am getting a proper results.

If the bar code is not available also I am getting a numeric value.

How to fix this?

Coordinator
Dec 10, 2012 at 9:09 PM

Do you have a sample picture for me?

Jan 17, 2013 at 8:19 PM
Edited Jan 17, 2013 at 8:31 PM

Hi.  Unlike micjahn, I am using version 0.10 for Silverlight 5 and want to display the user readable data at the bottom but am unable to get it to appear.  I have tried a few different variations with no luck - including the code posted above with the following change because Bitmap doesn't seem to be a member of ZXing.Rendering anymore

    public class PureBarcodeRenderer : ZXing.Rendering.WriteableBitmapRenderer
    {
        public override System.Windows.Media.Imaging.WriteableBitmap Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options)
        {
            return base.Render(matrix, format, content, options);
        } 

        //public override Bitmap Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options)
        //{
        //    return base.Render(matrix, format, null, options);
        //}
    }

Is there something specific (besides setting PureBarcode = false) that I need to do ?

Thanks.

Jan 18, 2013 at 12:03 AM

Hi Doneil,

I am using the following sample code to generate the 1d bar code, I am getting the user readable data at the bottom.

var writer = new BarcodeWriter{Format = BarcodeFormat.CODE_128};

var result = writer.Write("123456");

result.save("test.bmp");

I hope this willl solve ur issue.

 

Thanks.

Coordinator
Jan 18, 2013 at 11:07 AM
Edited Apr 15, 2013 at 2:45 PM
PureBarcode has an effect only for target frameworks with Bitmap support. Silverlight (Windows Phone and WinRT, too) instead uses the WriteableBitmap class. The barcode render class for WriteableBitmap doesn't support the output of user readable content. Feel free to submit a patch.