git-svn-id: http://zxing.googlecode.com/svn/trunk@5 59b500cc-1b3d-0410-9834-0bbf25fbcc57
[zxing.git] / src / com / google / zxing / qrcode / decoder / Decoder.java
diff --git a/src/com/google/zxing/qrcode/decoder/Decoder.java b/src/com/google/zxing/qrcode/decoder/Decoder.java
deleted file mode 100644 (file)
index a37128f..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*\r
- * Copyright 2007 Google Inc.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package com.google.zxing.qrcode.decoder;\r
-\r
-import com.google.zxing.ReaderException;\r
-import com.google.zxing.common.BitMatrix;\r
-import com.google.zxing.common.reedsolomon.ReedSolomonDecoder;\r
-import com.google.zxing.common.reedsolomon.ReedSolomonException;\r
-\r
-/**\r
- * @author srowen@google.com (Sean Owen)\r
- */\r
-public final class Decoder {\r
-\r
-  private Decoder() {\r
-  }\r
-\r
-  public static String decode(boolean[][] image) throws ReaderException {\r
-    int dimension = image.length;\r
-    BitMatrix bits = new BitMatrix(dimension);\r
-    for (int i = 0; i < dimension; i++) {\r
-      for (int j = 0; j < dimension; j++) {\r
-        if (image[i][j]) {\r
-          bits.set(i, j);\r
-        }\r
-      }\r
-    }\r
-    return decode(bits);\r
-  }\r
-\r
-  public static String decode(BitMatrix bits) throws ReaderException {\r
-    BitMatrixParser parser = new BitMatrixParser(bits);\r
-    Version version = parser.readVersion();\r
-    ErrorCorrectionLevel ecLevel = parser.readFormatInformation().getErrorCorrectionLevel();\r
-    byte[] codewords = parser.readCodewords();\r
-    DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version, ecLevel);\r
-    int totalBytes = 0;\r
-    for (int i = 0; i < dataBlocks.length; i++) {\r
-      totalBytes += dataBlocks[i].getNumDataCodewords();\r
-    }\r
-    byte[] resultBytes = new byte[totalBytes];\r
-    int resultOffset = 0;\r
-    for (int j = 0; j < dataBlocks.length; j++) {\r
-      DataBlock dataBlock = dataBlocks[j];\r
-      byte[] codewordBytes = dataBlock.getCodewords();\r
-      int numDataCodewords = dataBlock.getNumDataCodewords();\r
-      correctErrors(codewordBytes, numDataCodewords);\r
-      for (int i = 0; i < numDataCodewords; i++) {\r
-        resultBytes[resultOffset++] = codewordBytes[i];\r
-      }\r
-    }\r
-\r
-    return DecodedBitStreamParser.decode(resultBytes, version);\r
-  }\r
-\r
-  private static void correctErrors(byte[] codewordBytes, int numDataCodewords)\r
-      throws ReaderException {\r
-    int numCodewords = codewordBytes.length;\r
-    int[] codewordsInts = new int[numCodewords];\r
-    for (int i = 0; i < numCodewords; i++) {\r
-      codewordsInts[i] = codewordBytes[i] & 0xFF;\r
-    }\r
-    int numECCodewords = codewordBytes.length - numDataCodewords;\r
-    try {\r
-      ReedSolomonDecoder.decode(codewordsInts, numECCodewords);\r
-    } catch (ReedSolomonException rse) {\r
-      throw new ReaderException(rse.toString());\r
-    }\r
-    for (int i = 0; i < numDataCodewords; i++) {\r
-      codewordBytes[i] = (byte) codewordsInts[i];\r
-    }\r
-  }\r
-\r
-}\r