ZXing.Net ITF条形码发布Windows Phone 8.1

时间:2015-06-10 18:17:01

标签: c# windows-phone-8.1 zxing barcode-scanner

我可以使用ZXing.Net成功解码条形码ITF,但在某些情况下,Result.Text有一些缺失的数字,如下所示:

原始条码:836900000008262500403007233338786038100661049195

Result.Text:83690000000 26250040300 23333878603 10066104919

在这种情况下,缺少8,7,8和5

在另一种情况下,这些数字会被重新排序为随机顺序并且有一些缺失的数字:

原始条码:23793381285017475716618000050809162310000010000

Result.Text 23791623100000100003381250174757161800005080

任何想法为什么会发生?

谢谢

编辑:06/12/2015

如果我没有指定PossibleFormats,解码器将所有代码(图像在这里:1drv.ms/1B6wD5c)解码为ITF,结果与上述相同。我正在使用的代码在这里:

    public BarCodeReaderService(IDialogService _dialogService)
    {
        dialogService = _dialogService;

        barcodeReader = new BarcodeReader
        {
            Options = new DecodingOptions
            {
                PureBarcode = true,
                TryHarder = true,
                PossibleFormats = new BarcodeFormat[] { BarcodeFormat.ITF }
            },

        };
    }

    public async Task<string> ScanBitmapAsync(StorageFile file)
    {
        string result = null;
        using (var stream = await file.OpenReadAsync())
        {
            // initialize with 1,1 to get the current size of the image
            var writeableBmp = new WriteableBitmap(1, 1);
            writeableBmp.SetSource(stream);
            // and create it again because otherwise the WB isn't fully initialized and decoding
            // results in a IndexOutOfRange
            writeableBmp = new WriteableBitmap(writeableBmp.PixelWidth, writeableBmp.PixelHeight);
            stream.Seek(0);
            writeableBmp.SetSource(stream);


            try
            {
                result = ScanBitmap(writeableBmp);
            }
            catch (Exception ex)
            {
                dialogService.ShowAsync("Ocorreu um erro \n" + ex.Message, "Erro");
            }
        }

        return result != null ? result : null;
    }

    private string ScanBitmap(WriteableBitmap writeableBmp)
    {

        var result = barcodeReader.Decode(writeableBmp);

        return result != null ? result.Text : null;
    }

1 个答案:

答案 0 :(得分:0)

缺少的数字确实是验证数字,必须进行计算。