注意:My original question是关于ZXing C#端口是否可靠,但在这里,我试图弄清楚如何使用它。因此,它们不是重复的。如何使用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();
我越来越对行开头的异常“结果的结果= ...”的ReaderException指出:"Unable to cast object of type 'com.google.zxing.oned.MultiFormatOneDReader' to type 'com.google.zxing.Reader'.
所以,我是什么做错了?
UPDATE:我会尝试一下建议的想法,但是在此期间,我在ZXing组中发现了这个issue。
问题上的条形码格式有关读取条形码,而不是创建它们,那么错题,但不错的答案:) – Sam 2012-06-13 08:22:49