Take the 2-minute tour ×

I'm using zXing C# library to decode QR code in my winforms application in VS 2010. It works fine for some images, but fails for a few.

exception message :

"Exception of type 'com.google.zxing.ReaderException' was thrown."

here is my code :

Code for the function that returns the decoded data

    public string GetQRValue(Bitmap value)
        string result = string.Empty;

            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;

Code that calls the above function :

Bitmap image1 = (Bitmap)Image.FromFile(txtFile.Text , true);
lblData.Text = cls.GetQRValue(image1);

Here txtFile is the path to the file, and cls is a object of the class that contains the decoding function.

Following is the image that fails to decode.

Qr code that fails to decode
I've tried tried decoding it at the following website. And is decoded there.

And the following image is decoded successfully.

Qr code that decoded successfully

Please help me to solve the issue

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The C# port is somewhat old and not maintained. It looks like either a problem with your binarization, or some problem in the port, since the main branch (Java) decodes these fine:

http://zxing.org/w/decode?u=http%3A%2F%2Fi.stack.imgur.com%2FTEiIH.jpg&full=true http://zxing.org/w/decode?u=http%3A%2F%2Fi.stack.imgur.com%2FP8irV.png&full=true

share|improve this answer
:: Then what should I do? Any suggestion to make my program accurate? –  Krishanu Dey Nov 2 '12 at 21:19
Re-port the Java code? –  Sean Owen Nov 2 '12 at 21:55
I want to do it in c# –  Krishanu Dey Nov 3 '12 at 6:03

Your Answer


