【发布时间】:2020-03-27 18:28:13
【问题描述】:
我正在尝试读取 3of9 条码。 3of9 barcode Image 给我的结果是不稳定的,但位置仍然相同。 (尝试多次运行该方法相同的图像/条形码和相同的位置) 我所说的不稳定的意思是有时我会得到条形码的价值 前任。 barcodesd.Length 不为零,因此它得到的barcodesd[0].Value 是 25350111 有时barcodesd.Length = 0
这是我的代码:
public static string DecodeImg(System.Drawing.Bitmap img)
{
System.IO.MemoryStream data = new MemoryStream();
RasterImage srcImage = null;
try
{
BarcodeEngine engine = new BarcodeEngine();
Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs();
img.Save(data, System.Drawing.Imaging.ImageFormat.Jpeg);
data.Seek(0, System.IO.SeekOrigin.Begin);
srcImage = codecs.Load(data);
BarcodeData[] barcodesd = engine.Reader.ReadBarcodes(srcImage, LeadRect.Empty, 0, BarcodeEngine.GetSupportedSymbologies(), null);
srcImage.Dispose();
if (barcodesd != null)
{
if (barcodesd.Length > 0)
return barcodesd[0].Value;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
data.Dispose();
if (srcImage != null)
srcImage.Dispose();
}
return "Unable to Read";
}
【问题讨论】:
-
throw ex.Message;无法编译。 -
好的,编辑问题。我对此不好。
标签: c# leadtools-sdk