ChecksumValidation
ChecksumValidation enumeration
在识别一维和邮政条码期间启用校验和验证。
对于必须包含校验和的符号,默认被视为是,在仅可能校验和的情况下被视为否。
从未使用过校验和:Codabar、PatchCode、Pharmacode、DataLogic2of5
可以使用校验和:Code39 Standard/Extended、Standard2of5、Interleaved2of5、ItalianPost25、Matrix2of5、MSI、ItalianPost25、DeutschePostIdentcode、DeutschePostLeitcode、VIN
始终使用校验和:其余符号
public enum ChecksumValidation
价值观
姓名 | 价值 | 描述 |
---|---|---|
Default | 0 | 如果规范要求校验和 - 它将被验证。 |
On | 1 | 如果可能,请始终验证校验和。 |
Off | 2 | 不验证校验和。 |
例子
此示例显示了 ChecksumValidation 对识别质量和结果的影响
[C#]
using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.EAN13, "1234567890128"))
{
generator.Save(@"c:\test.png");
}
using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.EAN13))
{
//校验和禁用
reader.BarcodeSettings.ChecksumValidation = ChecksumValidation.Off;
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine("BarCode CodeText: " + result.CodeText);
Console.WriteLine("BarCode Value: " + result.Extended.OneD.Value);
Console.WriteLine("BarCode Checksum: " + result.Extended.OneD.CheckSum);
}
}
using (BarCodeReader reader = new BarCodeReader(@"c:\test.png", DecodeType.EAN13))
{
//校验和启用
reader.BarcodeSettings.ChecksumValidation = ChecksumValidation.On;
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine("BarCode CodeText: " + result.CodeText);
Console.WriteLine("BarCode Value: " + result.Extended.OneD.Value);
Console.WriteLine("BarCode Checksum: " + result.Extended.OneD.CheckSum);
}
}
[VB.NET]
Using generator As New BarcodeGenerator(EncodeTypes.EAN13, "1234567890128")
generator.Save("c:\test.png")
End Using
Using reader As New BarCodeReader("c:\test.png", DecodeType.EAN13)
'校验和禁用
reader.BarcodeSettings.ChecksumValidation = ChecksumValidation.Off
For Each result As BarCodeResult In reader.ReadBarCodes()
Console.WriteLine("BarCode CodeText: " + result.CodeText)
Console.WriteLine("BarCode Value: " + result.Extended.OneD.Value)
Console.WriteLine("BarCode Checksum: " + result.Extended.OneD.CheckSum)
Next
End Using
Using reader As New BarCodeReader("c:\test.png", DecodeType.EAN13)
'启用校验和
reader.BarcodeSettings.ChecksumValidation = ChecksumValidation.On
For Each result As BarCodeResult In reader.ReadBarCodes()
Console.WriteLine("BarCode CodeText: " + result.CodeText)
Console.WriteLine("BarCode Value: " + result.Extended.OneD.Value)
Console.WriteLine("BarCode Checksum: " + result.Extended.OneD.CheckSum)
Next
End Using