Completed some modest tweaks to new Data Matrix code based on IntelliJ suggestions
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 11 Mar 2008 15:01:02 +0000 (15:01 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 11 Mar 2008 15:01:02 +0000 (15:01 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@265 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/common/DetectorResult.java [new file with mode: 0644]
core/src/com/google/zxing/datamatrix/DataMatrixReader.java
core/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java
core/src/com/google/zxing/datamatrix/decoder/DecodedBitStreamParser.java
core/src/com/google/zxing/datamatrix/decoder/Version.java
core/src/com/google/zxing/datamatrix/detector/Detector.java
core/src/com/google/zxing/qrcode/QRCodeReader.java
core/src/com/google/zxing/qrcode/decoder/BitSource.java [deleted file]
core/src/com/google/zxing/qrcode/detector/Detector.java
core/src/com/google/zxing/qrcode/detector/DetectorResult.java [deleted file]

diff --git a/core/src/com/google/zxing/common/DetectorResult.java b/core/src/com/google/zxing/common/DetectorResult.java
new file mode 100644 (file)
index 0000000..1dbfae5
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.zxing.common;
+
+import com.google.zxing.ResultPoint;
+
+/**
+ * <p>Encapsulates the result of detecting a barcode in an image. This includes the raw
+ * matrix of black/white pixels corresponding to the barcode, and possibly points of interest
+ * in the image, like the location of finder patterns or corners of the barcode in the image.</p>
+ *
+ * @author srowen@google.com (Sean Owen)
+ */
+public final class DetectorResult {
+
+  private final BitMatrix bits;
+  private final ResultPoint[] points;
+
+  public DetectorResult(BitMatrix bits, ResultPoint[] points) {
+    this.bits = bits;
+    this.points = points;
+  }
+
+  public BitMatrix getBits() {
+    return bits;
+  }
+
+  public ResultPoint[] getPoints() {
+    return points;
+  }
+
+}
\ No newline at end of file
index 5d7b4a3..e5bff73 100644 (file)
@@ -17,7 +17,6 @@
 package com.google.zxing.datamatrix;
 
 import com.google.zxing.BarcodeFormat;
-import com.google.zxing.DecodeHintType;
 import com.google.zxing.MonochromeBitmapSource;
 import com.google.zxing.Reader;
 import com.google.zxing.ReaderException;
@@ -25,8 +24,6 @@ import com.google.zxing.Result;
 import com.google.zxing.ResultPoint;
 import com.google.zxing.common.BitMatrix;
 import com.google.zxing.datamatrix.decoder.Decoder;
-import com.google.zxing.datamatrix.detector.Detector;
-import com.google.zxing.datamatrix.detector.DetectorResult;
 
 import java.util.Hashtable;
 
index 3bc61cd..a14eb95 100644 (file)
@@ -40,7 +40,7 @@ final class BitMatrixParser {
     }\r
     \r
     version = readVersion(bitMatrix);\r
-    this.mappingBitMatrix = ExtractDataRegion(bitMatrix, version);\r
+    this.mappingBitMatrix = extractDataRegion(bitMatrix, version);\r
     // TODO(bbrown): Make this work for rectangular symbols\r
     this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getDimension());\r
   }\r
@@ -81,8 +81,6 @@ final class BitMatrixParser {
 \r
     byte[] result = new byte[version.getTotalCodewords()];\r
     int resultOffset = 0;\r
-    int currentByte = 0;\r
-    int bitsRead = 0;\r
     \r
     int row = 4;\r
     int column = 0;\r
@@ -144,10 +142,10 @@ final class BitMatrixParser {
   /**\r
    * <p>Reads a bit of the mapping matrix accounting for boundry wrapping.</p>\r
    * \r
-   * @param Row to read in the mapping matrix\r
-   * @param Column to read in the mapping matrix\r
-   * @param Number of rows in the mapping matrix\r
-   * @param Number of columns in the mapping matrix\r
+   * @param row Row to read in the mapping matrix\r
+   * @param column Column to read in the mapping matrix\r
+   * @param numRows Number of rows in the mapping matrix\r
+   * @param numColumns Number of columns in the mapping matrix\r
    * @return value of the given bit in the mapping matrix\r
    */\r
   boolean readModule(int row, int column, int numRows, int numColumns) {\r
@@ -169,10 +167,10 @@ final class BitMatrixParser {
    * \r
    * <p>See ISO 16022:2006, 5.8.1 Figure 6</p>\r
    * \r
-   * @param Current row in the mapping matrix, anchored at the 8th bit (LSB) of the pattern\r
-   * @param Current column in the mapping matrix, anchored at the 8th bit (LSB) of the pattern\r
-   * @param Number of rows in the mapping matrix\r
-   * @param Number of columns in the mapping matrix\r
+   * @param row Current row in the mapping matrix, anchored at the 8th bit (LSB) of the pattern\r
+   * @param column Current column in the mapping matrix, anchored at the 8th bit (LSB) of the pattern\r
+   * @param numRows Number of rows in the mapping matrix\r
+   * @param numColumns Number of columns in the mapping matrix\r
    * @return byte from the utah shape\r
    */\r
   int readUtah(int row, int column, int numRows, int numColumns) {\r
@@ -216,8 +214,8 @@ final class BitMatrixParser {
    * \r
    * <p>See ISO 16022:2006, Figure F.3</p>\r
    * \r
-   * @param Number of rows in the mapping matrix\r
-   * @param Number of columns in the mapping matrix\r
+   * @param numRows Number of rows in the mapping matrix\r
+   * @param numColumns Number of columns in the mapping matrix\r
    * @return byte from the Corner condition 1\r
    */\r
   int readCorner1(int numRows, int numColumns) {\r
@@ -261,8 +259,8 @@ final class BitMatrixParser {
    * \r
    * <p>See ISO 16022:2006, Figure F.4</p>\r
    * \r
-   * @param Number of rows in the mapping matrix\r
-   * @param Number of columns in the mapping matrix\r
+   * @param numRows Number of rows in the mapping matrix\r
+   * @param numColumns Number of columns in the mapping matrix\r
    * @return byte from the Corner condition 2\r
    */\r
   int readCorner2(int numRows, int numColumns) {\r
@@ -306,8 +304,8 @@ final class BitMatrixParser {
    * \r
    * <p>See ISO 16022:2006, Figure F.5</p>\r
    * \r
-   * @param Number of rows in the mapping matrix\r
-   * @param Number of columns in the mapping matrix\r
+   * @param numRows Number of rows in the mapping matrix\r
+   * @param numColumns Number of columns in the mapping matrix\r
    * @return byte from the Corner condition 3\r
    */\r
   int readCorner3(int numRows, int numColumns) {\r
@@ -351,8 +349,8 @@ final class BitMatrixParser {
    * \r
    * <p>See ISO 16022:2006, Figure F.6</p>\r
    * \r
-   * @param Number of rows in the mapping matrix\r
-   * @param Number of columns in the mapping matrix\r
+   * @param numRows Number of rows in the mapping matrix\r
+   * @param numColumns Number of columns in the mapping matrix\r
    * @return byte from the Corner condition 4\r
    */\r
   int readCorner4(int numRows, int numColumns) {\r
@@ -395,11 +393,11 @@ final class BitMatrixParser {
    * <p>Extracts the data region from a {@link BitMatrix} that contains\r
    * alignment patterns.</p>\r
    * \r
-   * @param bitMarix Original {@link BitMatrix} with alignment patterns\r
+   * @param bitMatrix Original {@link BitMatrix} with alignment patterns\r
    * @param version {@link Version} information corresponding with the bitMatrix\r
    * @return BitMatrix that has the alignment patterns removed\r
    */\r
-  BitMatrix ExtractDataRegion(BitMatrix bitMatrix, Version version) {\r
+  BitMatrix extractDataRegion(BitMatrix bitMatrix, Version version) {\r
     int symbolSizeRows = version.getSymbolSizeRows();\r
     int symbolSizeColumns = version.getSymbolSizeColumns();\r
     \r
index 9d6f207..09dcebe 100644 (file)
@@ -18,7 +18,6 @@ package com.google.zxing.datamatrix.decoder;
 
 import com.google.zxing.ReaderException;
 import com.google.zxing.common.BitSource;
-import java.io.UnsupportedEncodingException;
 
 /**
  * <p>Data Matrix Codes can encode text as bits in one of several modes, and can use multiple modes
@@ -104,12 +103,10 @@ final class DecodedBitStreamParser {
   */
   private static int decodeAsciiSegment(BitSource bits,
                                         StringBuffer result) throws ReaderException {
-    char oneByte;
     boolean upperShift = false;
-    int bytesProcessed = 0;
     do {
-           oneByte = (char) bits.readBits(8);
-           if (oneByte == 0) {
+      char oneByte = (char) bits.readBits(8);
+      if (oneByte == '\0') {
                // TODO(bbrown): I think this would be a bug, not sure
                throw new ReaderException("0 is an invalid ASCII codeword");
            } else if (oneByte <= 128) {  // ASCII data (ASCII value + 1)
@@ -164,7 +161,6 @@ final class DecodedBitStreamParser {
                                       StringBuffer result) throws ReaderException {
     // Three C40 values are encoded in a 16-bit value as
     // (1600 * C1) + (40 * C2) + C3 + 1
-    char firstByte;
     int shift = 0;
     // TODO(bbrown): The Upper Shift with C40 doesn't work in the 4 value scenario all the time
     boolean upperShift = false;
@@ -175,67 +171,67 @@ final class DecodedBitStreamParser {
         return ASCII_ENCODE;
       }
 
-      firstByte = (char) bits.readBits(8);
-      
+      char firstByte = (char) bits.readBits(8);
+
       if (firstByte == 254) {  // Unlatch codeword
         return ASCII_ENCODE;
       }
 
-      int fullBitValue = firstByte * 256 + bits.readBits(8) - 1;
+      int fullBitValue = (firstByte << 8) + bits.readBits(8) - 1;
 
-      char[] CValues = new char[3];
-      CValues[0] = (char) (fullBitValue / 1600);
-      fullBitValue -= CValues[0] * 1600;
-      CValues[1] = (char) (fullBitValue / 40);
-      fullBitValue -= CValues[1] * 40;
-      CValues[2] = (char) (fullBitValue);
+      char[] cValues = new char[3];
+      cValues[0] = (char) (fullBitValue / 1600);
+      fullBitValue -= cValues[0] * 1600;
+      cValues[1] = (char) (fullBitValue / 40);
+      fullBitValue -= cValues[1] * 40;
+      cValues[2] = (char) fullBitValue;
 
       for (int i = 0; i < 3; i++) {
         if (shift == 0) {
-          if (CValues[i] == 0) {  // Shift 1
+          if (cValues[i] == 0) {  // Shift 1
             shift = 1;
             continue;
-          } else if (CValues[i] == 1) {  // Shift 2
+          } else if (cValues[i] == 1) {  // Shift 2
             shift = 2;
             continue;
-          } else if (CValues[i] == 2) {  // Shift 3
+          } else if (cValues[i] == 2) {  // Shift 3
             shift = 3;
             continue;
           }
           if (upperShift) {
-            result.append((char)(C40_BASIC_SET_CHARS[CValues[i]] + 128));
+            result.append((char)(C40_BASIC_SET_CHARS[cValues[i]] + 128));
             upperShift = false;
           } else {
-            result.append(C40_BASIC_SET_CHARS[CValues[i]]);
+            result.append(C40_BASIC_SET_CHARS[cValues[i]]);
           }
         } else if (shift == 1) {
           if (upperShift) {
-            result.append((char) (CValues[i] + 128));
+            result.append((char) (cValues[i] + 128));
             upperShift = false;
           } else {
-            result.append((char) CValues[i]);
+            result.append(cValues[i]);
           }
         } else if (shift == 2) {
-          if (CValues[i] < 27) {
+          if (cValues[i] < 27) {
             if(upperShift) {
-              result.append((char)(C40_SHIFT2_SET_CHARS[CValues[i]] + 128));
+              result.append((char)(C40_SHIFT2_SET_CHARS[cValues[i]] + 128));
               upperShift = false;
             } else {
-              result.append(C40_SHIFT2_SET_CHARS[CValues[i]]);
+              result.append(C40_SHIFT2_SET_CHARS[cValues[i]]);
             }
-          } else if (CValues[i] == 27) {  // FNC1
+          } else if (cValues[i] == 27) {  // FNC1
             throw new ReaderException("Currently not supporting FNC1");
-          } else if (CValues[i] == 30) {  // Upper Shirt
+          } else if (cValues[i] == 30) {  // Upper Shirt
             upperShift = true;
           } else {
-            throw new ReaderException(Integer.toString(CValues[i]) + " is not valid in the C40 Shift 2 set");
+            throw new ReaderException(Integer.toString(cValues[i]) + " is not valid in the C40 Shift 2 set");
           }
         } else if (shift == 3) {
           if (upperShift) {
-            result.append((char) (CValues[i] + 224));
+            result.append((char) (cValues[i] + 224));
             upperShift = false;
           } else {
-            result.append((char) CValues[i] + 96);
+            result.append((char) cValues[i] + 96);
           }
         } else {
           throw new ReaderException("Invalid shift value");
@@ -252,7 +248,6 @@ final class DecodedBitStreamParser {
                                        StringBuffer result) throws ReaderException {
     // Three Text values are encoded in a 16-bit value as
     // (1600 * C1) + (40 * C2) + C3 + 1
-    char firstByte;
     int shift = 0;
     // TODO(bbrown): The Upper Shift with Text doesn't work in the 4 value scenario all the time
     boolean upperShift = false;
@@ -263,68 +258,68 @@ final class DecodedBitStreamParser {
         return ASCII_ENCODE;
       }
 
-      firstByte = (char) bits.readBits(8);
-      
+      char firstByte = (char) bits.readBits(8);
+
       if (firstByte == 254) {  // Unlatch codeword
         return ASCII_ENCODE;
       }
 
-      int fullBitValue = firstByte * 256 + bits.readBits(8) - 1;
+      int fullBitValue = (firstByte << 8) + bits.readBits(8) - 1;
 
-      char[] CValues = new char[3];
-      CValues[0] = (char) (fullBitValue / 1600);
-      fullBitValue -= CValues[0] * 1600;
-      CValues[1] = (char) (fullBitValue / 40);
-      fullBitValue -= CValues[1] * 40;
-      CValues[2] = (char) (fullBitValue);
+      char[] cValues = new char[3];
+      cValues[0] = (char) (fullBitValue / 1600);
+      fullBitValue -= cValues[0] * 1600;
+      cValues[1] = (char) (fullBitValue / 40);
+      fullBitValue -= cValues[1] * 40;
+      cValues[2] = (char) fullBitValue;
 
       for (int i = 0; i < 3; i++) {
         if (shift == 0) {
-          if (CValues[i] == 0) {  // Shift 1
+          if (cValues[i] == 0) {  // Shift 1
             shift = 1;
             continue;
-          } else if (CValues[i] == 1) {  // Shift 2
+          } else if (cValues[i] == 1) {  // Shift 2
             shift = 2;
             continue;
-          } else if (CValues[i] == 2) {  // Shift 3
+          } else if (cValues[i] == 2) {  // Shift 3
             shift = 3;
             continue;
           }
           if (upperShift) {
-            result.append((char)(TEXT_BASIC_SET_CHARS[CValues[i]] + 128));
+            result.append((char)(TEXT_BASIC_SET_CHARS[cValues[i]] + 128));
             upperShift = false;
           } else {
-            result.append(TEXT_BASIC_SET_CHARS[CValues[i]]);
+            result.append(TEXT_BASIC_SET_CHARS[cValues[i]]);
           }
         } else if (shift == 1) {
           if (upperShift) {
-            result.append((char) (CValues[i] + 128));
+            result.append((char) (cValues[i] + 128));
             upperShift = false;
           } else {
-            result.append((char) CValues[i]);
+            result.append((char) cValues[i]);
           }
         } else if (shift == 2) {
           // Shift 2 for Text is the same encoding as C40
-          if (CValues[i] < 27) {
+          if (cValues[i] < 27) {
             if(upperShift) {
-              result.append((char)(C40_SHIFT2_SET_CHARS[CValues[i]] + 128));
+              result.append((char)(C40_SHIFT2_SET_CHARS[cValues[i]] + 128));
               upperShift = false;
             } else {
-              result.append(C40_SHIFT2_SET_CHARS[CValues[i]]);
+              result.append(C40_SHIFT2_SET_CHARS[cValues[i]]);
             }
-          } else if (CValues[i] == 27) {  // FNC1
+          } else if (cValues[i] == 27) {  // FNC1
             throw new ReaderException("Currently not supporting FNC1");
-          } else if (CValues[i] == 30) {  // Upper Shirt
+          } else if (cValues[i] == 30) {  // Upper Shirt
             upperShift = true;
           } else {
-            throw new ReaderException(Integer.toString(CValues[i]) + " is not valid in the C40 Shift 2 set");
+            throw new ReaderException(Integer.toString(cValues[i]) + " is not valid in the C40 Shift 2 set");
           }
         } else if (shift == 3) {
           if (upperShift) {
-            result.append((char)(TEXT_SHIFT3_SET_CHARS[CValues[i]] + 128));
+            result.append((char)(TEXT_SHIFT3_SET_CHARS[cValues[i]] + 128));
             upperShift = false;
           } else {
-            result.append(TEXT_SHIFT3_SET_CHARS[CValues[i]]);
+            result.append(TEXT_SHIFT3_SET_CHARS[cValues[i]]);
           }
         } else {
           throw new ReaderException("Invalid shift value");
@@ -341,7 +336,6 @@ final class DecodedBitStreamParser {
                                           StringBuffer result) throws ReaderException {
     // Three ANSI X12 values are encoded in a 16-bit value as
     // (1600 * C1) + (40 * C2) + C3 + 1
-    char firstByte;
 
     do {
       // If there is only one byte left then it will be encoded as ASCII
@@ -349,37 +343,37 @@ final class DecodedBitStreamParser {
         return ASCII_ENCODE;
       }
 
-      firstByte = (char) bits.readBits(8);
-      
+      char firstByte = (char) bits.readBits(8);
+
       if (firstByte == 254) {  // Unlatch codeword
         return ASCII_ENCODE;
       }
 
-      int fullBitValue = firstByte * 256 + bits.readBits(8) - 1;
+      int fullBitValue = (firstByte << 8) + bits.readBits(8) - 1;
 
-      char[] CValues = new char[3];
-      CValues[0] = (char) (fullBitValue / 1600);
-      fullBitValue -= CValues[0] * 1600;
-      CValues[1] = (char) (fullBitValue / 40);
-      fullBitValue -= CValues[1] * 40;
-      CValues[2] = (char) (fullBitValue);
+      char[] cValues = new char[3];
+      cValues[0] = (char) (fullBitValue / 1600);
+      fullBitValue -= cValues[0] * 1600;
+      cValues[1] = (char) (fullBitValue / 40);
+      fullBitValue -= cValues[1] * 40;
+      cValues[2] = (char) fullBitValue;
 
       for (int i = 0; i < 3; i++) {
         // TODO(bbrown): These really aren't X12 symbols, we are converting to ASCII chars
-        if (CValues[i] == 0) {  // X12 segment terminator <CR>
+        if (cValues[i] == 0) {  // X12 segment terminator <CR>
           result.append("<CR>");
-        } else if (CValues[i] == 1) {  // X12 segment separator *
+        } else if (cValues[i] == 1) {  // X12 segment separator *
           result.append('*');
-        } else if (CValues[i] == 2) {  // X12 sub-element separator >
+        } else if (cValues[i] == 2) {  // X12 sub-element separator >
           result.append('>');
-        } else if (CValues[i] == 3) {  // space
+        } else if (cValues[i] == 3) {  // space
           result.append(' ');
-        } else if (CValues[i] < 14) {  // 0 - 9
-          result.append((char) (CValues[i] + 44));
-        } else if (CValues[i] < 40) {  // A - Z
-          result.append((char) (CValues[i] + 51));
+        } else if (cValues[i] < 14) {  // 0 - 9
+          result.append((char) (cValues[i] + 44));
+        } else if (cValues[i] < 40) {  // A - Z
+          result.append((char) (cValues[i] + 51));
         } else {
-          throw new ReaderException(Integer.toString(CValues[i]) + " is not valid in the ANSI X12 set");
+          throw new ReaderException(Integer.toString(cValues[i]) + " is not valid in the ANSI X12 set");
         }
       }
     } while (bits.available() > 0);
@@ -398,11 +392,10 @@ final class DecodedBitStreamParser {
       if (bits.available() <= 16) {
         return ASCII_ENCODE;
       }
-      
-      char edifactValue;
+
       for (int i = 0; i < 4; i++) {
-        edifactValue = (char) bits.readBits(6);
-        
+        char edifactValue = (char) bits.readBits(6);
+
         // Check for the unlatch character
         if (edifactValue == 0x2B67) {  // 011111
           unlatch = true;
@@ -429,7 +422,7 @@ final class DecodedBitStreamParser {
                                           StringBuffer result) throws ReaderException {
     // Figure out how long the Base 256 Segment is.
     char d1 = (char) bits.readBits(8);
-    int count = 0;
+    int count;
     if (d1 == 0) {  // Read the remainder of the symbol
       count = bits.available() / 8;
     } else if (d1 < 250) {
@@ -439,7 +432,7 @@ final class DecodedBitStreamParser {
     }
     char[] readBytes = new char[count];
     for (int i = 0; i < count; i++) {
-      result.append((char)unrandomize255State((char) bits.readBits(8), count));
+      result.append(unrandomize255State((char) bits.readBits(8), count));
     }
     
     return ASCII_ENCODE;
index dc6469b..a7dbdc0 100644 (file)
@@ -17,7 +17,6 @@
 package com.google.zxing.datamatrix.decoder;\r
 \r
 import com.google.zxing.ReaderException;\r
-import com.google.zxing.common.BitMatrix;\r
 \r
 /**\r
  * The Version object encapsulates attributes about a particular\r
@@ -108,10 +107,8 @@ public final class Version {
     int numVersions = VERSIONS.length;\r
     for (int i = 0; i < numVersions; ++i){\r
       Version version = VERSIONS[i];\r
-      if (version.symbolSizeRows == numRows) {\r
-        if (version.symbolSizeColumns == numColumns) {\r
-          return version;\r
-        }\r
+      if (version.symbolSizeRows == numRows && version.symbolSizeColumns == numColumns) {\r
+        return version;\r
       }\r
     }\r
     \r
index e445976..11e63ff 100644 (file)
 
 package com.google.zxing.datamatrix.detector;
 
-import com.google.zxing.BlackPointEstimationMethod;
 import com.google.zxing.MonochromeBitmapSource;
 import com.google.zxing.ReaderException;
-import com.google.zxing.ResultPoint;
-import com.google.zxing.common.BitMatrix;
-import com.google.zxing.datamatrix.decoder.Version;
+import com.google.zxing.common.DetectorResult;
 
 /**
  * <p>Encapsulates logic that can detect a Data Matrix Code in an image, even if the Data Matrix Code
index 7001576..3672377 100644 (file)
@@ -24,9 +24,9 @@ import com.google.zxing.ReaderException;
 import com.google.zxing.Result;
 import com.google.zxing.ResultPoint;
 import com.google.zxing.common.BitMatrix;
+import com.google.zxing.common.DetectorResult;
 import com.google.zxing.qrcode.decoder.Decoder;
 import com.google.zxing.qrcode.detector.Detector;
-import com.google.zxing.qrcode.detector.DetectorResult;
 
 import java.util.Hashtable;
 
diff --git a/core/src/com/google/zxing/qrcode/decoder/BitSource.java b/core/src/com/google/zxing/qrcode/decoder/BitSource.java
deleted file mode 100755 (executable)
index c19e34d..0000000
+++ /dev/null
@@ -1,96 +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
-/**\r
- * <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the\r
- * number of bits read is not often a multiple of 8.</p>\r
- *\r
- * <p>This class is not thread-safe.</p>\r
- *\r
- * @author srowen@google.com (Sean Owen)\r
- */\r
-final class BitSource {\r
-\r
-  private final byte[] bytes;\r
-  private int byteOffset;\r
-  private int bitOffset;\r
-\r
-  /**\r
-   * @param bytes bytes from which this will read bits. Bits will be read from the first byte first.\r
-   * Bits are read within a byte from most-significant to least-significant bit.\r
-   */\r
-  BitSource(byte[] bytes) {\r
-    this.bytes = bytes;\r
-  }\r
-\r
-  /**\r
-   * @param numBits number of bits to read\r
-   * @return int representing the bits read. The bits will appear as the least-significant\r
-   *         bits of the int\r
-   * @throws IllegalArgumentException if numBits isn't in [1,32]\r
-   */\r
-  int readBits(int numBits) {\r
-    if (numBits < 1 || numBits > 32) {\r
-      throw new IllegalArgumentException();\r
-    }\r
-\r
-    int result = 0;\r
-\r
-    // First, read remainder from current byte\r
-    if (bitOffset > 0) {\r
-      int bitsLeft = 8 - bitOffset;\r
-      int toRead = numBits < bitsLeft ? numBits : bitsLeft;\r
-      int bitsToNotRead = bitsLeft - toRead;\r
-      int mask = (0xFF >> (8 - toRead)) << bitsToNotRead;\r
-      result = (bytes[byteOffset] & mask) >> bitsToNotRead;\r
-      numBits -= toRead;\r
-      bitOffset += toRead;\r
-      if (bitOffset == 8) {\r
-        bitOffset = 0;\r
-        byteOffset++;\r
-      }\r
-    }\r
-\r
-    // Next read whole bytes\r
-    if (numBits > 0) {\r
-      while (numBits >= 8) {\r
-        result = (result << 8) | (bytes[byteOffset] & 0xFF);\r
-        byteOffset++;\r
-        numBits -= 8;\r
-      }\r
-\r
-      // Finally read a partial byte\r
-      if (numBits > 0) {\r
-        int bitsToNotRead = 8 - numBits;\r
-        int mask = (0xFF >> bitsToNotRead) << bitsToNotRead;\r
-        result = (result << numBits) | ((bytes[byteOffset] & mask) >> bitsToNotRead);\r
-        bitOffset += numBits;\r
-      }\r
-    }\r
-\r
-    return result;\r
-  }\r
-\r
-  /**\r
-   * @return number of bits that can be read successfully\r
-   */\r
-  int available() {\r
-    return 8 * (bytes.length - byteOffset) - bitOffset;\r
-  }\r
-\r
-}\r
index 940476b..3b5f94f 100644 (file)
@@ -21,6 +21,7 @@ import com.google.zxing.MonochromeBitmapSource;
 import com.google.zxing.ReaderException;
 import com.google.zxing.ResultPoint;
 import com.google.zxing.common.BitMatrix;
+import com.google.zxing.common.DetectorResult;
 import com.google.zxing.qrcode.decoder.Version;
 
 /**
diff --git a/core/src/com/google/zxing/qrcode/detector/DetectorResult.java b/core/src/com/google/zxing/qrcode/detector/DetectorResult.java
deleted file mode 100644 (file)
index 15fb78c..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.zxing.qrcode.detector;
-
-import com.google.zxing.ResultPoint;
-import com.google.zxing.common.BitMatrix;
-
-/**
- * <p>Encapsulates the result of detecting a barcode in an image. This includes the raw
- * matrix of black/white pixels corresponding to the barcode, and possibly points of interest
- * in the image, like the location of finder patterns or corners of the barcode in the image.</p>
- *
- * @author srowen@google.com (Sean Owen)
- */
-public final class DetectorResult {
-
-  private final BitMatrix bits;
-  private final ResultPoint[] points;
-
-  DetectorResult(BitMatrix bits, ResultPoint[] points) {
-    this.bits = bits;
-    this.points = points;
-  }
-
-  public BitMatrix getBits() {
-    return bits;
-  }
-
-  public ResultPoint[] getPoints() {
-    return points;
-  }
-
-}
\ No newline at end of file