( image, startX, startY, width, height, moduleSize, resultPointCallback)
| 63 | } |
| 64 | |
| 65 | function AlignmentPatternFinder( image, startX, startY, width, height, moduleSize, resultPointCallback) |
| 66 | { |
| 67 | this.image = image; |
| 68 | this.possibleCenters = new Array(); |
| 69 | this.startX = startX; |
| 70 | this.startY = startY; |
| 71 | this.width = width; |
| 72 | this.height = height; |
| 73 | this.moduleSize = moduleSize; |
| 74 | this.crossCheckStateCount = new Array(0,0,0); |
| 75 | this.resultPointCallback = resultPointCallback; |
| 76 | |
| 77 | this.centerFromEnd=function(stateCount, end) |
| 78 | { |
| 79 | return (end - stateCount[2]) - stateCount[1] / 2.0; |
| 80 | } |
| 81 | this.foundPatternCross = function(stateCount) |
| 82 | { |
| 83 | var moduleSize = this.moduleSize; |
| 84 | var maxVariance = moduleSize / 2.0; |
| 85 | for (var i = 0; i < 3; i++) |
| 86 | { |
| 87 | if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) |
| 88 | { |
| 89 | return false; |
| 90 | } |
| 91 | } |
| 92 | return true; |
| 93 | } |
| 94 | |
| 95 | this.crossCheckVertical=function( startI, centerJ, maxCount, originalStateCountTotal) |
| 96 | { |
| 97 | var image = this.image; |
| 98 | |
| 99 | var maxI = qrcode.height; |
| 100 | var stateCount = this.crossCheckStateCount; |
| 101 | stateCount[0] = 0; |
| 102 | stateCount[1] = 0; |
| 103 | stateCount[2] = 0; |
| 104 | |
| 105 | // Start counting up from center |
| 106 | var i = startI; |
| 107 | while (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount) |
| 108 | { |
| 109 | stateCount[1]++; |
| 110 | i--; |
| 111 | } |
| 112 | // If already too many modules in this state or ran off the edge: |
| 113 | if (i < 0 || stateCount[1] > maxCount) |
| 114 | { |
| 115 | return NaN; |
| 116 | } |
| 117 | while (i >= 0 && !image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount) |
| 118 | { |
| 119 | stateCount[0]++; |
| 120 | i--; |
| 121 | } |
| 122 | if (stateCount[0] > maxCount) |
nothing calls this directly
no outgoing calls
no test coverage detected