* @throws FormatException if dimension is not >= 21 and 1 mod 4\r
*/\r
BitMatrixParser(BitMatrix bitMatrix) throws FormatException {\r
- int dimension = bitMatrix.getDimension();\r
+ int dimension = bitMatrix.getHeight();\r
if (dimension < 21 || (dimension & 0x03) != 1) {\r
throw FormatException.getFormatInstance();\r
}\r
}\r
\r
// Read top-left format info bits\r
- int formatInfoBits = 0;\r
+ int formatInfoBits1 = 0;\r
for (int i = 0; i < 6; i++) {\r
- formatInfoBits = copyBit(i, 8, formatInfoBits);\r
+ formatInfoBits1 = copyBit(i, 8, formatInfoBits1);\r
}\r
// .. and skip a bit in the timing pattern ...\r
- formatInfoBits = copyBit(7, 8, formatInfoBits);\r
- formatInfoBits = copyBit(8, 8, formatInfoBits);\r
- formatInfoBits = copyBit(8, 7, formatInfoBits);\r
+ formatInfoBits1 = copyBit(7, 8, formatInfoBits1);\r
+ formatInfoBits1 = copyBit(8, 8, formatInfoBits1);\r
+ formatInfoBits1 = copyBit(8, 7, formatInfoBits1);\r
// .. and skip a bit in the timing pattern ...\r
for (int j = 5; j >= 0; j--) {\r
- formatInfoBits = copyBit(8, j, formatInfoBits);\r
+ formatInfoBits1 = copyBit(8, j, formatInfoBits1);\r
}\r
\r
- parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits);\r
- if (parsedFormatInfo != null) {\r
- return parsedFormatInfo;\r
- }\r
-\r
- // Hmm, failed. Try the top-right/bottom-left pattern\r
- int dimension = bitMatrix.getDimension();\r
- formatInfoBits = 0;\r
+ // Read the top-right/bottom-left pattern too\r
+ int dimension = bitMatrix.getHeight();\r
+ int formatInfoBits2 = 0;\r
int iMin = dimension - 8;\r
for (int i = dimension - 1; i >= iMin; i--) {\r
- formatInfoBits = copyBit(i, 8, formatInfoBits);\r
+ formatInfoBits2 = copyBit(i, 8, formatInfoBits2);\r
}\r
for (int j = dimension - 7; j < dimension; j++) {\r
- formatInfoBits = copyBit(8, j, formatInfoBits);\r
+ formatInfoBits2 = copyBit(8, j, formatInfoBits2);\r
}\r
\r
- parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits);\r
+ parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits1, formatInfoBits2);\r
if (parsedFormatInfo != null) {\r
return parsedFormatInfo;\r
}\r
return parsedVersion;\r
}\r
\r
- int dimension = bitMatrix.getDimension();\r
+ int dimension = bitMatrix.getHeight();\r
\r
int provisionalVersion = (dimension - 17) >> 2;\r
if (provisionalVersion <= 6) {\r
// Get the data mask for the format used in this QR Code. This will exclude\r
// some bits from reading as we wind through the bit matrix.\r
DataMask dataMask = DataMask.forReference((int) formatInfo.getDataMask());\r
- int dimension = bitMatrix.getDimension();\r
+ int dimension = bitMatrix.getHeight();\r
dataMask.unmaskBitMatrix(bitMatrix, dimension);\r
\r
BitMatrix functionPattern = version.buildFunctionPattern();\r