我在 VS 2010 的 winforms 应用程序中使用 zXing C# 库来解码 QR 码。它适用于某些图像,但对一些图像无效。
异常消息:
“抛出了‘com.google.zxing.ReaderException’类型的异常。”
这是我的代码:
返回解码数据的函数代码
    public string GetQRValue(Bitmap value)
    {
        string result = string.Empty;
        try
        {
            QRCodeReader reader = new QRCodeReader();
            //com.google.zxing.Reader re
            com.google.zxing.LuminanceSource source = new RGBLuminanceSource(value, value.Width, value.Height);
            var binarizer = new HybridBinarizer(source);
            var binBitmap = new BinaryBitmap(binarizer);
            result = reader.decode(binBitmap).Text;
        }
        catch(Exception ex)
        {
            result = ex.Message; //string.Empty;
        }
        return result;
    }
调用上述函数的代码:
Bitmap image1 = (Bitmap)Image.FromFile(txtFile.Text , true);
lblData.Text = cls.GetQRValue(image1);
这里txtFile是文件的路径,cls是包含解码函数的类的对象。
以下是无法解码的图像。

我尝试在以下网站上对其进行解码。并在那里解码。
http://www.patrick-wied.at/static/qrgen/
并且下面的图像被成功解码。

请帮我解决问题