<注意: 我的原始问题 是关于ZXing C#端口是否可靠的,但在这里,我正在尝试弄清楚如何使用它。因此,它们不是重复的。
我正在尝试使用ZXing C#模块,但遇到了问题。有没有使用过ZXing的人知道如何正确地使用它?不幸的是,C#文档非常少。
我的当前代码是:
using com.google.zxing;
using com.google.zxing.client.j2se;
using com.google.zxing.common;
//...
Reader reader = new MultiFormatReader();
MonochromeBitmapSource image = new BufferedImageMonochromeBitmapSource(new Bitmap(Image.FromFile("barcode.jpg")),false);
Result result = reader.decode(image);
string text = result.getText();
sbyte[] rawbytes = result.getRawBytes();
BarcodeFormat format = result.getBarcodeFormat();
ResultPoint[] points = result.getResultPoints();
Console.WriteLine("barcode text: {0}", text);
Console.WriteLine("raw bytes: {0}", rawbytes);
Console.WriteLine("format: {0}", format);
Console.ReadLine();
我在以“Result result = ...”开头的那一行遇到了异常。ReaderException指出:"无法将类型为 'com.google.zxing.oned.MultiFormatOneDReader' 的对象强制转换为类型 'com.google.zxing.Reader'。
那么,我做错了什么?
更新: 我将尝试建议的方法,但同时,我在ZXing组中找到了这个issue。