diff --git a/AUTHORS b/AUTHORS index 47cc7cfef..9f73026a7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -33,6 +33,7 @@ Juho Mikkonen jwicks Kevin O'Sullivan (SITA) Kevin Xue (NetDragon Websoft Inc., China) +Lachezar Dobrev Luiz Silva Luka Finžgar Marcelo diff --git a/core/src/com/google/zxing/datamatrix/decoder/Decoder.java b/core/src/com/google/zxing/datamatrix/decoder/Decoder.java index aef9709e6..d26a04c4d 100644 --- a/core/src/com/google/zxing/datamatrix/decoder/Decoder.java +++ b/core/src/com/google/zxing/datamatrix/decoder/Decoder.java @@ -80,22 +80,24 @@ public final class Decoder { // Separate into data blocks DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version); + int dataBlocksCount = dataBlocks.length; + // Count total number of data bytes int totalBytes = 0; - for (int i = 0; i < dataBlocks.length; i++) { + for (int i = 0; i < dataBlocksCount; i++) { totalBytes += dataBlocks[i].getNumDataCodewords(); } byte[] resultBytes = new byte[totalBytes]; - int resultOffset = 0; // Error-correct and copy data blocks together into a stream of bytes - for (int j = 0; j < dataBlocks.length; j++) { + for (int j = 0; j < dataBlocksCount; j++) { DataBlock dataBlock = dataBlocks[j]; byte[] codewordBytes = dataBlock.getCodewords(); int numDataCodewords = dataBlock.getNumDataCodewords(); correctErrors(codewordBytes, numDataCodewords); for (int i = 0; i < numDataCodewords; i++) { - resultBytes[resultOffset++] = codewordBytes[i]; + // De-interlace data blocks. + resultBytes[i * dataBlocksCount + j] = codewordBytes[i]; } } diff --git a/core/test/data/blackbox/datamatrix-1/abcd-52x52-IDAutomation.gif.error b/core/test/data/blackbox/datamatrix-1/abcd-52x52-IDAutomation.gif similarity index 100% rename from core/test/data/blackbox/datamatrix-1/abcd-52x52-IDAutomation.gif.error rename to core/test/data/blackbox/datamatrix-1/abcd-52x52-IDAutomation.gif diff --git a/core/test/data/blackbox/datamatrix-1/abcd-52x52.png.error b/core/test/data/blackbox/datamatrix-1/abcd-52x52.png similarity index 100% rename from core/test/data/blackbox/datamatrix-1/abcd-52x52.png.error rename to core/test/data/blackbox/datamatrix-1/abcd-52x52.png diff --git a/core/test/data/blackbox/datamatrix-1/abcdefg-64x64.png.error b/core/test/data/blackbox/datamatrix-1/abcdefg-64x64.png similarity index 100% rename from core/test/data/blackbox/datamatrix-1/abcdefg-64x64.png.error rename to core/test/data/blackbox/datamatrix-1/abcdefg-64x64.png diff --git a/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java b/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java index 52a9461a3..869b0afb6 100644 --- a/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java +++ b/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java @@ -17,6 +17,7 @@ package com.google.zxing.datamatrix; import com.google.zxing.BarcodeFormat; +import com.google.zxing.MultiFormatReader; import com.google.zxing.common.AbstractBlackBoxTestCase; /** @@ -25,12 +26,11 @@ import com.google.zxing.common.AbstractBlackBoxTestCase; public final class DataMatrixBlackBox1TestCase extends AbstractBlackBoxTestCase { public DataMatrixBlackBox1TestCase() { - // TODO use MultiFormatReader here once Data Matrix decoder is done - super("test/data/blackbox/datamatrix-1", new DataMatrixReader(), BarcodeFormat.DATA_MATRIX); - addTest(13, 13, 0.0f); - addTest(13, 13, 90.0f); - addTest(13, 13, 180.0f); - addTest(13, 13, 270.0f); + super("test/data/blackbox/datamatrix-1", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX); + addTest(16, 16, 0.0f); + addTest(16, 16, 90.0f); + addTest(16, 16, 180.0f); + addTest(16, 16, 270.0f); } } \ No newline at end of file diff --git a/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox2TestCase.java b/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox2TestCase.java index ff4960359..34752df5d 100644 --- a/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox2TestCase.java +++ b/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox2TestCase.java @@ -17,6 +17,7 @@ package com.google.zxing.datamatrix; import com.google.zxing.BarcodeFormat; +import com.google.zxing.MultiFormatReader; import com.google.zxing.common.AbstractBlackBoxTestCase; /** @@ -25,8 +26,7 @@ import com.google.zxing.common.AbstractBlackBoxTestCase; public final class DataMatrixBlackBox2TestCase extends AbstractBlackBoxTestCase { public DataMatrixBlackBox2TestCase() { - // TODO use MultiFormatReader here once Data Matrix decoder is done - super("test/data/blackbox/datamatrix-2", new DataMatrixReader(), BarcodeFormat.DATA_MATRIX); + super("test/data/blackbox/datamatrix-2", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX); addTest(10, 10, 0.0f); addTest(13, 13, 90.0f); addTest(16, 16, 180.0f);