ZXing <fnc> GS1条形码的分隔符

时间:2017-05-24 18:57:51

标签: c# zxing

我正在尝试将<FNC1>分隔符放在我的ZXing条形码中,我不确定这些是如何在字符串值中格式化的。我有

BarcodeWriterPixelData writer = new BarcodeWriterPixelData()
{
    Format = BarcodeFormat.CODE_128,
    Options = new ZXing.Common.EncodingOptions
    {
        Width = 554,
        Height = 120
    }
};
var pixelData = writer.Write("<FNC1>42011111<FNC1>92612123456789000000155015");

using (var bitmap = new Bitmap(pixelData.Width, pixelData.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb))
{
    using (var ms = new System.IO.MemoryStream())
    {
        var bitmapData = bitmap.LockBits(new Rectangle(0, 0, pixelData.Width, pixelData.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
        try
        {
            // we assume that the row stride of the bitmap is aligned to 4 byte multiplied by the width of the image   
            System.Runtime.InteropServices.Marshal.Copy(pixelData.Pixels, 0, bitmapData.Scan0, pixelData.Pixels.Length);
        }
        finally
        {
            bitmap.UnlockBits(bitmapData);
        }

        // PNG or JPEG or whatever you want
        bitmap.SetResolution(300, 300);
        bitmap.Save(@"C:\Users\user\Desktop\newBarcode.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
    }
}

此代码生成此图片enter image description here

究竟是<FNC1>42011111<FNC1>92612123456789000000155015如何插入和插入FNC1值?我尝试使用我在此解决方案中找到的“] C1”:

https://github.com/zxing/zxing/issues/475

但它没有用。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

unicode字符'\ u00f1'而不是“&lt; FNC1&gt;”应该工作。