I can successfully decode barcodes ITF using ZXing.Net, but in some cases the Result.Text have some missing numbers, like in this:
original barcode: 836900000008262500403007233338786038100661049195
Result.Text : 83690000000 26250040300 23333878603 10066104919
In this case there are missing a 8,7,8 and 5
In this other case, the numbers are reordered to a random order and have some missing numbers:
original barcode: 23793381285017475716618000050809162310000010000
Result.Text 23791623100000100003381250174757161800005080
Any ideas why is it happening?
Thanks
EDIT: 06/12/2015
If I don't specify the PossibleFormats the decoder decodes all the codes (the images are here:1drv.ms/1B6wD5c) as ITF and the result is the same as the described above. The code I'm using is here:
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;
}
The missing numbers are indeed validation numbers and they have to be calculated.