注意:我最初的问题是关于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();
Run Code Online (Sandbox Code Playgroud)
我在以"Result result = ..."开头的行上遇到异常ReaderException指出: "Unable to cast object of type 'com.google.zxing.oned.MultiFormatOneDReader' to type 'com.google.zxing.Reader'.
那么,我做错了什么?
更新:我将尝试建议的想法,但与此同时,我在ZXing小组中发现了这个问题.