ZXing.Net ITF 条码问题 Windows Phone 8.1
ZXing.Net ITF Barcode issues Windows Phone 8.1
我可以使用 ZXing.Net 成功解码 ITF 条形码,但在某些情况下 Result.Text 有一些缺失的数字,例如:
原始条码:836900000008262500403007233338786038100661049195
Result.Text : 83690000000 26250040300 23333878603 10066104919
在这种情况下,缺少 8、7、8 和 5
在另一种情况下,数字被重新排序为随机顺序并且有一些缺失的数字:
原始条码:23793381285017475716618000050809162310000010000
Result.Text 23791623100000100003381250174757161800005080
知道为什么会这样吗?
谢谢
编辑:2015 年 6 月 12 日
如果我不指定 PossibleFormats,解码器会将所有代码(图像为 here: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;
}
缺失的数字确实是验证数字,需要计算。
我可以使用 ZXing.Net 成功解码 ITF 条形码,但在某些情况下 Result.Text 有一些缺失的数字,例如:
原始条码:836900000008262500403007233338786038100661049195
Result.Text : 83690000000 26250040300 23333878603 10066104919
在这种情况下,缺少 8、7、8 和 5
在另一种情况下,数字被重新排序为随机顺序并且有一些缺失的数字:
原始条码:23793381285017475716618000050809162310000010000
Result.Text 23791623100000100003381250174757161800005080
知道为什么会这样吗?
谢谢
编辑:2015 年 6 月 12 日
如果我不指定 PossibleFormats,解码器会将所有代码(图像为 here: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;
}
缺失的数字确实是验证数字,需要计算。