final class FinderPatternFinder {\r
\r
private static final int CENTER_QUORUM = 2;\r
- private static final int BIG_SKIP = 3;\r
+ private static final int MIN_SKIP = 3; // 1 pixel/module times 3 modules/center\r
+ private static final int MAX_MODULES = 57; // support up to version 10 for mobile clients\r
\r
private final MonochromeBitmapSource image;\r
private final Vector possibleCenters;\r
// 1:1:3:1:1 ratio; this tracks the number of such modules seen so far\r
int[] stateCount = new int[5];\r
boolean done = false;\r
- // We can afford to examine every few lines until we've started finding\r
- // the patterns\r
- int iSkip = tryHarder ? 1 : BIG_SKIP;\r
+\r
+ // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the\r
+ // image, and then account for the center being 3 modules in size. This gives the smallest\r
+ // number of pixels the center could be, so skip this often. When trying harder, look for all\r
+ // QR versions regardless of how dense they are.\r
+ int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3);\r
+ if (iSkip < MIN_SKIP || tryHarder) {\r
+ iSkip = MIN_SKIP;\r
+ }\r
+\r
for (int i = iSkip - 1; i < maxI && !done; i += iSkip) {\r
// Get a row of black/white values\r
BitArray blackRow = image.getBlackRow(i, null, 0, maxJ);\r