This project has moved. For the latest updates, please go here.

Out of bounds error when using EncodingOptions object...

Aug 3, 2015 at 9:05 PM
Edited Aug 3, 2015 at 9:08 PM
The following code snippet throws an out of bounds error.
        var content = "1234567890";
        var writer = new BarcodeWriter
        {
            Format = BarcodeFormat.CODE_128,
            Options = new EncodingOptions() { Width = 3 }
        };
        Bitmap bitmap = writer.Write(content);
The error message is:
"An unhandled exception of type 'System.IndexOutOfRangeException' occurred in zxing.dll
Additional information: Index was outside the bounds of the array."

The code that it broke inside the source was
inside the method:
virtual public Bitmap Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options)
More specifically, within the line that says:
" pixels[index++] = Background.B;"
current line is 164

Although this snippet does work
        var content = "1234567890";
        var writer = new BarcodeWriter
        {
            Format = BarcodeFormat.CODE_128,
        };
        Bitmap bitmap = writer.Write(content);
Any ideas why?
Coordinator
Aug 13, 2015 at 8:01 PM
it is fixed in revision 89595.
The renderer class want's to reserve a area of 16 pixels for the human readable barcode content below the barcode itself.
But it didn't check that the requested height is more than 16 pixels.