Using the C# port for QR code always gives "Index was outside the bounds of the array."

1,007 views
Skip to first unread message

RKM

unread,
Jul 15, 2009, 12:59:24 PM7/15/09
to zxing
I am trying to use the C# port of ZXing to decode a QR code and I
invariably get an exception
"[System.IndexOutOfRangeException] = {"Index was outside the bounds
of the array."} in

DecoderResult decode(BitMatrix bits).


Specifically it occurs at line 140 of DataBlock.CS which is...

result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];

when rawCodewordsOffset exceeds the size of rawCodewords/

I would be very appreciative if someone could perhaps point me towards
an example
that uses this class properly.

Here is my simple test...

Image img2 = new Bitmap(@"c:\temp\QR.jpg");
BufferedImageMonochromeBitmapSource imgMono =
new BufferedImageMonochromeBitmapSource
(img2,false);
QRCodeReader ZXingQR = new QRCodeReader();
try
{
com.google.zxing.Result r = ZXingQR.decode(imgMono);
textBox1.Text = r.getText();
}
catch(Exception ex)
{
textBox1.Text = ex.Message;
}

Thanks very much in advance for any help or pointers in the right
direction that anyone give me...

P.S. I have tried a number of images, both "ideal" and "real world"
and I always get this result.

srowen

unread,
Jul 17, 2009, 8:04:26 AM7/17/09
to zxing
Not sure, could be a bug in the port, since it's reasonably old. I
don't know C# and we don't maintain that code. If you find a solution,
you're welcome to contribute a patch. You might compare to the latest
version of the Java code to perhaps find that the Java code has fixed
it.
Reply all
Reply to author
Forward
0 new messages