diff --git a/index.html b/index.html
index 2c7cb58..5d5c288 100644
--- a/index.html
+++ b/index.html
@@ -89,7 +89,7 @@
@@ -329,7 +329,7 @@
QR Decoder
Decoded Message :
-
+
Error :
diff --git a/js/jsqrcode/alignpat.js b/js/jsqrcode/alignpat.js
index 9140f0a..967473f 100644
--- a/js/jsqrcode/alignpat.js
+++ b/js/jsqrcode/alignpat.js
@@ -1,289 +1,279 @@
-/*
- Ported to JavaScript by Lazar Laszlo 2011
-
- lazarsoft@gmail.com, www.lazarsoft.info
-
-*/
-
-/*
-*
-* Copyright 2007 ZXing authors
-*
-* 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.
-*/
-
-
-function AlignmentPattern(posX, posY, estimatedModuleSize)
-{
- this.x=posX;
- this.y=posY;
- this.count = 1;
- this.estimatedModuleSize = estimatedModuleSize;
-
- Object.defineProperties(this, {
- 'EstimatedModuleSize': {
- get: function () {
- return this.estimatedModuleSize;
- }
- },
-
- "Count": {
- get: function() {
- return this.count;
- }
- },
-
- "X": {
- get: function() {
- return Math.floor(this.x);
- }
- },
-
- "Y": {
- get: function() {
- return Math.floor(this.y);
- }
- }
- });
-
- this.incrementCount = function()
- {
- this.count++;
- }
- this.aboutEquals=function( moduleSize, i, j)
- {
- if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize)
- {
- var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
- return moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;
- }
- return false;
- }
-
-}
-
-function AlignmentPatternFinder( image, startX, startY, width, height, moduleSize, resultPointCallback)
-{
- this.image = image;
- this.possibleCenters = new Array();
- this.startX = startX;
- this.startY = startY;
- this.width = width;
- this.height = height;
- this.moduleSize = moduleSize;
- this.crossCheckStateCount = new Array(0,0,0);
- this.resultPointCallback = resultPointCallback;
-
- this.centerFromEnd=function(stateCount, end)
- {
- return (end - stateCount[2]) - stateCount[1] / 2.0;
- }
- this.foundPatternCross = function(stateCount)
- {
- var moduleSize = this.moduleSize;
- var maxVariance = moduleSize / 2.0;
- for (var i = 0; i < 3; i++)
- {
- if (Math.abs(moduleSize - stateCount[i]) >= maxVariance)
- {
- return false;
- }
- }
- return true;
- }
-
- this.crossCheckVertical=function( startI, centerJ, maxCount, originalStateCountTotal)
- {
- var image = this.image;
-
- var maxI = qrcode.height;
- var stateCount = this.crossCheckStateCount;
- stateCount[0] = 0;
- stateCount[1] = 0;
- stateCount[2] = 0;
-
- // Start counting up from center
- var i = startI;
- while (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)
- {
- stateCount[1]++;
- i--;
- }
- // If already too many modules in this state or ran off the edge:
- if (i < 0 || stateCount[1] > maxCount)
- {
- return NaN;
- }
- while (i >= 0 && !image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount)
- {
- stateCount[0]++;
- i--;
- }
- if (stateCount[0] > maxCount)
- {
- return NaN;
- }
-
- // Now also count down from center
- i = startI + 1;
- while (i < maxI && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)
- {
- stateCount[1]++;
- i++;
- }
- if (i == maxI || stateCount[1] > maxCount)
- {
- return NaN;
- }
- while (i < maxI && !image[centerJ + i*qrcode.width] && stateCount[2] <= maxCount)
- {
- stateCount[2]++;
- i++;
- }
- if (stateCount[2] > maxCount)
- {
- return NaN;
- }
-
- var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
- if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal)
- {
- return NaN;
- }
-
- return this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, i):NaN;
- }
-
- this.handlePossibleCenter=function( stateCount, i, j)
- {
- var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
- var centerJ = this.centerFromEnd(stateCount, j);
- var centerI = this.crossCheckVertical(i, Math.floor (centerJ), 2 * stateCount[1], stateCountTotal);
- if (!isNaN(centerI))
- {
- var estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0;
- var max = this.possibleCenters.length;
- for (var index = 0; index < max; index++)
- {
- var center = this.possibleCenters[index];
- // Look for about the same center and module size:
- if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
- {
- return new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
- }
- }
- // Hadn't found this before; save it
- var point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
- this.possibleCenters.push(point);
- if (this.resultPointCallback != null)
- {
- this.resultPointCallback.foundPossibleResultPoint(point);
- }
- }
- return null;
- }
-
- this.find = function()
- {
- var startX = this.startX;
- var height = this.height;
- var maxJ = startX + width;
- var middleI = startY + (height >> 1);
- // We are looking for black/white/black modules in 1:1:1 ratio;
- // this tracks the number of black/white/black modules seen so far
- var stateCount = new Array(0,0,0);
- for (var iGen = 0; iGen < height; iGen++)
- {
- // Search from middle outwards
- var i = middleI + ((iGen & 0x01) == 0?((iGen + 1) >> 1):- ((iGen + 1) >> 1));
- stateCount[0] = 0;
- stateCount[1] = 0;
- stateCount[2] = 0;
- var j = startX;
- // Burn off leading white pixels before anything else; if we start in the middle of
- // a white run, it doesn't make sense to count its length, since we don't know if the
- // white run continued to the left of the start point
- while (j < maxJ && !image[j + qrcode.width* i])
- {
- j++;
- }
- var currentState = 0;
- while (j < maxJ)
- {
- if (image[j + i*qrcode.width])
- {
- // Black pixel
- if (currentState == 1)
- {
- // Counting black pixels
- stateCount[currentState]++;
- }
- else
- {
- // Counting white pixels
- if (currentState == 2)
- {
- // A winner?
- if (this.foundPatternCross(stateCount))
- {
- // Yes
- var confirmed = this.handlePossibleCenter(stateCount, i, j);
- if (confirmed != null)
- {
- return confirmed;
- }
- }
- stateCount[0] = stateCount[2];
- stateCount[1] = 1;
- stateCount[2] = 0;
- currentState = 1;
- }
- else
- {
- stateCount[++currentState]++;
- }
- }
- }
- else
- {
- // White pixel
- if (currentState == 1)
- {
- // Counting black pixels
- currentState++;
- }
- stateCount[currentState]++;
- }
- j++;
- }
- if (this.foundPatternCross(stateCount))
- {
- var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
- if (confirmed != null)
- {
- return confirmed;
- }
- }
- }
-
- // Hmm, nothing we saw was observed and confirmed twice. If we had
- // any guess at all, return it.
- if (!(this.possibleCenters.length == 0))
- {
- return this.possibleCenters[0];
- }
-
- throw "Couldn't find enough alignment patterns";
- }
-
-}
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* 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.
+*/
+
+
+function AlignmentPattern(posX, posY, estimatedModuleSize)
+{
+ this.x=posX;
+ this.y=posY;
+ this.count = 1;
+ this.estimatedModuleSize = estimatedModuleSize;
+
+ this.__defineGetter__("EstimatedModuleSize", function()
+ {
+ return this.estimatedModuleSize;
+ });
+ this.__defineGetter__("Count", function()
+ {
+ return this.count;
+ });
+ this.__defineGetter__("X", function()
+ {
+ return Math.floor(this.x);
+ });
+ this.__defineGetter__("Y", function()
+ {
+ return Math.floor(this.y);
+ });
+ this.incrementCount = function()
+ {
+ this.count++;
+ }
+ this.aboutEquals=function( moduleSize, i, j)
+ {
+ if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize)
+ {
+ var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
+ return moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;
+ }
+ return false;
+ }
+
+}
+
+function AlignmentPatternFinder( image, startX, startY, width, height, moduleSize, resultPointCallback)
+{
+ this.image = image;
+ this.possibleCenters = new Array();
+ this.startX = startX;
+ this.startY = startY;
+ this.width = width;
+ this.height = height;
+ this.moduleSize = moduleSize;
+ this.crossCheckStateCount = new Array(0,0,0);
+ this.resultPointCallback = resultPointCallback;
+
+ this.centerFromEnd=function(stateCount, end)
+ {
+ return (end - stateCount[2]) - stateCount[1] / 2.0;
+ }
+ this.foundPatternCross = function(stateCount)
+ {
+ var moduleSize = this.moduleSize;
+ var maxVariance = moduleSize / 2.0;
+ for (var i = 0; i < 3; i++)
+ {
+ if (Math.abs(moduleSize - stateCount[i]) >= maxVariance)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ this.crossCheckVertical=function( startI, centerJ, maxCount, originalStateCountTotal)
+ {
+ var image = this.image;
+
+ var maxI = qrcode.height;
+ var stateCount = this.crossCheckStateCount;
+ stateCount[0] = 0;
+ stateCount[1] = 0;
+ stateCount[2] = 0;
+
+ // Start counting up from center
+ var i = startI;
+ while (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)
+ {
+ stateCount[1]++;
+ i--;
+ }
+ // If already too many modules in this state or ran off the edge:
+ if (i < 0 || stateCount[1] > maxCount)
+ {
+ return NaN;
+ }
+ while (i >= 0 && !image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount)
+ {
+ stateCount[0]++;
+ i--;
+ }
+ if (stateCount[0] > maxCount)
+ {
+ return NaN;
+ }
+
+ // Now also count down from center
+ i = startI + 1;
+ while (i < maxI && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)
+ {
+ stateCount[1]++;
+ i++;
+ }
+ if (i == maxI || stateCount[1] > maxCount)
+ {
+ return NaN;
+ }
+ while (i < maxI && !image[centerJ + i*qrcode.width] && stateCount[2] <= maxCount)
+ {
+ stateCount[2]++;
+ i++;
+ }
+ if (stateCount[2] > maxCount)
+ {
+ return NaN;
+ }
+
+ var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
+ if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal)
+ {
+ return NaN;
+ }
+
+ return this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, i):NaN;
+ }
+
+ this.handlePossibleCenter=function( stateCount, i, j)
+ {
+ var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
+ var centerJ = this.centerFromEnd(stateCount, j);
+ var centerI = this.crossCheckVertical(i, Math.floor (centerJ), 2 * stateCount[1], stateCountTotal);
+ if (!isNaN(centerI))
+ {
+ var estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0;
+ var max = this.possibleCenters.length;
+ for (var index = 0; index < max; index++)
+ {
+ var center = this.possibleCenters[index];
+ // Look for about the same center and module size:
+ if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
+ {
+ return new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
+ }
+ }
+ // Hadn't found this before; save it
+ var point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
+ this.possibleCenters.push(point);
+ if (this.resultPointCallback != null)
+ {
+ this.resultPointCallback.foundPossibleResultPoint(point);
+ }
+ }
+ return null;
+ }
+
+ this.find = function()
+ {
+ var startX = this.startX;
+ var height = this.height;
+ var maxJ = startX + width;
+ var middleI = startY + (height >> 1);
+ // We are looking for black/white/black modules in 1:1:1 ratio;
+ // this tracks the number of black/white/black modules seen so far
+ var stateCount = new Array(0,0,0);
+ for (var iGen = 0; iGen < height; iGen++)
+ {
+ // Search from middle outwards
+ var i = middleI + ((iGen & 0x01) == 0?((iGen + 1) >> 1):- ((iGen + 1) >> 1));
+ stateCount[0] = 0;
+ stateCount[1] = 0;
+ stateCount[2] = 0;
+ var j = startX;
+ // Burn off leading white pixels before anything else; if we start in the middle of
+ // a white run, it doesn't make sense to count its length, since we don't know if the
+ // white run continued to the left of the start point
+ while (j < maxJ && !image[j + qrcode.width* i])
+ {
+ j++;
+ }
+ var currentState = 0;
+ while (j < maxJ)
+ {
+ if (image[j + i*qrcode.width])
+ {
+ // Black pixel
+ if (currentState == 1)
+ {
+ // Counting black pixels
+ stateCount[currentState]++;
+ }
+ else
+ {
+ // Counting white pixels
+ if (currentState == 2)
+ {
+ // A winner?
+ if (this.foundPatternCross(stateCount))
+ {
+ // Yes
+ var confirmed = this.handlePossibleCenter(stateCount, i, j);
+ if (confirmed != null)
+ {
+ return confirmed;
+ }
+ }
+ stateCount[0] = stateCount[2];
+ stateCount[1] = 1;
+ stateCount[2] = 0;
+ currentState = 1;
+ }
+ else
+ {
+ stateCount[++currentState]++;
+ }
+ }
+ }
+ else
+ {
+ // White pixel
+ if (currentState == 1)
+ {
+ // Counting black pixels
+ currentState++;
+ }
+ stateCount[currentState]++;
+ }
+ j++;
+ }
+ if (this.foundPatternCross(stateCount))
+ {
+ var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
+ if (confirmed != null)
+ {
+ return confirmed;
+ }
+ }
+ }
+
+ // Hmm, nothing we saw was observed and confirmed twice. If we had
+ // any guess at all, return it.
+ if (!(this.possibleCenters.length == 0))
+ {
+ return this.possibleCenters[0];
+ }
+
+ throw "Couldn't find enough alignment patterns";
+ }
+
+}
\ No newline at end of file
diff --git a/js/jsqrcode/bitmat.js b/js/jsqrcode/bitmat.js
index 78aa997..5b00784 100644
--- a/js/jsqrcode/bitmat.js
+++ b/js/jsqrcode/bitmat.js
@@ -1,119 +1,111 @@
-/*
- Ported to JavaScript by Lazar Laszlo 2011
-
- lazarsoft@gmail.com, www.lazarsoft.info
-
-*/
-
-/*
-*
-* Copyright 2007 ZXing authors
-*
-* 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.
-*/
-
-
-function BitMatrix( width, height)
-{
- if(!height)
- height=width;
- if (width < 1 || height < 1)
- {
- throw "Both dimensions must be greater than 0";
- }
- this.width = width;
- this.height = height;
- var rowSize = width >> 5;
- if ((width & 0x1f) != 0) {
- rowSize++;
- }
-
- this.rowSize = rowSize;
- this.bits = new Array(rowSize * height);
-
- for(var i=0;i> 5);
- return ((URShift(this.bits[offset], (x & 0x1f))) & 1) != 0;
- }
- this.set_Renamed=function( x, y)
- {
- var offset = y * this.rowSize + (x >> 5);
- this.bits[offset] |= 1 << (x & 0x1f);
- }
- this.flip=function( x, y)
- {
- var offset = y * this.rowSize + (x >> 5);
- this.bits[offset] ^= 1 << (x & 0x1f);
- }
- this.clear=function()
- {
- var max = this.bits.length;
- for (var i = 0; i < max; i++)
- {
- this.bits[i] = 0;
- }
- }
- this.setRegion=function( left, top, width, height)
- {
- if (top < 0 || left < 0)
- {
- throw "Left and top must be nonnegative";
- }
- if (height < 1 || width < 1)
- {
- throw "Height and width must be at least 1";
- }
- var right = left + width;
- var bottom = top + height;
- if (bottom > this.height || right > this.width)
- {
- throw "The region must fit inside the matrix";
- }
- for (var y = top; y < bottom; y++)
- {
- var offset = y * this.rowSize;
- for (var x = left; x < right; x++)
- {
- this.bits[offset + (x >> 5)] |= 1 << (x & 0x1f);
- }
- }
- }
-}
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* 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.
+*/
+
+
+function BitMatrix( width, height)
+{
+ if(!height)
+ height=width;
+ if (width < 1 || height < 1)
+ {
+ throw "Both dimensions must be greater than 0";
+ }
+ this.width = width;
+ this.height = height;
+ var rowSize = width >> 5;
+ if ((width & 0x1f) != 0)
+ {
+ rowSize++;
+ }
+ this.rowSize = rowSize;
+ this.bits = new Array(rowSize * height);
+ for(var i=0;i> 5);
+ return ((URShift(this.bits[offset], (x & 0x1f))) & 1) != 0;
+ }
+ this.set_Renamed=function( x, y)
+ {
+ var offset = y * this.rowSize + (x >> 5);
+ this.bits[offset] |= 1 << (x & 0x1f);
+ }
+ this.flip=function( x, y)
+ {
+ var offset = y * this.rowSize + (x >> 5);
+ this.bits[offset] ^= 1 << (x & 0x1f);
+ }
+ this.clear=function()
+ {
+ var max = this.bits.length;
+ for (var i = 0; i < max; i++)
+ {
+ this.bits[i] = 0;
+ }
+ }
+ this.setRegion=function( left, top, width, height)
+ {
+ if (top < 0 || left < 0)
+ {
+ throw "Left and top must be nonnegative";
+ }
+ if (height < 1 || width < 1)
+ {
+ throw "Height and width must be at least 1";
+ }
+ var right = left + width;
+ var bottom = top + height;
+ if (bottom > this.height || right > this.width)
+ {
+ throw "The region must fit inside the matrix";
+ }
+ for (var y = top; y < bottom; y++)
+ {
+ var offset = y * this.rowSize;
+ for (var x = left; x < right; x++)
+ {
+ this.bits[offset + (x >> 5)] |= 1 << (x & 0x1f);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/js/jsqrcode/datablock.js b/js/jsqrcode/datablock.js
index 31024cb..3cb277a 100644
--- a/js/jsqrcode/datablock.js
+++ b/js/jsqrcode/datablock.js
@@ -1,122 +1,117 @@
-/*
- Ported to JavaScript by Lazar Laszlo 2011
-
- lazarsoft@gmail.com, www.lazarsoft.info
-
-*/
-
-/*
-*
-* Copyright 2007 ZXing authors
-*
-* 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.
-*/
-
-
-function DataBlock(numDataCodewords, codewords)
-{
- this.numDataCodewords = numDataCodewords;
- this.codewords = codewords;
-
- Object.defineProperties(this, {
- 'NumDataCodewords': {
- get: function () {
- return this.numDataCodewords;
- }
- },
-
- 'Codewords': {
- get: function () {
- return this.codewords;
- }
- }
- });
-}
-
-DataBlock.getDataBlocks=function(rawCodewords, version, ecLevel)
-{
-
- if (rawCodewords.length != version.TotalCodewords)
- {
- throw "ArgumentException";
- }
-
- // Figure out the number and size of data blocks used by this version and
- // error correction level
- var ecBlocks = version.getECBlocksForLevel(ecLevel);
-
- // First count the total number of data blocks
- var totalBlocks = 0;
- var ecBlockArray = ecBlocks.getECBlocks();
- for (var i = 0; i < ecBlockArray.length; i++)
- {
- totalBlocks += ecBlockArray[i].Count;
- }
-
- // Now establish DataBlocks of the appropriate size and number of data codewords
- var result = new Array(totalBlocks);
- var numResultBlocks = 0;
- for (var j = 0; j < ecBlockArray.length; j++)
- {
- var ecBlock = ecBlockArray[j];
- for (var i = 0; i < ecBlock.Count; i++)
- {
- var numDataCodewords = ecBlock.DataCodewords;
- var numBlockCodewords = ecBlocks.ECCodewordsPerBlock + numDataCodewords;
- result[numResultBlocks++] = new DataBlock(numDataCodewords, new Array(numBlockCodewords));
- }
- }
-
- // All blocks have the same amount of data, except that the last n
- // (where n may be 0) have 1 more byte. Figure out where these start.
- var shorterBlocksTotalCodewords = result[0].codewords.length;
- var longerBlocksStartAt = result.length - 1;
- while (longerBlocksStartAt >= 0)
- {
- var numCodewords = result[longerBlocksStartAt].codewords.length;
- if (numCodewords == shorterBlocksTotalCodewords)
- {
- break;
- }
- longerBlocksStartAt--;
- }
- longerBlocksStartAt++;
-
- var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ECCodewordsPerBlock;
- // The last elements of result may be 1 element longer;
- // first fill out as many elements as all of them have
- var rawCodewordsOffset = 0;
- for (var i = 0; i < shorterBlocksNumDataCodewords; i++)
- {
- for (var j = 0; j < numResultBlocks; j++)
- {
- result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
- }
- }
- // Fill out the last data block in the longer ones
- for (var j = longerBlocksStartAt; j < numResultBlocks; j++)
- {
- result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];
- }
- // Now add in error correction blocks
- var max = result[0].codewords.length;
- for (var i = shorterBlocksNumDataCodewords; i < max; i++)
- {
- for (var j = 0; j < numResultBlocks; j++)
- {
- var iOffset = j < longerBlocksStartAt?i:i + 1;
- result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
- }
- }
- return result;
-}
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* 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.
+*/
+
+
+function DataBlock(numDataCodewords, codewords)
+{
+ this.numDataCodewords = numDataCodewords;
+ this.codewords = codewords;
+
+ this.__defineGetter__("NumDataCodewords", function()
+ {
+ return this.numDataCodewords;
+ });
+ this.__defineGetter__("Codewords", function()
+ {
+ return this.codewords;
+ });
+}
+
+DataBlock.getDataBlocks=function(rawCodewords, version, ecLevel)
+{
+
+ if (rawCodewords.length != version.TotalCodewords)
+ {
+ throw "ArgumentException";
+ }
+
+ // Figure out the number and size of data blocks used by this version and
+ // error correction level
+ var ecBlocks = version.getECBlocksForLevel(ecLevel);
+
+ // First count the total number of data blocks
+ var totalBlocks = 0;
+ var ecBlockArray = ecBlocks.getECBlocks();
+ for (var i = 0; i < ecBlockArray.length; i++)
+ {
+ totalBlocks += ecBlockArray[i].Count;
+ }
+
+ // Now establish DataBlocks of the appropriate size and number of data codewords
+ var result = new Array(totalBlocks);
+ var numResultBlocks = 0;
+ for (var j = 0; j < ecBlockArray.length; j++)
+ {
+ var ecBlock = ecBlockArray[j];
+ for (var i = 0; i < ecBlock.Count; i++)
+ {
+ var numDataCodewords = ecBlock.DataCodewords;
+ var numBlockCodewords = ecBlocks.ECCodewordsPerBlock + numDataCodewords;
+ result[numResultBlocks++] = new DataBlock(numDataCodewords, new Array(numBlockCodewords));
+ }
+ }
+
+ // All blocks have the same amount of data, except that the last n
+ // (where n may be 0) have 1 more byte. Figure out where these start.
+ var shorterBlocksTotalCodewords = result[0].codewords.length;
+ var longerBlocksStartAt = result.length - 1;
+ while (longerBlocksStartAt >= 0)
+ {
+ var numCodewords = result[longerBlocksStartAt].codewords.length;
+ if (numCodewords == shorterBlocksTotalCodewords)
+ {
+ break;
+ }
+ longerBlocksStartAt--;
+ }
+ longerBlocksStartAt++;
+
+ var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ECCodewordsPerBlock;
+ // The last elements of result may be 1 element longer;
+ // first fill out as many elements as all of them have
+ var rawCodewordsOffset = 0;
+ for (var i = 0; i < shorterBlocksNumDataCodewords; i++)
+ {
+ for (var j = 0; j < numResultBlocks; j++)
+ {
+ result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
+ }
+ }
+ // Fill out the last data block in the longer ones
+ for (var j = longerBlocksStartAt; j < numResultBlocks; j++)
+ {
+ result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];
+ }
+ // Now add in error correction blocks
+ var max = result[0].codewords.length;
+ for (var i = shorterBlocksNumDataCodewords; i < max; i++)
+ {
+ for (var j = 0; j < numResultBlocks; j++)
+ {
+ var iOffset = j < longerBlocksStartAt?i:i + 1;
+ result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
+ }
+ }
+ return result;
+}
diff --git a/js/jsqrcode/databr.js b/js/jsqrcode/databr.js
index cf71752..855a849 100644
--- a/js/jsqrcode/databr.js
+++ b/js/jsqrcode/databr.js
@@ -1,284 +1,337 @@
-/*
- Ported to JavaScript by Lazar Laszlo 2011
-
- lazarsoft@gmail.com, www.lazarsoft.info
-
-*/
-
-/*
-*
-* Copyright 2007 ZXing authors
-*
-* 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.
-*/
-
-
-function QRCodeDataBlockReader (blocks, version, numErrorCorrectionCode) {
- this.blockPointer = 0;
- this.bitPointer = 7;
- this.dataLength = 0;
- this.blocks = blocks;
- this.numErrorCorrectionCode = numErrorCorrectionCode;
- if (version <= 9)
- this.dataLengthMode = 0;
- else if (version >= 10 && version <= 26)
- this.dataLengthMode = 1;
- else if (version >= 27 && version <= 40)
- this.dataLengthMode = 2;
-
- this.getNextBits = function (numBits) {
- var bits = 0;
-
- if (numBits < this.bitPointer + 1) {
- // next word fits into current data block
- var mask = 0;
- for (var i = 0; i < numBits; i++) {
- mask += (1 << i);
- }
- mask <<= (this.bitPointer - numBits + 1);
-
- bits = (this.blocks[this.blockPointer] & mask) >> (this.bitPointer - numBits + 1);
- this.bitPointer -= numBits;
- return bits;
- } else if (numBits < this.bitPointer + 1 + 8) {
- // next word crosses 2 data blocks
- var mask1 = 0;
- for (var i = 0; i < this.bitPointer + 1; i++)
- {
- mask1 += (1 << i);
- }
- bits = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));
- this.blockPointer++;
- bits += ((this.blocks[this.blockPointer]) >> (8 - (numBits - (this.bitPointer + 1))));
-
- this.bitPointer = this.bitPointer - numBits % 8;
- if (this.bitPointer < 0)
- {
- this.bitPointer = 8 + this.bitPointer;
- }
- return bits;
- } else if (numBits < this.bitPointer + 1 + 16) {
- // next word crosses 3 data blocks
- var mask1 = 0; // mask of first block
- var mask3 = 0; // mask of 3rd block
- //bitPointer + 1 : number of bits of the 1st block
- //8 : number of the 2nd block (note that use already 8bits because next word uses 3 data blocks)
- //numBits - (bitPointer + 1 + 8) : number of bits of the 3rd block
- for (var i = 0; i < this.bitPointer + 1; i++)
- {
- mask1 += (1 << i);
- }
- var bitsFirstBlock = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));
- this.blockPointer++;
-
- var bitsSecondBlock = this.blocks[this.blockPointer] << (numBits - (this.bitPointer + 1 + 8));
- this.blockPointer++;
-
- for (var i = 0; i < numBits - (this.bitPointer + 1 + 8); i++) {
- mask3 += (1 << i);
- }
-
- mask3 <<= 8 - (numBits - (this.bitPointer + 1 + 8));
- var bitsThirdBlock = (this.blocks[this.blockPointer] & mask3) >> (8 - (numBits - (this.bitPointer + 1 + 8)));
-
- bits = bitsFirstBlock + bitsSecondBlock + bitsThirdBlock;
- this.bitPointer = this.bitPointer - (numBits - 8) % 8;
- if (this.bitPointer < 0) {
- this.bitPointer = 8 + this.bitPointer;
- }
-
- return bits;
- } else {
- return 0;
- }
- };
-
- this.NextMode = function () {
- if ((this.blockPointer > this.blocks.length - this.numErrorCorrectionCode - 2))
- return 0;
- else
- return this.getNextBits(4);
- };
-
- this.getDataLength=function( modeIndicator) {
- var index = 0;
- while (true)
- {
- if ((modeIndicator >> index) == 1)
- break;
- index++;
- }
-
- return this.getNextBits(qrcode.sizeOfDataLengthInfo[this.dataLengthMode][index]);
- };
-
- this.getRomanAndFigureString = function (dataLength) {
- var length = dataLength;
- var intData = 0;
- var strData = "";
- var tableRomanAndFigure = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', '+', '-', '.', '/', ':');
-
- do {
- if (length > 1) {
- intData = this.getNextBits(11);
- var firstLetter = Math.floor(intData / 45);
- var secondLetter = intData % 45;
- strData += tableRomanAndFigure[firstLetter];
- strData += tableRomanAndFigure[secondLetter];
- length -= 2;
- } else if (length == 1) {
- intData = this.getNextBits(6);
- strData += tableRomanAndFigure[intData];
- length -= 1;
- }
- } while (length > 0);
-
- return strData;
- };
-
- this.getFigureString=function( dataLength) {
- var length = dataLength;
- var intData = 0;
- var strData = "";
- do
- {
- if (length >= 3)
- {
- intData = this.getNextBits(10);
- if (intData < 100)
- strData += "0";
- if (intData < 10)
- strData += "0";
- length -= 3;
- }
- else if (length == 2)
- {
- intData = this.getNextBits(7);
- if (intData < 10)
- strData += "0";
- length -= 2;
- }
- else if (length == 1)
- {
- intData = this.getNextBits(4);
- length -= 1;
- }
- strData += intData;
- }
- while (length > 0);
-
- return strData;
- };
-
- this.get8bitByteArray=function( dataLength) {
- var length = dataLength;
- var intData = 0;
- var output = new Array();
-
- do {
- intData = this.getNextBits(8);
- output.push( intData);
- length--;
- } while (length > 0);
-
- return output;
- };
-
- this.getKanjiString = function (dataLength) {
- var length = dataLength;
- var intData = 0;
- var unicodeString = "";
- do {
- intData = getNextBits(13);
- var lowerByte = intData % 0xC0;
- var higherByte = intData / 0xC0;
-
- var tempWord = (higherByte << 8) + lowerByte;
- var shiftjisWord = 0;
- if (tempWord + 0x8140 <= 0x9FFC) {
- // between 8140 - 9FFC on Shift_JIS character set
- shiftjisWord = tempWord + 0x8140;
- } else {
- // between E040 - EBBF on Shift_JIS character set
- shiftjisWord = tempWord + 0xC140;
- }
-
- unicodeString += String.fromCharCode(shiftjisWord);
- length--;
- } while (length > 0);
-
- return unicodeString;
- };
-
- Object.defineProperty(this, 'DataByte', {
- get: function () {
- var output = new Array();
- var MODE_NUMBER = 1;
- var MODE_ROMAN_AND_NUMBER = 2;
- var MODE_8BIT_BYTE = 4;
- var MODE_KANJI = 8;
- do {
- var mode = this.NextMode();
- if (mode == 0) {
- if (output.length > 0)
- break;
- else
- throw "Empty data block";
- }
-
- if (mode != MODE_NUMBER &&
- mode != MODE_ROMAN_AND_NUMBER &&
- mode != MODE_8BIT_BYTE &&
- mode != MODE_KANJI) {
-
- mode = guessMode(mode);
- throw "Invalid mode: " + mode + " in (block:" + this.blockPointer + " bit:" + this.bitPointer + ")";
- }
-
- dataLength = this.getDataLength(mode);
-
- if (dataLength < 1)
- throw "Invalid data length: " + dataLength;
- switch (mode) {
- case MODE_NUMBER:
- var temp_str = this.getFigureString(dataLength);
- var ta = new Array(temp_str.length);
- for(var j=0;j= 10 && version <= 26)
+ this.dataLengthMode = 1;
+ else if (version >= 27 && version <= 40)
+ this.dataLengthMode = 2;
+
+ this.getNextBits = function( numBits)
+ {
+ var bits = 0;
+ if (numBits < this.bitPointer + 1)
+ {
+ // next word fits into current data block
+ var mask = 0;
+ for (var i = 0; i < numBits; i++)
+ {
+ mask += (1 << i);
+ }
+ mask <<= (this.bitPointer - numBits + 1);
+
+ bits = (this.blocks[this.blockPointer] & mask) >> (this.bitPointer - numBits + 1);
+ this.bitPointer -= numBits;
+ return bits;
+ }
+ else if (numBits < this.bitPointer + 1 + 8)
+ {
+ // next word crosses 2 data blocks
+ var mask1 = 0;
+ for (var i = 0; i < this.bitPointer + 1; i++)
+ {
+ mask1 += (1 << i);
+ }
+ bits = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));
+ this.blockPointer++;
+ bits += ((this.blocks[this.blockPointer]) >> (8 - (numBits - (this.bitPointer + 1))));
+
+ this.bitPointer = this.bitPointer - numBits % 8;
+ if (this.bitPointer < 0)
+ {
+ this.bitPointer = 8 + this.bitPointer;
+ }
+ return bits;
+ }
+ else if (numBits < this.bitPointer + 1 + 16)
+ {
+ // next word crosses 3 data blocks
+ var mask1 = 0; // mask of first block
+ var mask3 = 0; // mask of 3rd block
+ //bitPointer + 1 : number of bits of the 1st block
+ //8 : number of the 2nd block (note that use already 8bits because next word uses 3 data blocks)
+ //numBits - (bitPointer + 1 + 8) : number of bits of the 3rd block
+ for (var i = 0; i < this.bitPointer + 1; i++)
+ {
+ mask1 += (1 << i);
+ }
+ var bitsFirstBlock = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));
+ this.blockPointer++;
+
+ var bitsSecondBlock = this.blocks[this.blockPointer] << (numBits - (this.bitPointer + 1 + 8));
+ this.blockPointer++;
+
+ for (var i = 0; i < numBits - (this.bitPointer + 1 + 8); i++)
+ {
+ mask3 += (1 << i);
+ }
+ mask3 <<= 8 - (numBits - (this.bitPointer + 1 + 8));
+ var bitsThirdBlock = (this.blocks[this.blockPointer] & mask3) >> (8 - (numBits - (this.bitPointer + 1 + 8)));
+
+ bits = bitsFirstBlock + bitsSecondBlock + bitsThirdBlock;
+ this.bitPointer = this.bitPointer - (numBits - 8) % 8;
+ if (this.bitPointer < 0)
+ {
+ this.bitPointer = 8 + this.bitPointer;
+ }
+ return bits;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ this.NextMode=function()
+ {
+ if ((this.blockPointer > this.blocks.length - this.numErrorCorrectionCode - 2))
+ return 0;
+ else
+ return this.getNextBits(4);
+ }
+ this.getDataLength=function( modeIndicator)
+ {
+ var index = 0;
+ while (true)
+ {
+ if ((modeIndicator >> index) == 1)
+ break;
+ index++;
+ }
+
+ return this.getNextBits(qrcode.sizeOfDataLengthInfo[this.dataLengthMode][index]);
+ }
+ this.getRomanAndFigureString=function( dataLength)
+ {
+ var length = dataLength;
+ var intData = 0;
+ var strData = "";
+ var tableRomanAndFigure = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', '+', '-', '.', '/', ':');
+ do
+ {
+ if (length > 1)
+ {
+ intData = this.getNextBits(11);
+ var firstLetter = Math.floor(intData / 45);
+ var secondLetter = intData % 45;
+ strData += tableRomanAndFigure[firstLetter];
+ strData += tableRomanAndFigure[secondLetter];
+ length -= 2;
+ }
+ else if (length == 1)
+ {
+ intData = this.getNextBits(6);
+ strData += tableRomanAndFigure[intData];
+ length -= 1;
+ }
+ }
+ while (length > 0);
+
+ return strData;
+ }
+ this.getFigureString=function( dataLength)
+ {
+ var length = dataLength;
+ var intData = 0;
+ var strData = "";
+ do
+ {
+ if (length >= 3)
+ {
+ intData = this.getNextBits(10);
+ if (intData < 100)
+ strData += "0";
+ if (intData < 10)
+ strData += "0";
+ length -= 3;
+ }
+ else if (length == 2)
+ {
+ intData = this.getNextBits(7);
+ if (intData < 10)
+ strData += "0";
+ length -= 2;
+ }
+ else if (length == 1)
+ {
+ intData = this.getNextBits(4);
+ length -= 1;
+ }
+ strData += intData;
+ }
+ while (length > 0);
+
+ return strData;
+ }
+ this.get8bitByteArray=function( dataLength)
+ {
+ var length = dataLength;
+ var intData = 0;
+ var output = new Array();
+
+ do
+ {
+ intData = this.getNextBits(8);
+ output.push( intData);
+ length--;
+ }
+ while (length > 0);
+ return output;
+ }
+ this.getKanjiString=function( dataLength)
+ {
+ var length = dataLength;
+ var intData = 0;
+ var unicodeString = "";
+ do
+ {
+ intData = this.getNextBits(13);
+ var lowerByte = intData % 0xC0;
+ var higherByte = intData / 0xC0;
+
+ var tempWord = (higherByte << 8) + lowerByte;
+ var shiftjisWord = 0;
+ if (tempWord + 0x8140 <= 0x9FFC)
+ {
+ // between 8140 - 9FFC on Shift_JIS character set
+ shiftjisWord = tempWord + 0x8140;
+ }
+ else
+ {
+ // between E040 - EBBF on Shift_JIS character set
+ shiftjisWord = tempWord + 0xC140;
+ }
+
+ //var tempByte = new Array(0,0);
+ //tempByte[0] = (sbyte) (shiftjisWord >> 8);
+ //tempByte[1] = (sbyte) (shiftjisWord & 0xFF);
+ //unicodeString += new String(SystemUtils.ToCharArray(SystemUtils.ToByteArray(tempByte)));
+ unicodeString += String.fromCharCode(shiftjisWord);
+ length--;
+ }
+ while (length > 0);
+
+
+ return unicodeString;
+ }
+
+ this.parseECIValue = function ()
+ {
+ var intData = 0;
+ var firstByte = this.getNextBits(8);
+ if ((firstByte & 0x80) == 0) {
+ intData = firstByte & 0x7F;
+ }
+ if ((firstByte & 0xC0) == 0x80) {
+ // two bytes
+ var secondByte = this.getNextBits(8);
+ intData = ((firstByte & 0x3F) << 8) | secondByte;
+ }
+ if ((firstByte & 0xE0) == 0xC0) {
+ // three bytes
+ var secondThirdBytes = this.getNextBits(8);;
+ intData = ((firstByte & 0x1F) << 16) | secondThirdBytes;
+ }
+ return intData;
+ }
+
+ this.__defineGetter__("DataByte", function()
+ {
+ var output = new Array();
+ var MODE_NUMBER = 1;
+ var MODE_ROMAN_AND_NUMBER = 2;
+ var MODE_8BIT_BYTE = 4;
+ var MODE_ECI = 7;
+ var MODE_KANJI = 8;
+ do
+ {
+ var mode = this.NextMode();
+ console.log(mode);
+ //canvas.println("mode: " + mode);
+ if (mode == 0)
+ {
+ if (output.length > 0)
+ break;
+ else
+ throw "Empty data block";
+ }
+ if (mode != MODE_NUMBER && mode != MODE_ROMAN_AND_NUMBER && mode != MODE_8BIT_BYTE && mode != MODE_KANJI && mode != MODE_ECI)
+ {
+ throw "Invalid mode: " + mode + " in (block:" + this.blockPointer + " bit:" + this.bitPointer + ")";
+ }
+
+ if(mode == MODE_ECI)
+ {
+ var temp_sbyteArray3 = this.parseECIValue();
+ //output.push(temp_sbyteArray3);
+ }
+ else
+ {
+
+ var dataLength = this.getDataLength(mode);
+ if (dataLength < 1)
+ throw "Invalid data length: " + dataLength;
+ switch (mode)
+ {
+
+ case MODE_NUMBER:
+ var temp_str = this.getFigureString(dataLength);
+ var ta = new Array(temp_str.length);
+ for(var j=0;j= FOR_BITS.length) {
- throw "ArgumentException";
- }
-
- return FOR_BITS[bits];
-}
-
-var L = new ErrorCorrectionLevel(0, 0x01, "L");
-var M = new ErrorCorrectionLevel(1, 0x00, "M");
-var Q = new ErrorCorrectionLevel(2, 0x03, "Q");
-var H = new ErrorCorrectionLevel(3, 0x02, "H");
-var FOR_BITS = new Array( M, L, H, Q);
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* 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.
+*/
+
+
+function ErrorCorrectionLevel(ordinal, bits, name)
+{
+ this.ordinal_Renamed_Field = ordinal;
+ this.bits = bits;
+ this.name = name;
+ this.__defineGetter__("Bits", function()
+ {
+ return this.bits;
+ });
+ this.__defineGetter__("Name", function()
+ {
+ return this.name;
+ });
+ this.ordinal=function()
+ {
+ return this.ordinal_Renamed_Field;
+ }
+}
+
+ErrorCorrectionLevel.forBits=function( bits)
+{
+ if (bits < 0 || bits >= FOR_BITS.length)
+ {
+ throw "ArgumentException";
+ }
+ return FOR_BITS[bits];
+}
+
+var L = new ErrorCorrectionLevel(0, 0x01, "L");
+var M = new ErrorCorrectionLevel(1, 0x00, "M");
+var Q = new ErrorCorrectionLevel(2, 0x03, "Q");
+var H = new ErrorCorrectionLevel(3, 0x02, "H");
+var FOR_BITS = new Array( M, L, H, Q);
\ No newline at end of file
diff --git a/js/jsqrcode/findpat.js b/js/jsqrcode/findpat.js
index c582bf5..7f6ba89 100644
--- a/js/jsqrcode/findpat.js
+++ b/js/jsqrcode/findpat.js
@@ -1,653 +1,651 @@
-/*
- Ported to JavaScript by Lazar Laszlo 2011
-
- lazarsoft@gmail.com, www.lazarsoft.info
-
-*/
-
-/*
-*
-* Copyright 2007 ZXing authors
-*
-* 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.
-*/
-
-
-var MIN_SKIP = 3;
-var MAX_MODULES = 57;
-var INTEGER_MATH_SHIFT = 8;
-var CENTER_QUORUM = 2;
-
-qrcode.orderBestPatterns = function (patterns) {
- function distance( pattern1, pattern2) {
- xDiff = pattern1.X - pattern2.X;
- yDiff = pattern1.Y - pattern2.Y;
- return Math.sqrt( (xDiff * xDiff + yDiff * yDiff));
- }
-
- /// Returns the z component of the cross product between vectors BC and BA.
- function crossProductZ( pointA, pointB, pointC) {
- var bX = pointB.x;
- var bY = pointB.y;
- return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));
- }
-
- // Find distances between pattern centers
- var zeroOneDistance = distance(patterns[0], patterns[1]);
- var oneTwoDistance = distance(patterns[1], patterns[2]);
- var zeroTwoDistance = distance(patterns[0], patterns[2]);
-
- var pointA, pointB, pointC;
- // Assume one closest to other two is B; A and C will just be guesses at first
- if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
- pointB = patterns[0];
- pointA = patterns[1];
- pointC = patterns[2];
- } else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) {
- pointB = patterns[1];
- pointA = patterns[0];
- pointC = patterns[2];
- } else {
- pointB = patterns[2];
- pointA = patterns[0];
- pointC = patterns[1];
- }
-
- // Use cross product to figure out whether A and C are correct or flipped.
- // This asks whether BC x BA has a positive z component, which is the arrangement
- // we want for A, B, C. If it's negative, then we've got it flipped around and
- // should swap A and C.
- if (crossProductZ(pointA, pointB, pointC) < 0.0) {
- var temp = pointA;
-
- pointA = pointC;
- pointC = temp;
- }
-
- patterns[0] = pointA;
- patterns[1] = pointB;
- patterns[2] = pointC;
-};
-
-function FinderPattern (posX, posY, estimatedModuleSize) {
- this.x=posX;
- this.y=posY;
- this.count = 1;
- this.estimatedModuleSize = estimatedModuleSize;
-
- Object.defineProperties(this, {
- "EstimatedModuleSize": {
- get: function () {
- return this.estimatedModuleSize;
- }
- },
-
- "Count": {
- get: function () {
- return this.count;
- }
- },
-
- "X": {
- get: function () {
- return this.x;
- }
- },
-
- "Y": {
- get: function () {
- return this.y;
- }
- }
- });
-
- this.incrementCount = function() {
- this.count++;
- };
-
- this.aboutEquals = function (moduleSize, i, j) {
- if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize) {
- var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
-
- return moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;
- }
-
- return false;
- }
-};
-
-function FinderPatternInfo(patternCenters) {
- this.bottomLeft = patternCenters[0];
- this.topLeft = patternCenters[1];
- this.topRight = patternCenters[2];
-
- Object.defineProperties(this, {
- "BottomLeft": {
- get: function () {
- return this.bottomLeft;
- }
- },
- "TopLeft": {
- get: function () {
- return this.topLeft;
- }
- },
- "TopRight": {
- get: function () {
- return this.topRight;
- }
- }
- });
-}
-
-function FinderPatternFinder()
-{
- this.image=null;
- this.possibleCenters = [];
- this.hasSkipped = false;
- this.crossCheckStateCount = new Array(0,0,0,0,0);
- this.resultPointCallback = null;
-
- Object.defineProperty(this, 'CrossCheckStateCount', {
- get: function () {
- this.crossCheckStateCount[0] = 0;
- this.crossCheckStateCount[1] = 0;
- this.crossCheckStateCount[2] = 0;
- this.crossCheckStateCount[3] = 0;
- this.crossCheckStateCount[4] = 0;
-
- return this.crossCheckStateCount;
- }
- });
-
- this.foundPatternCross=function( stateCount)
- {
- var totalModuleSize = 0;
- for (var i = 0; i < 5; i++)
- {
- var count = stateCount[i];
- if (count == 0)
- {
- return false;
- }
- totalModuleSize += count;
- }
- if (totalModuleSize < 7)
- {
- return false;
- }
- var moduleSize = Math.floor((totalModuleSize << INTEGER_MATH_SHIFT) / 7);
- var maxVariance = Math.floor(moduleSize / 2);
- // Allow less than 50% variance from 1-1-3-1-1 proportions
- return Math.abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < 3 * maxVariance && Math.abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < maxVariance;
- }
- this.centerFromEnd=function( stateCount, end)
- {
- return (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0;
- }
- this.crossCheckVertical=function( startI, centerJ, maxCount, originalStateCountTotal)
- {
- var image = this.image;
-
- var maxI = qrcode.height;
- var stateCount = this.CrossCheckStateCount;
-
- // Start counting up from center
- var i = startI;
- while (i >= 0 && image[centerJ + i*qrcode.width])
- {
- stateCount[2]++;
- i--;
- }
- if (i < 0)
- {
- return NaN;
- }
- while (i >= 0 && !image[centerJ +i*qrcode.width] && stateCount[1] <= maxCount)
- {
- stateCount[1]++;
- i--;
- }
- // If already too many modules in this state or ran off the edge:
- if (i < 0 || stateCount[1] > maxCount)
- {
- return NaN;
- }
- while (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount)
- {
- stateCount[0]++;
- i--;
- }
- if (stateCount[0] > maxCount)
- {
- return NaN;
- }
-
- // Now also count down from center
- i = startI + 1;
- while (i < maxI && image[centerJ +i*qrcode.width])
- {
- stateCount[2]++;
- i++;
- }
- if (i == maxI)
- {
- return NaN;
- }
- while (i < maxI && !image[centerJ + i*qrcode.width] && stateCount[3] < maxCount)
- {
- stateCount[3]++;
- i++;
- }
- if (i == maxI || stateCount[3] >= maxCount)
- {
- return NaN;
- }
- while (i < maxI && image[centerJ + i*qrcode.width] && stateCount[4] < maxCount)
- {
- stateCount[4]++;
- i++;
- }
- if (stateCount[4] >= maxCount)
- {
- return NaN;
- }
-
- // If we found a finder-pattern-like section, but its size is more than 40% different than
- // the original, assume it's a false positive
- var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
- if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal)
- {
- return NaN;
- }
-
- return this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, i):NaN;
- }
- this.crossCheckHorizontal=function( startJ, centerI, maxCount, originalStateCountTotal)
- {
- var image = this.image;
-
- var maxJ = qrcode.width;
- var stateCount = this.CrossCheckStateCount;
-
- var j = startJ;
- while (j >= 0 && image[j+ centerI*qrcode.width])
- {
- stateCount[2]++;
- j--;
- }
- if (j < 0)
- {
- return NaN;
- }
- while (j >= 0 && !image[j+ centerI*qrcode.width] && stateCount[1] <= maxCount)
- {
- stateCount[1]++;
- j--;
- }
- if (j < 0 || stateCount[1] > maxCount)
- {
- return NaN;
- }
- while (j >= 0 && image[j+ centerI*qrcode.width] && stateCount[0] <= maxCount)
- {
- stateCount[0]++;
- j--;
- }
- if (stateCount[0] > maxCount)
- {
- return NaN;
- }
-
- j = startJ + 1;
- while (j < maxJ && image[j+ centerI*qrcode.width])
- {
- stateCount[2]++;
- j++;
- }
- if (j == maxJ)
- {
- return NaN;
- }
- while (j < maxJ && !image[j+ centerI*qrcode.width] && stateCount[3] < maxCount)
- {
- stateCount[3]++;
- j++;
- }
- if (j == maxJ || stateCount[3] >= maxCount)
- {
- return NaN;
- }
- while (j < maxJ && image[j+ centerI*qrcode.width] && stateCount[4] < maxCount)
- {
- stateCount[4]++;
- j++;
- }
- if (stateCount[4] >= maxCount)
- {
- return NaN;
- }
-
- // If we found a finder-pattern-like section, but its size is significantly different than
- // the original, assume it's a false positive
- var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
- if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal)
- {
- return NaN;
- }
-
- return this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, j):NaN;
- }
- this.handlePossibleCenter=function( stateCount, i, j)
- {
- var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
- var centerJ = this.centerFromEnd(stateCount, j); //float
- var centerI = this.crossCheckVertical(i, Math.floor( centerJ), stateCount[2], stateCountTotal); //float
- if (!isNaN(centerI))
- {
- // Re-cross check
- centerJ = this.crossCheckHorizontal(Math.floor( centerJ), Math.floor( centerI), stateCount[2], stateCountTotal);
- if (!isNaN(centerJ))
- {
- var estimatedModuleSize = stateCountTotal / 7.0;
- var found = false;
- var max = this.possibleCenters.length;
- for (var index = 0; index < max; index++)
- {
- var center = this.possibleCenters[index];
- // Look for about the same center and module size:
- if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
- {
- center.incrementCount();
- found = true;
- break;
- }
- }
- if (!found)
- {
- var point = new FinderPattern(centerJ, centerI, estimatedModuleSize);
- this.possibleCenters.push(point);
- if (this.resultPointCallback != null)
- {
- this.resultPointCallback.foundPossibleResultPoint(point);
- }
- }
- return true;
- }
- }
- return false;
- }
-
- this.selectBestPatterns=function()
- {
-
- var startSize = this.possibleCenters.length;
- if (startSize < 3)
- {
- // Couldn't find enough finder patterns
- throw "Couldn't find enough finder patterns";
- }
-
- // Filter outlier possibilities whose module size is too different
- if (startSize > 3)
- {
- // But we can only afford to do so if we have at least 4 possibilities to choose from
- var totalModuleSize = 0.0;
- var square = 0.0;
- for (var i = 0; i < startSize; i++)
- {
- //totalModuleSize += this.possibleCenters[i].EstimatedModuleSize;
- var centerValue=this.possibleCenters[i].EstimatedModuleSize;
- totalModuleSize += centerValue;
- square += (centerValue * centerValue);
- }
- var average = totalModuleSize / startSize;
- this.possibleCenters.sort(function(center1,center2) {
- var dA=Math.abs(center2.EstimatedModuleSize - average);
- var dB=Math.abs(center1.EstimatedModuleSize - average);
- if (dA < dB) {
- return (-1);
- } else if (dA == dB) {
- return 0;
- } else {
- return 1;
- }
- });
-
- var stdDev = Math.sqrt(square / startSize - average * average);
- var limit = Math.max(0.2 * average, stdDev);
- for (var i = 0; i < this.possibleCenters.length && this.possibleCenters.length > 3; i++)
- {
- var pattern = this.possibleCenters[i];
- //if (Math.abs(pattern.EstimatedModuleSize - average) > 0.2 * average)
- if (Math.abs(pattern.EstimatedModuleSize - average) > limit)
- {
- this.possibleCenters.remove(i);
- i--;
- }
- }
- }
-
- if (this.possibleCenters.length > 3)
- {
- // Throw away all but those first size candidate points we found.
- this.possibleCenters.sort(function(a, b){
- if (a.count > b.count){return -1;}
- if (a.count < b.count){return 1;}
- return 0;
- });
- }
-
- return new Array( this.possibleCenters[0], this.possibleCenters[1], this.possibleCenters[2]);
- }
-
- this.findRowSkip=function()
- {
- var max = this.possibleCenters.length;
- if (max <= 1)
- {
- return 0;
- }
- var firstConfirmedCenter = null;
- for (var i = 0; i < max; i++)
- {
- var center = this.possibleCenters[i];
- if (center.Count >= CENTER_QUORUM)
- {
- if (firstConfirmedCenter == null)
- {
- firstConfirmedCenter = center;
- }
- else
- {
- // We have two confirmed centers
- // How far down can we skip before resuming looking for the next
- // pattern? In the worst case, only the difference between the
- // difference in the x / y coordinates of the two centers.
- // This is the case where you find top left last.
- this.hasSkipped = true;
- return Math.floor ((Math.abs(firstConfirmedCenter.X - center.X) - Math.abs(firstConfirmedCenter.Y - center.Y)) / 2);
- }
- }
- }
- return 0;
- }
-
- this.haveMultiplyConfirmedCenters=function()
- {
- var confirmedCount = 0;
- var totalModuleSize = 0.0;
- var max = this.possibleCenters.length;
- for (var i = 0; i < max; i++)
- {
- var pattern = this.possibleCenters[i];
- if (pattern.Count >= CENTER_QUORUM)
- {
- confirmedCount++;
- totalModuleSize += pattern.EstimatedModuleSize;
- }
- }
- if (confirmedCount < 3)
- {
- return false;
- }
- // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive"
- // and that we need to keep looking. We detect this by asking if the estimated module sizes
- // vary too much. We arbitrarily say that when the total deviation from average exceeds
- // 5% of the total module size estimates, it's too much.
- var average = totalModuleSize / max;
- var totalDeviation = 0.0;
- for (var i = 0; i < max; i++)
- {
- pattern = this.possibleCenters[i];
- totalDeviation += Math.abs(pattern.EstimatedModuleSize - average);
- }
- return totalDeviation <= 0.05 * totalModuleSize;
- }
-
- this.findFinderPattern = function(image){
- var tryHarder = false;
- this.image=image;
- var maxI = qrcode.height;
- var maxJ = qrcode.width;
- var iSkip = Math.floor((3 * maxI) / (4 * MAX_MODULES));
- if (iSkip < MIN_SKIP || tryHarder)
- {
- iSkip = MIN_SKIP;
- }
-
- var done = false;
- var stateCount = new Array(5);
- for (var i = iSkip - 1; i < maxI && !done; i += iSkip)
- {
- // Get a row of black/white values
- stateCount[0] = 0;
- stateCount[1] = 0;
- stateCount[2] = 0;
- stateCount[3] = 0;
- stateCount[4] = 0;
- var currentState = 0;
- for (var j = 0; j < maxJ; j++)
- {
- if (image[j+i*qrcode.width] )
- {
- // Black pixel
- if ((currentState & 1) == 1)
- {
- // Counting white pixels
- currentState++;
- }
- stateCount[currentState]++;
- }
- else
- {
- // White pixel
- if ((currentState & 1) == 0)
- {
- // Counting black pixels
- if (currentState == 4)
- {
- // A winner?
- if (this.foundPatternCross(stateCount))
- {
- // Yes
- var confirmed = this.handlePossibleCenter(stateCount, i, j);
- if (confirmed)
- {
- // Start examining every other line. Checking each line turned out to be too
- // expensive and didn't improve performance.
- iSkip = 2;
- if (this.hasSkipped)
- {
- done = this.haveMultiplyConfirmedCenters();
- }
- else
- {
- var rowSkip = this.findRowSkip();
- if (rowSkip > stateCount[2])
- {
- // Skip rows between row of lower confirmed center
- // and top of presumed third confirmed center
- // but back up a bit to get a full chance of detecting
- // it, entire width of center of finder pattern
-
- // Skip by rowSkip, but back off by stateCount[2] (size of last center
- // of pattern we saw) to be conservative, and also back off by iSkip which
- // is about to be re-added
- i += rowSkip - stateCount[2] - iSkip;
- j = maxJ - 1;
- }
- }
- }
- else
- {
- // Advance to next black pixel
- do
- {
- j++;
- }
- while (j < maxJ && !image[j + i*qrcode.width]);
- j--; // back up to that last white pixel
- }
- // Clear state to start looking again
- currentState = 0;
- stateCount[0] = 0;
- stateCount[1] = 0;
- stateCount[2] = 0;
- stateCount[3] = 0;
- stateCount[4] = 0;
- }
- else
- {
- // No, shift counts back by two
- stateCount[0] = stateCount[2];
- stateCount[1] = stateCount[3];
- stateCount[2] = stateCount[4];
- stateCount[3] = 1;
- stateCount[4] = 0;
- currentState = 3;
- }
- }
- else
- {
- stateCount[++currentState]++;
- }
- }
- else
- {
- // Counting white pixels
- stateCount[currentState]++;
- }
- }
- }
- if (this.foundPatternCross(stateCount))
- {
- var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
- if (confirmed)
- {
- iSkip = stateCount[0];
- if (this.hasSkipped)
- {
- // Found a third one
- done = haveMultiplyConfirmedCenters();
- }
- }
- }
- }
-
- var patternInfo = this.selectBestPatterns();
- qrcode.orderBestPatterns(patternInfo);
-
- return new FinderPatternInfo(patternInfo);
- };
-}
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* 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.
+*/
+
+
+var MIN_SKIP = 3;
+var MAX_MODULES = 57;
+var INTEGER_MATH_SHIFT = 8;
+var CENTER_QUORUM = 2;
+
+qrcode.orderBestPatterns=function(patterns)
+ {
+
+ function distance( pattern1, pattern2)
+ {
+ var xDiff = pattern1.X - pattern2.X;
+ var yDiff = pattern1.Y - pattern2.Y;
+ return Math.sqrt( (xDiff * xDiff + yDiff * yDiff));
+ }
+
+ /// Returns the z component of the cross product between vectors BC and BA.
+ function crossProductZ( pointA, pointB, pointC)
+ {
+ var bX = pointB.x;
+ var bY = pointB.y;
+ return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));
+ }
+
+
+ // Find distances between pattern centers
+ var zeroOneDistance = distance(patterns[0], patterns[1]);
+ var oneTwoDistance = distance(patterns[1], patterns[2]);
+ var zeroTwoDistance = distance(patterns[0], patterns[2]);
+
+ var pointA, pointB, pointC;
+ // Assume one closest to other two is B; A and C will just be guesses at first
+ if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance)
+ {
+ pointB = patterns[0];
+ pointA = patterns[1];
+ pointC = patterns[2];
+ }
+ else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance)
+ {
+ pointB = patterns[1];
+ pointA = patterns[0];
+ pointC = patterns[2];
+ }
+ else
+ {
+ pointB = patterns[2];
+ pointA = patterns[0];
+ pointC = patterns[1];
+ }
+
+ // Use cross product to figure out whether A and C are correct or flipped.
+ // This asks whether BC x BA has a positive z component, which is the arrangement
+ // we want for A, B, C. If it's negative, then we've got it flipped around and
+ // should swap A and C.
+ if (crossProductZ(pointA, pointB, pointC) < 0.0)
+ {
+ var temp = pointA;
+ pointA = pointC;
+ pointC = temp;
+ }
+
+ patterns[0] = pointA;
+ patterns[1] = pointB;
+ patterns[2] = pointC;
+ }
+
+
+function FinderPattern(posX, posY, estimatedModuleSize)
+{
+ this.x=posX;
+ this.y=posY;
+ this.count = 1;
+ this.estimatedModuleSize = estimatedModuleSize;
+
+ this.__defineGetter__("EstimatedModuleSize", function()
+ {
+ return this.estimatedModuleSize;
+ });
+ this.__defineGetter__("Count", function()
+ {
+ return this.count;
+ });
+ this.__defineGetter__("X", function()
+ {
+ return this.x;
+ });
+ this.__defineGetter__("Y", function()
+ {
+ return this.y;
+ });
+ this.incrementCount = function()
+ {
+ this.count++;
+ }
+ this.aboutEquals=function( moduleSize, i, j)
+ {
+ if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize)
+ {
+ var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
+ return moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;
+ }
+ return false;
+ }
+
+}
+
+function FinderPatternInfo(patternCenters)
+{
+ this.bottomLeft = patternCenters[0];
+ this.topLeft = patternCenters[1];
+ this.topRight = patternCenters[2];
+ this.__defineGetter__("BottomLeft", function()
+ {
+ return this.bottomLeft;
+ });
+ this.__defineGetter__("TopLeft", function()
+ {
+ return this.topLeft;
+ });
+ this.__defineGetter__("TopRight", function()
+ {
+ return this.topRight;
+ });
+}
+
+function FinderPatternFinder()
+{
+ this.image=null;
+ this.possibleCenters = [];
+ this.hasSkipped = false;
+ this.crossCheckStateCount = new Array(0,0,0,0,0);
+ this.resultPointCallback = null;
+
+ this.__defineGetter__("CrossCheckStateCount", function()
+ {
+ this.crossCheckStateCount[0] = 0;
+ this.crossCheckStateCount[1] = 0;
+ this.crossCheckStateCount[2] = 0;
+ this.crossCheckStateCount[3] = 0;
+ this.crossCheckStateCount[4] = 0;
+ return this.crossCheckStateCount;
+ });
+
+ this.foundPatternCross=function( stateCount)
+ {
+ var totalModuleSize = 0;
+ for (var i = 0; i < 5; i++)
+ {
+ var count = stateCount[i];
+ if (count == 0)
+ {
+ return false;
+ }
+ totalModuleSize += count;
+ }
+ if (totalModuleSize < 7)
+ {
+ return false;
+ }
+ var moduleSize = Math.floor((totalModuleSize << INTEGER_MATH_SHIFT) / 7);
+ var maxVariance = Math.floor(moduleSize / 2);
+ // Allow less than 50% variance from 1-1-3-1-1 proportions
+ return Math.abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < 3 * maxVariance && Math.abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < maxVariance;
+ }
+ this.centerFromEnd=function( stateCount, end)
+ {
+ return (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0;
+ }
+ this.crossCheckVertical=function( startI, centerJ, maxCount, originalStateCountTotal)
+ {
+ var image = this.image;
+
+ var maxI = qrcode.height;
+ var stateCount = this.CrossCheckStateCount;
+
+ // Start counting up from center
+ var i = startI;
+ while (i >= 0 && image[centerJ + i*qrcode.width])
+ {
+ stateCount[2]++;
+ i--;
+ }
+ if (i < 0)
+ {
+ return NaN;
+ }
+ while (i >= 0 && !image[centerJ +i*qrcode.width] && stateCount[1] <= maxCount)
+ {
+ stateCount[1]++;
+ i--;
+ }
+ // If already too many modules in this state or ran off the edge:
+ if (i < 0 || stateCount[1] > maxCount)
+ {
+ return NaN;
+ }
+ while (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount)
+ {
+ stateCount[0]++;
+ i--;
+ }
+ if (stateCount[0] > maxCount)
+ {
+ return NaN;
+ }
+
+ // Now also count down from center
+ i = startI + 1;
+ while (i < maxI && image[centerJ +i*qrcode.width])
+ {
+ stateCount[2]++;
+ i++;
+ }
+ if (i == maxI)
+ {
+ return NaN;
+ }
+ while (i < maxI && !image[centerJ + i*qrcode.width] && stateCount[3] < maxCount)
+ {
+ stateCount[3]++;
+ i++;
+ }
+ if (i == maxI || stateCount[3] >= maxCount)
+ {
+ return NaN;
+ }
+ while (i < maxI && image[centerJ + i*qrcode.width] && stateCount[4] < maxCount)
+ {
+ stateCount[4]++;
+ i++;
+ }
+ if (stateCount[4] >= maxCount)
+ {
+ return NaN;
+ }
+
+ // If we found a finder-pattern-like section, but its size is more than 40% different than
+ // the original, assume it's a false positive
+ var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
+ if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal)
+ {
+ return NaN;
+ }
+
+ return this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, i):NaN;
+ }
+ this.crossCheckHorizontal=function( startJ, centerI, maxCount, originalStateCountTotal)
+ {
+ var image = this.image;
+
+ var maxJ = qrcode.width;
+ var stateCount = this.CrossCheckStateCount;
+
+ var j = startJ;
+ while (j >= 0 && image[j+ centerI*qrcode.width])
+ {
+ stateCount[2]++;
+ j--;
+ }
+ if (j < 0)
+ {
+ return NaN;
+ }
+ while (j >= 0 && !image[j+ centerI*qrcode.width] && stateCount[1] <= maxCount)
+ {
+ stateCount[1]++;
+ j--;
+ }
+ if (j < 0 || stateCount[1] > maxCount)
+ {
+ return NaN;
+ }
+ while (j >= 0 && image[j+ centerI*qrcode.width] && stateCount[0] <= maxCount)
+ {
+ stateCount[0]++;
+ j--;
+ }
+ if (stateCount[0] > maxCount)
+ {
+ return NaN;
+ }
+
+ j = startJ + 1;
+ while (j < maxJ && image[j+ centerI*qrcode.width])
+ {
+ stateCount[2]++;
+ j++;
+ }
+ if (j == maxJ)
+ {
+ return NaN;
+ }
+ while (j < maxJ && !image[j+ centerI*qrcode.width] && stateCount[3] < maxCount)
+ {
+ stateCount[3]++;
+ j++;
+ }
+ if (j == maxJ || stateCount[3] >= maxCount)
+ {
+ return NaN;
+ }
+ while (j < maxJ && image[j+ centerI*qrcode.width] && stateCount[4] < maxCount)
+ {
+ stateCount[4]++;
+ j++;
+ }
+ if (stateCount[4] >= maxCount)
+ {
+ return NaN;
+ }
+
+ // If we found a finder-pattern-like section, but its size is significantly different than
+ // the original, assume it's a false positive
+ var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
+ if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal)
+ {
+ return NaN;
+ }
+
+ return this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, j):NaN;
+ }
+ this.handlePossibleCenter=function( stateCount, i, j)
+ {
+ var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
+ var centerJ = this.centerFromEnd(stateCount, j); //float
+ var centerI = this.crossCheckVertical(i, Math.floor( centerJ), stateCount[2], stateCountTotal); //float
+ if (!isNaN(centerI))
+ {
+ // Re-cross check
+ centerJ = this.crossCheckHorizontal(Math.floor( centerJ), Math.floor( centerI), stateCount[2], stateCountTotal);
+ if (!isNaN(centerJ))
+ {
+ var estimatedModuleSize = stateCountTotal / 7.0;
+ var found = false;
+ var max = this.possibleCenters.length;
+ for (var index = 0; index < max; index++)
+ {
+ var center = this.possibleCenters[index];
+ // Look for about the same center and module size:
+ if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
+ {
+ center.incrementCount();
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
+ var point = new FinderPattern(centerJ, centerI, estimatedModuleSize);
+ this.possibleCenters.push(point);
+ if (this.resultPointCallback != null)
+ {
+ this.resultPointCallback.foundPossibleResultPoint(point);
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ this.selectBestPatterns=function()
+ {
+
+ var startSize = this.possibleCenters.length;
+ if (startSize < 3)
+ {
+ // Couldn't find enough finder patterns
+ throw "Couldn't find enough finder patterns (found " + startSize + ")"
+ }
+
+ // Filter outlier possibilities whose module size is too different
+ if (startSize > 3)
+ {
+ // But we can only afford to do so if we have at least 4 possibilities to choose from
+ var totalModuleSize = 0.0;
+ var square = 0.0;
+ for (var i = 0; i < startSize; i++)
+ {
+ //totalModuleSize += this.possibleCenters[i].EstimatedModuleSize;
+ var centerValue=this.possibleCenters[i].EstimatedModuleSize;
+ totalModuleSize += centerValue;
+ square += (centerValue * centerValue);
+ }
+ var average = totalModuleSize / startSize;
+ this.possibleCenters.sort(function(center1,center2) {
+ var dA=Math.abs(center2.EstimatedModuleSize - average);
+ var dB=Math.abs(center1.EstimatedModuleSize - average);
+ if (dA < dB) {
+ return (-1);
+ } else if (dA == dB) {
+ return 0;
+ } else {
+ return 1;
+ }
+ });
+
+ var stdDev = Math.sqrt(square / startSize - average * average);
+ var limit = Math.max(0.2 * average, stdDev);
+ //for (var i = 0; i < this.possibleCenters.length && this.possibleCenters.length > 3; i++)
+ for (var i = this.possibleCenters.length - 1; i >= 0 ; i--)
+ {
+ var pattern = this.possibleCenters[i];
+ //if (Math.abs(pattern.EstimatedModuleSize - average) > 0.2 * average)
+ if (Math.abs(pattern.EstimatedModuleSize - average) > limit)
+ {
+ //this.possibleCenters.remove(i);
+ this.possibleCenters.splice(i,1);
+ //i--;
+ }
+ }
+ }
+
+ if (this.possibleCenters.length > 3)
+ {
+ // Throw away all but those first size candidate points we found.
+ this.possibleCenters.sort(function(a, b){
+ if (a.count > b.count){return -1;}
+ if (a.count < b.count){return 1;}
+ return 0;
+ });
+ }
+
+ return new Array( this.possibleCenters[0], this.possibleCenters[1], this.possibleCenters[2]);
+ }
+
+ this.findRowSkip=function()
+ {
+ var max = this.possibleCenters.length;
+ if (max <= 1)
+ {
+ return 0;
+ }
+ var firstConfirmedCenter = null;
+ for (var i = 0; i < max; i++)
+ {
+ var center = this.possibleCenters[i];
+ if (center.Count >= CENTER_QUORUM)
+ {
+ if (firstConfirmedCenter == null)
+ {
+ firstConfirmedCenter = center;
+ }
+ else
+ {
+ // We have two confirmed centers
+ // How far down can we skip before resuming looking for the next
+ // pattern? In the worst case, only the difference between the
+ // difference in the x / y coordinates of the two centers.
+ // This is the case where you find top left last.
+ this.hasSkipped = true;
+ return Math.floor ((Math.abs(firstConfirmedCenter.X - center.X) - Math.abs(firstConfirmedCenter.Y - center.Y)) / 2);
+ }
+ }
+ }
+ return 0;
+ }
+
+ this.haveMultiplyConfirmedCenters=function()
+ {
+ var confirmedCount = 0;
+ var totalModuleSize = 0.0;
+ var max = this.possibleCenters.length;
+ for (var i = 0; i < max; i++)
+ {
+ var pattern = this.possibleCenters[i];
+ if (pattern.Count >= CENTER_QUORUM)
+ {
+ confirmedCount++;
+ totalModuleSize += pattern.EstimatedModuleSize;
+ }
+ }
+ if (confirmedCount < 3)
+ {
+ return false;
+ }
+ // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive"
+ // and that we need to keep looking. We detect this by asking if the estimated module sizes
+ // vary too much. We arbitrarily say that when the total deviation from average exceeds
+ // 5% of the total module size estimates, it's too much.
+ var average = totalModuleSize / max;
+ var totalDeviation = 0.0;
+ for (var i = 0; i < max; i++)
+ {
+ pattern = this.possibleCenters[i];
+ totalDeviation += Math.abs(pattern.EstimatedModuleSize - average);
+ }
+ return totalDeviation <= 0.05 * totalModuleSize;
+ }
+
+ this.findFinderPattern = function(image){
+ var tryHarder = false;
+ this.image=image;
+ var maxI = qrcode.height;
+ var maxJ = qrcode.width;
+ var iSkip = Math.floor((3 * maxI) / (4 * MAX_MODULES));
+ if (iSkip < MIN_SKIP || tryHarder)
+ {
+ iSkip = MIN_SKIP;
+ }
+
+ var done = false;
+ var stateCount = new Array(5);
+ for (var i = iSkip - 1; i < maxI && !done; i += iSkip)
+ {
+ // Get a row of black/white values
+ stateCount[0] = 0;
+ stateCount[1] = 0;
+ stateCount[2] = 0;
+ stateCount[3] = 0;
+ stateCount[4] = 0;
+ var currentState = 0;
+ for (var j = 0; j < maxJ; j++)
+ {
+ if (image[j+i*qrcode.width] )
+ {
+ // Black pixel
+ if ((currentState & 1) == 1)
+ {
+ // Counting white pixels
+ currentState++;
+ }
+ stateCount[currentState]++;
+ }
+ else
+ {
+ // White pixel
+ if ((currentState & 1) == 0)
+ {
+ // Counting black pixels
+ if (currentState == 4)
+ {
+ // A winner?
+ if (this.foundPatternCross(stateCount))
+ {
+ // Yes
+ var confirmed = this.handlePossibleCenter(stateCount, i, j);
+ if (confirmed)
+ {
+ // Start examining every other line. Checking each line turned out to be too
+ // expensive and didn't improve performance.
+ iSkip = 2;
+ if (this.hasSkipped)
+ {
+ done = this.haveMultiplyConfirmedCenters();
+ }
+ else
+ {
+ var rowSkip = this.findRowSkip();
+ if (rowSkip > stateCount[2])
+ {
+ // Skip rows between row of lower confirmed center
+ // and top of presumed third confirmed center
+ // but back up a bit to get a full chance of detecting
+ // it, entire width of center of finder pattern
+
+ // Skip by rowSkip, but back off by stateCount[2] (size of last center
+ // of pattern we saw) to be conservative, and also back off by iSkip which
+ // is about to be re-added
+ i += rowSkip - stateCount[2] - iSkip;
+ j = maxJ - 1;
+ }
+ }
+ }
+ else
+ {
+ // Advance to next black pixel
+ do
+ {
+ j++;
+ }
+ while (j < maxJ && !image[j + i*qrcode.width]);
+ j--; // back up to that last white pixel
+ }
+ // Clear state to start looking again
+ currentState = 0;
+ stateCount[0] = 0;
+ stateCount[1] = 0;
+ stateCount[2] = 0;
+ stateCount[3] = 0;
+ stateCount[4] = 0;
+ }
+ else
+ {
+ // No, shift counts back by two
+ stateCount[0] = stateCount[2];
+ stateCount[1] = stateCount[3];
+ stateCount[2] = stateCount[4];
+ stateCount[3] = 1;
+ stateCount[4] = 0;
+ currentState = 3;
+ }
+ }
+ else
+ {
+ stateCount[++currentState]++;
+ }
+ }
+ else
+ {
+ // Counting white pixels
+ stateCount[currentState]++;
+ }
+ }
+ }
+ if (this.foundPatternCross(stateCount))
+ {
+ var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
+ if (confirmed)
+ {
+ iSkip = stateCount[0];
+ if (this.hasSkipped)
+ {
+ // Found a third one
+ done = this.haveMultiplyConfirmedCenters();
+ }
+ }
+ }
+ }
+
+ var patternInfo = this.selectBestPatterns();
+ qrcode.orderBestPatterns(patternInfo);
+
+ return new FinderPatternInfo(patternInfo);
+ };
+}
\ No newline at end of file
diff --git a/js/jsqrcode/formatinf.js b/js/jsqrcode/formatinf.js
index 313a4da..62266a4 100644
--- a/js/jsqrcode/formatinf.js
+++ b/js/jsqrcode/formatinf.js
@@ -1,110 +1,104 @@
-/*
- Ported to JavaScript by Lazar Laszlo 2011
-
- lazarsoft@gmail.com, www.lazarsoft.info
-
-*/
-
-/*
-*
-* Copyright 2007 ZXing authors
-*
-* 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.
-*/
-
-
-var FORMAT_INFO_MASK_QR = 0x5412;
-var FORMAT_INFO_DECODE_LOOKUP = new Array(new Array(0x5412, 0x00), new Array(0x5125, 0x01), new Array(0x5E7C, 0x02), new Array(0x5B4B, 0x03), new Array(0x45F9, 0x04), new Array(0x40CE, 0x05), new Array(0x4F97, 0x06), new Array(0x4AA0, 0x07), new Array(0x77C4, 0x08), new Array(0x72F3, 0x09), new Array(0x7DAA, 0x0A), new Array(0x789D, 0x0B), new Array(0x662F, 0x0C), new Array(0x6318, 0x0D), new Array(0x6C41, 0x0E), new Array(0x6976, 0x0F), new Array(0x1689, 0x10), new Array(0x13BE, 0x11), new Array(0x1CE7, 0x12), new Array(0x19D0, 0x13), new Array(0x0762, 0x14), new Array(0x0255, 0x15), new Array(0x0D0C, 0x16), new Array(0x083B, 0x17), new Array(0x355F, 0x18), new Array(0x3068, 0x19), new Array(0x3F31, 0x1A), new Array(0x3A06, 0x1B), new Array(0x24B4, 0x1C), new Array(0x2183, 0x1D), new Array(0x2EDA, 0x1E), new Array(0x2BED, 0x1F));
-var BITS_SET_IN_HALF_BYTE = new Array(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
-
-
-function FormatInformation(formatInfo)
-{
- this.errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03);
- this.dataMask = (formatInfo & 0x07);
-
- Object.defineProperties(this, {
- 'ErrorCorrectionLevel': {
- get: function () {
- return this.errorCorrectionLevel;
- }
- },
-
- 'DataMask': {
- get: function () {
- return this.dataMask;
- }
- }
- });
-
- this.GetHashCode=function()
- {
- return (this.errorCorrectionLevel.ordinal() << 3) | dataMask;
- }
- this.Equals=function( o)
- {
- var other = o;
- return this.errorCorrectionLevel == other.errorCorrectionLevel && this.dataMask == other.dataMask;
- }
-}
-
-FormatInformation.numBitsDiffering=function( a, b)
-{
- a ^= b; // a now has a 1 bit exactly where its bit differs with b's
- // Count bits set quickly with a series of lookups:
- return BITS_SET_IN_HALF_BYTE[a & 0x0F] + BITS_SET_IN_HALF_BYTE[(URShift(a, 4) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 8) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 12) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 16) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 20) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 24) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 28) & 0x0F)];
-}
-
-FormatInformation.decodeFormatInformation=function( maskedFormatInfo)
-{
- var formatInfo = FormatInformation.doDecodeFormatInformation(maskedFormatInfo);
- if (formatInfo != null)
- {
- return formatInfo;
- }
- // Should return null, but, some QR codes apparently
- // do not mask this info. Try again by actually masking the pattern
- // first
- return FormatInformation.doDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR);
-}
-FormatInformation.doDecodeFormatInformation=function( maskedFormatInfo)
-{
- // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing
- var bestDifference = 0xffffffff;
- var bestFormatInfo = 0;
- for (var i = 0; i < FORMAT_INFO_DECODE_LOOKUP.length; i++)
- {
- var decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i];
- var targetInfo = decodeInfo[0];
- if (targetInfo == maskedFormatInfo)
- {
- // Found an exact match
- return new FormatInformation(decodeInfo[1]);
- }
- var bitsDifference = this.numBitsDiffering(maskedFormatInfo, targetInfo);
- if (bitsDifference < bestDifference)
- {
- bestFormatInfo = decodeInfo[1];
- bestDifference = bitsDifference;
- }
- }
- // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits
- // differing means we found a match
- if (bestDifference <= 3)
- {
- return new FormatInformation(bestFormatInfo);
- }
- return null;
-}
-
-
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* 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.
+*/
+
+
+var FORMAT_INFO_MASK_QR = 0x5412;
+var FORMAT_INFO_DECODE_LOOKUP = new Array(new Array(0x5412, 0x00), new Array(0x5125, 0x01), new Array(0x5E7C, 0x02), new Array(0x5B4B, 0x03), new Array(0x45F9, 0x04), new Array(0x40CE, 0x05), new Array(0x4F97, 0x06), new Array(0x4AA0, 0x07), new Array(0x77C4, 0x08), new Array(0x72F3, 0x09), new Array(0x7DAA, 0x0A), new Array(0x789D, 0x0B), new Array(0x662F, 0x0C), new Array(0x6318, 0x0D), new Array(0x6C41, 0x0E), new Array(0x6976, 0x0F), new Array(0x1689, 0x10), new Array(0x13BE, 0x11), new Array(0x1CE7, 0x12), new Array(0x19D0, 0x13), new Array(0x0762, 0x14), new Array(0x0255, 0x15), new Array(0x0D0C, 0x16), new Array(0x083B, 0x17), new Array(0x355F, 0x18), new Array(0x3068, 0x19), new Array(0x3F31, 0x1A), new Array(0x3A06, 0x1B), new Array(0x24B4, 0x1C), new Array(0x2183, 0x1D), new Array(0x2EDA, 0x1E), new Array(0x2BED, 0x1F));
+var BITS_SET_IN_HALF_BYTE = new Array(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
+
+
+function FormatInformation(formatInfo)
+{
+ this.errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03);
+ this.dataMask = (formatInfo & 0x07);
+
+ this.__defineGetter__("ErrorCorrectionLevel", function()
+ {
+ return this.errorCorrectionLevel;
+ });
+ this.__defineGetter__("DataMask", function()
+ {
+ return this.dataMask;
+ });
+ this.GetHashCode=function()
+ {
+ return (this.errorCorrectionLevel.ordinal() << 3) | this.dataMask;
+ }
+ this.Equals=function( o)
+ {
+ var other = o;
+ return this.errorCorrectionLevel == other.errorCorrectionLevel && this.dataMask == other.dataMask;
+ }
+}
+
+FormatInformation.numBitsDiffering=function( a, b)
+{
+ a ^= b; // a now has a 1 bit exactly where its bit differs with b's
+ // Count bits set quickly with a series of lookups:
+ return BITS_SET_IN_HALF_BYTE[a & 0x0F] + BITS_SET_IN_HALF_BYTE[(URShift(a, 4) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 8) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 12) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 16) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 20) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 24) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 28) & 0x0F)];
+}
+
+FormatInformation.decodeFormatInformation=function( maskedFormatInfo)
+{
+ var formatInfo = FormatInformation.doDecodeFormatInformation(maskedFormatInfo);
+ if (formatInfo != null)
+ {
+ return formatInfo;
+ }
+ // Should return null, but, some QR codes apparently
+ // do not mask this info. Try again by actually masking the pattern
+ // first
+ return FormatInformation.doDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR);
+}
+FormatInformation.doDecodeFormatInformation=function( maskedFormatInfo)
+{
+ // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing
+ var bestDifference = 0xffffffff;
+ var bestFormatInfo = 0;
+ for (var i = 0; i < FORMAT_INFO_DECODE_LOOKUP.length; i++)
+ {
+ var decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i];
+ var targetInfo = decodeInfo[0];
+ if (targetInfo == maskedFormatInfo)
+ {
+ // Found an exact match
+ return new FormatInformation(decodeInfo[1]);
+ }
+ var bitsDifference = this.numBitsDiffering(maskedFormatInfo, targetInfo);
+ if (bitsDifference < bestDifference)
+ {
+ bestFormatInfo = decodeInfo[1];
+ bestDifference = bitsDifference;
+ }
+ }
+ // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits
+ // differing means we found a match
+ if (bestDifference <= 3)
+ {
+ return new FormatInformation(bestFormatInfo);
+ }
+ return null;
+}
+
+
\ No newline at end of file
diff --git a/js/jsqrcode/gf256.js b/js/jsqrcode/gf256.js
index 9df58c6..8eb6b61 100644
--- a/js/jsqrcode/gf256.js
+++ b/js/jsqrcode/gf256.js
@@ -1,123 +1,117 @@
-/*
- Ported to JavaScript by Lazar Laszlo 2011
-
- lazarsoft@gmail.com, www.lazarsoft.info
-
-*/
-
-/*
-*
-* Copyright 2007 ZXing authors
-*
-* 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.
-*/
-
-
-function GF256( primitive)
-{
- this.expTable = new Array(256);
- this.logTable = new Array(256);
- var x = 1;
- for (var i = 0; i < 256; i++)
- {
- this.expTable[i] = x;
- x <<= 1; // x = x * 2; we're assuming the generator alpha is 2
- if (x >= 0x100)
- {
- x ^= primitive;
- }
- }
- for (var i = 0; i < 255; i++)
- {
- this.logTable[this.expTable[i]] = i;
- }
- // logTable[0] == 0 but this should never be used
- var at0=new Array(1);at0[0]=0;
- this.zero = new GF256Poly(this, new Array(at0));
- var at1=new Array(1);at1[0]=1;
- this.one = new GF256Poly(this, new Array(at1));
-
- Object.defineProperties(this, {
- 'Zero': {
- get: function () {
- return this.zero;
- }
- },
-
- 'One': {
- get: function () {
- return this.one;
- }
- }
- });
-
- this.buildMonomial=function( degree, coefficient)
- {
- if (degree < 0)
- {
- throw "System.ArgumentException";
- }
- if (coefficient == 0)
- {
- return zero;
- }
- var coefficients = new Array(degree + 1);
- for(var i=0;i= 0x100)
+ {
+ x ^= primitive;
+ }
+ }
+ for (var i = 0; i < 255; i++)
+ {
+ this.logTable[this.expTable[i]] = i;
+ }
+ // logTable[0] == 0 but this should never be used
+ var at0=new Array(1);at0[0]=0;
+ this.zero = new GF256Poly(this, new Array(at0));
+ var at1=new Array(1);at1[0]=1;
+ this.one = new GF256Poly(this, new Array(at1));
+
+ this.__defineGetter__("Zero", function()
+ {
+ return this.zero;
+ });
+ this.__defineGetter__("One", function()
+ {
+ return this.one;
+ });
+ this.buildMonomial=function( degree, coefficient)
+ {
+ if (degree < 0)
+ {
+ throw "System.ArgumentException";
+ }
+ if (coefficient == 0)
+ {
+ return this.zero;
+ }
+ var coefficients = new Array(degree + 1);
+ for(var i=0;i 1 && coefficients[0] == 0)
- {
- // Leading term must be non-zero for anything except the constant polynomial "0"
- var firstNonZero = 1;
- while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0)
- {
- firstNonZero++;
- }
- if (firstNonZero == coefficientsLength)
- {
- this.coefficients = field.Zero.coefficients;
- }
- else
- {
- this.coefficients = new Array(coefficientsLength - firstNonZero);
- for(var i=0;i largerCoefficients.length)
- {
- var temp = smallerCoefficients;
- smallerCoefficients = largerCoefficients;
- largerCoefficients = temp;
- }
- var sumDiff = new Array(largerCoefficients.length);
- var lengthDiff = largerCoefficients.length - smallerCoefficients.length;
- // Copy high-order terms only found in higher-degree polynomial's coefficients
- //Array.Copy(largerCoefficients, 0, sumDiff, 0, lengthDiff);
- for(var ci=0;ci= other.Degree && !remainder.Zero)
- {
- var degreeDifference = remainder.Degree - other.Degree;
- var scale = this.field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm);
- var term = other.multiplyByMonomial(degreeDifference, scale);
- var iterationQuotient = this.field.buildMonomial(degreeDifference, scale);
- quotient = quotient.addOrSubtract(iterationQuotient);
- remainder = remainder.addOrSubtract(term);
- }
-
- return new Array(quotient, remainder);
- }
-}
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* 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.
+*/
+
+
+function GF256Poly(field, coefficients)
+{
+ if (coefficients == null || coefficients.length == 0)
+ {
+ throw "System.ArgumentException";
+ }
+ this.field = field;
+ var coefficientsLength = coefficients.length;
+ if (coefficientsLength > 1 && coefficients[0] == 0)
+ {
+ // Leading term must be non-zero for anything except the constant polynomial "0"
+ var firstNonZero = 1;
+ while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0)
+ {
+ firstNonZero++;
+ }
+ if (firstNonZero == coefficientsLength)
+ {
+ this.coefficients = field.Zero.coefficients;
+ }
+ else
+ {
+ this.coefficients = new Array(coefficientsLength - firstNonZero);
+ for(var i=0;i largerCoefficients.length)
+ {
+ var temp = smallerCoefficients;
+ smallerCoefficients = largerCoefficients;
+ largerCoefficients = temp;
+ }
+ var sumDiff = new Array(largerCoefficients.length);
+ var lengthDiff = largerCoefficients.length - smallerCoefficients.length;
+ // Copy high-order terms only found in higher-degree polynomial's coefficients
+ //Array.Copy(largerCoefficients, 0, sumDiff, 0, lengthDiff);
+ for(var ci=0;ci= other.Degree && !remainder.Zero)
+ {
+ var degreeDifference = remainder.Degree - other.Degree;
+ var scale = this.field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm);
+ var term = other.multiplyByMonomial(degreeDifference, scale);
+ var iterationQuotient = this.field.buildMonomial(degreeDifference, scale);
+ quotient = quotient.addOrSubtract(iterationQuotient);
+ remainder = remainder.addOrSubtract(term);
+ }
+
+ return new Array(quotient, remainder);
+ }
+}
\ No newline at end of file
diff --git a/js/jsqrcode/grid.js b/js/jsqrcode/grid.js
index b049fe0..3be2ad6 100644
--- a/js/jsqrcode/grid.js
+++ b/js/jsqrcode/grid.js
@@ -1,152 +1,152 @@
-/*
- Ported to JavaScript by Lazar Laszlo 2011
-
- lazarsoft@gmail.com, www.lazarsoft.info
-
-*/
-
-/*
-*
-* Copyright 2007 ZXing authors
-*
-* 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.
-*/
-
-
-GridSampler = {};
-
-GridSampler.checkAndNudgePoints=function( image, points)
- {
- var width = qrcode.width;
- var height = qrcode.height;
- // Check and nudge points from start until we see some that are OK:
- var nudged = true;
- for (var offset = 0; offset < points.length && nudged; offset += 2)
- {
- var x = Math.floor (points[offset]);
- var y = Math.floor( points[offset + 1]);
- if (x < - 1 || x > width || y < - 1 || y > height)
- {
- throw "Error.checkAndNudgePoints ";
- }
- nudged = false;
- if (x == - 1)
- {
- points[offset] = 0.0;
- nudged = true;
- }
- else if (x == width)
- {
- points[offset] = width - 1;
- nudged = true;
- }
- if (y == - 1)
- {
- points[offset + 1] = 0.0;
- nudged = true;
- }
- else if (y == height)
- {
- points[offset + 1] = height - 1;
- nudged = true;
- }
- }
- // Check and nudge points from end:
- nudged = true;
- for (var offset = points.length - 2; offset >= 0 && nudged; offset -= 2)
- {
- var x = Math.floor( points[offset]);
- var y = Math.floor( points[offset + 1]);
- if (x < - 1 || x > width || y < - 1 || y > height)
- {
- throw "Error.checkAndNudgePoints ";
- }
- nudged = false;
- if (x == - 1)
- {
- points[offset] = 0.0;
- nudged = true;
- }
- else if (x == width)
- {
- points[offset] = width - 1;
- nudged = true;
- }
- if (y == - 1)
- {
- points[offset + 1] = 0.0;
- nudged = true;
- }
- else if (y == height)
- {
- points[offset + 1] = height - 1;
- nudged = true;
- }
- }
- }
-
-
-
-GridSampler.sampleGrid3=function( image, dimension, transform)
- {
- var bits = new BitMatrix(dimension);
- var points = new Array(dimension << 1);
- for (var y = 0; y < dimension; y++)
- {
- var max = points.length;
- var iValue = y + 0.5;
- for (var x = 0; x < max; x += 2)
- {
- points[x] = (x >> 1) + 0.5;
- points[x + 1] = iValue;
- }
- transform.transformPoints1(points);
- // Quick check to see if points transformed to something inside the image;
- // sufficient to check the endpoints
- GridSampler.checkAndNudgePoints(image, points);
- try
- {
- for (var x = 0; x < max; x += 2)
- {
- var xpoint = (Math.floor( points[x]) * 4) + (Math.floor( points[x + 1]) * qrcode.width * 4);
- var bit = image[Math.floor( points[x])+ qrcode.width* Math.floor( points[x + 1])];
- qrcode.imagedata.data[xpoint] = bit?255:0;
- qrcode.imagedata.data[xpoint+1] = bit?255:0;
- qrcode.imagedata.data[xpoint+2] = 0;
- qrcode.imagedata.data[xpoint+3] = 255;
- //bits[x >> 1][ y]=bit;
- if(bit)
- bits.set_Renamed(x >> 1, y);
- }
- }
- catch ( aioobe)
- {
- // This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting
- // transform gets "twisted" such that it maps a straight line of points to a set of points
- // whose endpoints are in bounds, but others are not. There is probably some mathematical
- // way to detect this about the transformation that I don't know yet.
- // This results in an ugly runtime exception despite our clever checks above -- can't have
- // that. We could check each point's coordinates but that feels duplicative. We settle for
- // catching and wrapping ArrayIndexOutOfBoundsException.
- throw "Error.checkAndNudgePoints";
- }
- }
- return bits;
- }
-
-GridSampler.sampleGridx=function( image, dimension, p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY)
-{
- var transform = PerspectiveTransform.quadrilateralToQuadrilateral(p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY);
-
- return GridSampler.sampleGrid3(image, dimension, transform);
-}
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* 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.
+*/
+
+
+var GridSampler = {};
+
+GridSampler.checkAndNudgePoints=function( image, points)
+ {
+ var width = qrcode.width;
+ var height = qrcode.height;
+ // Check and nudge points from start until we see some that are OK:
+ var nudged = true;
+ for (var offset = 0; offset < points.length && nudged; offset += 2)
+ {
+ var x = Math.floor (points[offset]);
+ var y = Math.floor( points[offset + 1]);
+ if (x < - 1 || x > width || y < - 1 || y > height)
+ {
+ throw "Error.checkAndNudgePoints ";
+ }
+ nudged = false;
+ if (x == - 1)
+ {
+ points[offset] = 0.0;
+ nudged = true;
+ }
+ else if (x == width)
+ {
+ points[offset] = width - 1;
+ nudged = true;
+ }
+ if (y == - 1)
+ {
+ points[offset + 1] = 0.0;
+ nudged = true;
+ }
+ else if (y == height)
+ {
+ points[offset + 1] = height - 1;
+ nudged = true;
+ }
+ }
+ // Check and nudge points from end:
+ nudged = true;
+ for (var offset = points.length - 2; offset >= 0 && nudged; offset -= 2)
+ {
+ var x = Math.floor( points[offset]);
+ var y = Math.floor( points[offset + 1]);
+ if (x < - 1 || x > width || y < - 1 || y > height)
+ {
+ throw "Error.checkAndNudgePoints ";
+ }
+ nudged = false;
+ if (x == - 1)
+ {
+ points[offset] = 0.0;
+ nudged = true;
+ }
+ else if (x == width)
+ {
+ points[offset] = width - 1;
+ nudged = true;
+ }
+ if (y == - 1)
+ {
+ points[offset + 1] = 0.0;
+ nudged = true;
+ }
+ else if (y == height)
+ {
+ points[offset + 1] = height - 1;
+ nudged = true;
+ }
+ }
+ }
+
+
+
+GridSampler.sampleGrid3=function( image, dimension, transform)
+ {
+ var bits = new BitMatrix(dimension);
+ var points = new Array(dimension << 1);
+ for (var y = 0; y < dimension; y++)
+ {
+ var max = points.length;
+ var iValue = y + 0.5;
+ for (var x = 0; x < max; x += 2)
+ {
+ points[x] = (x >> 1) + 0.5;
+ points[x + 1] = iValue;
+ }
+ transform.transformPoints1(points);
+ // Quick check to see if points transformed to something inside the image;
+ // sufficient to check the endpoints
+ GridSampler.checkAndNudgePoints(image, points);
+ try
+ {
+ for (var x = 0; x < max; x += 2)
+ {
+ //var xpoint = (Math.floor( points[x]) * 4) + (Math.floor( points[x + 1]) * qrcode.width * 4);
+ var bit = image[Math.floor( points[x])+ qrcode.width* Math.floor( points[x + 1])];
+ //qrcode.imagedata.data[xpoint] = bit?255:0;
+ //qrcode.imagedata.data[xpoint+1] = bit?255:0;
+ //qrcode.imagedata.data[xpoint+2] = 0;
+ //qrcode.imagedata.data[xpoint+3] = 255;
+ //bits[x >> 1][ y]=bit;
+ if(bit)
+ bits.set_Renamed(x >> 1, y);
+ }
+ }
+ catch ( aioobe)
+ {
+ // This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting
+ // transform gets "twisted" such that it maps a straight line of points to a set of points
+ // whose endpoints are in bounds, but others are not. There is probably some mathematical
+ // way to detect this about the transformation that I don't know yet.
+ // This results in an ugly runtime exception despite our clever checks above -- can't have
+ // that. We could check each point's coordinates but that feels duplicative. We settle for
+ // catching and wrapping ArrayIndexOutOfBoundsException.
+ throw "Error.checkAndNudgePoints";
+ }
+ }
+ return bits;
+ }
+
+GridSampler.sampleGridx=function( image, dimension, p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY)
+{
+ var transform = PerspectiveTransform.quadrilateralToQuadrilateral(p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY);
+
+ return GridSampler.sampleGrid3(image, dimension, transform);
+}
\ No newline at end of file
diff --git a/js/jsqrcode/qrcode.js b/js/jsqrcode/qrcode.js
index 2830c83..a83bdde 100644
--- a/js/jsqrcode/qrcode.js
+++ b/js/jsqrcode/qrcode.js
@@ -1,322 +1,455 @@
-/*
- Copyright 2011 Lazar Laszlo (lazarsoft@gmail.com, www.lazarsoft.info)
-
- 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.
-*/
-
-
-qrcode = {};
-qrcode.imagedata = null;
-qrcode.width = 0;
-qrcode.height = 0;
-qrcode.qrCodeSymbol = null;
-qrcode.debug = false;
-qrcode.maxImgSize = 1024*1024;
-
-qrcode.sizeOfDataLengthInfo = [ [ 10, 9, 8, 8 ], [ 12, 11, 16, 10 ], [ 14, 13, 16, 12 ] ];
-
-qrcode.callback = null;
-
-qrcode.decode = function(src){
-
- if(arguments.length==0)
- {
- var canvas_qr = document.getElementById("qr-canvas");
- var context = canvas_qr.getContext('2d');
- qrcode.width = canvas_qr.width;
- qrcode.height = canvas_qr.height;
- qrcode.imagedata = context.getImageData(0, 0, qrcode.width, qrcode.height);
- qrcode.result = qrcode.process(context);
- if(qrcode.callback!=null)
- qrcode.callback(qrcode.result);
- return qrcode.result;
- }
- else
- {
- var image = new Image();
- image.crossOrigin = "Anonymous";
- image.onload=function(){
- //var canvas_qr = document.getElementById("qr-canvas");
- var canvas_qr = document.createElement('canvas');
- var context = canvas_qr.getContext('2d');
- var nheight = image.height;
- var nwidth = image.width;
- if(image.width*image.height>qrcode.maxImgSize)
- {
- var ir = image.width / image.height;
- nheight = Math.sqrt(qrcode.maxImgSize/ir);
- nwidth=ir*nheight;
- }
-
- canvas_qr.width = nwidth;
- canvas_qr.height = nheight;
-
- context.drawImage(image, 0, 0, canvas_qr.width, canvas_qr.height );
- qrcode.width = canvas_qr.width;
- qrcode.height = canvas_qr.height;
- try{
- qrcode.imagedata = context.getImageData(0, 0, canvas_qr.width, canvas_qr.height);
- }catch(e){
- qrcode.result = "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!";
- if(qrcode.callback!=null)
- qrcode.callback(qrcode.result);
- return;
- }
-
- try
- {
- qrcode.result = qrcode.process(context);
- }
- catch(e)
- {
- console.log(e);
- qrcode.result = "error decoding QR Code";
- }
- if(qrcode.callback!=null)
- qrcode.callback(qrcode.result);
- }
- image.src = src;
- }
-}
-
-qrcode.isUrl = function(s)
-{
- var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
- return regexp.test(s);
-}
-
-qrcode.decode_url = function (s)
-{
- var escaped = "";
- try{
- escaped = escape( s );
- }
- catch(e)
- {
- console.log(e);
- escaped = s;
- }
- var ret = "";
- try{
- ret = decodeURIComponent( escaped );
- }
- catch(e)
- {
- console.log(e);
- ret = escaped;
- }
- return ret;
-}
-
-qrcode.decode_utf8 = function ( s )
-{
- if(qrcode.isUrl(s))
- return qrcode.decode_url(s);
- else
- return s;
-}
-
-qrcode.process = function(ctx){
-
- var start = new Date().getTime();
-
- var image = qrcode.grayScaleToBitmap(qrcode.grayscale());
- //var image = qrcode.binarize(128);
-
- if(qrcode.debug)
- {
- for (var y = 0; y < qrcode.height; y++)
- {
- for (var x = 0; x < qrcode.width; x++)
- {
- var point = (x * 4) + (y * qrcode.width * 4);
- qrcode.imagedata.data[point] = image[x+y*qrcode.width]?0:0;
- qrcode.imagedata.data[point+1] = image[x+y*qrcode.width]?0:0;
- qrcode.imagedata.data[point+2] = image[x+y*qrcode.width]?255:0;
- }
- }
- ctx.putImageData(qrcode.imagedata, 0, 0);
- }
-
- //var finderPatternInfo = new FinderPatternFinder().findFinderPattern(image);
-
- var detector = new Detector(image);
-
- var qRCodeMatrix = detector.detect();
-
- /*for (var y = 0; y < qRCodeMatrix.bits.Height; y++)
- {
- for (var x = 0; x < qRCodeMatrix.bits.Width; x++)
- {
- var point = (x * 4*2) + (y*2 * qrcode.width * 4);
- qrcode.imagedata.data[point] = qRCodeMatrix.bits.get_Renamed(x,y)?0:0;
- qrcode.imagedata.data[point+1] = qRCodeMatrix.bits.get_Renamed(x,y)?0:0;
- qrcode.imagedata.data[point+2] = qRCodeMatrix.bits.get_Renamed(x,y)?255:0;
- }
- }*/
- if(qrcode.debug)
- ctx.putImageData(qrcode.imagedata, 0, 0);
-
- console.log(qRCodeMatrix);
-
- var reader = Decoder.decode(qRCodeMatrix.bits);
- var data = reader.DataByte;
- var str="";
- for(var i=0;i minmax[ax][ay][1])
- minmax[ax][ay][1] = target;
- }
- }
- //minmax[ax][ay][0] = (minmax[ax][ay][0] + minmax[ax][ay][1]) / 2;
- }
- }
- var middle = new Array(numSqrtArea);
- for (var i3 = 0; i3 < numSqrtArea; i3++)
- {
- middle[i3] = new Array(numSqrtArea);
- }
- for (var ay = 0; ay < numSqrtArea; ay++)
- {
- for (var ax = 0; ax < numSqrtArea; ax++)
- {
- middle[ax][ay] = Math.floor((minmax[ax][ay][0] + minmax[ax][ay][1]) / 2);
- //Console.out.print(middle[ax][ay] + ",");
- }
- //Console.out.println("");
- }
- //Console.out.println("");
-
- return middle;
-}
-
-qrcode.grayScaleToBitmap=function(grayScale)
-{
- var middle = qrcode.getMiddleBrightnessPerArea(grayScale);
- var sqrtNumArea = middle.length;
- var areaWidth = Math.floor(qrcode.width / sqrtNumArea);
- var areaHeight = Math.floor(qrcode.height / sqrtNumArea);
- var bitmap = new Array(qrcode.height*qrcode.width);
-
- for (var ay = 0; ay < sqrtNumArea; ay++)
- {
- for (var ax = 0; ax < sqrtNumArea; ax++)
- {
- for (var dy = 0; dy < areaHeight; dy++)
- {
- for (var dx = 0; dx < areaWidth; dx++)
- {
- bitmap[areaWidth * ax + dx+ (areaHeight * ay + dy)*qrcode.width] = (grayScale[areaWidth * ax + dx+ (areaHeight * ay + dy)*qrcode.width] < middle[ax][ay])?true:false;
- }
- }
- }
- }
- return bitmap;
-}
-
-qrcode.grayscale = function(){
- var ret = new Array(qrcode.width*qrcode.height);
- for (var y = 0; y < qrcode.height; y++)
- {
- for (var x = 0; x < qrcode.width; x++)
- {
- var gray = qrcode.getPixel(x, y);
-
- ret[x+y*qrcode.width] = gray;
- }
- }
- return ret;
-}
-
-
-
-
-function URShift( number, bits)
-{
- if (number >= 0)
- return number >> bits;
- else
- return (number >> bits) + (2 << ~bits);
-}
-
-
-Array.prototype.remove = function(from, to) {
- var rest = this.slice((to || from) + 1 || this.length);
- this.length = from < 0 ? this.length + from : from;
- return this.push.apply(this, rest);
-};
+/*
+ Copyright 2011 Lazar Laszlo (lazarsoft@gmail.com, www.lazarsoft.info)
+
+ 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.
+*/
+
+
+var qrcode = {};
+qrcode.imagedata = null;
+qrcode.width = 0;
+qrcode.height = 0;
+qrcode.qrCodeSymbol = null;
+qrcode.debug = false;
+qrcode.maxImgSize = 1024*1024;
+
+qrcode.sizeOfDataLengthInfo = [ [ 10, 9, 8, 8 ], [ 12, 11, 16, 10 ], [ 14, 13, 16, 12 ] ];
+
+qrcode.callback = null;
+
+qrcode.vidSuccess = function (stream)
+{
+ qrcode.localstream = stream;
+ if(qrcode.webkit)
+ qrcode.video.src = window.webkitURL.createObjectURL(stream);
+ else
+ if(qrcode.moz)
+ {
+ qrcode.video.mozSrcObject = stream;
+ qrcode.video.play();
+ }
+ else
+ qrcode.video.src = stream;
+
+ qrcode.gUM=true;
+
+ qrcode.canvas_qr2 = document.createElement('canvas');
+ qrcode.canvas_qr2.id = "qr-canvas";
+ qrcode.qrcontext2 = qrcode.canvas_qr2.getContext('2d');
+ qrcode.canvas_qr2.width = qrcode.video.videoWidth;
+ qrcode.canvas_qr2.height = qrcode.video.videoHeight;
+ setTimeout(qrcode.captureToCanvas, 500);
+}
+
+qrcode.vidError = function(error)
+{
+ qrcode.gUM=false;
+ return;
+}
+
+qrcode.captureToCanvas = function()
+{
+ if(qrcode.gUM)
+ {
+ try{
+ if(qrcode.video.videoWidth == 0)
+ {
+ setTimeout(qrcode.captureToCanvas, 500);
+ return;
+ }
+ else
+ {
+ qrcode.canvas_qr2.width = qrcode.video.videoWidth;
+ qrcode.canvas_qr2.height = qrcode.video.videoHeight;
+ }
+ qrcode.qrcontext2.drawImage(qrcode.video,0,0);
+ try{
+ qrcode.decode();
+ }
+ catch(e){
+ console.log(e);
+ setTimeout(qrcode.captureToCanvas, 500);
+ };
+ }
+ catch(e){
+ console.log(e);
+ setTimeout(qrcode.captureToCanvas, 500);
+ };
+ }
+}
+
+qrcode.setWebcam = function(videoId)
+{
+ var n=navigator;
+ qrcode.video=document.getElementById(videoId);
+
+ var options = true;
+ if(navigator.mediaDevices && navigator.mediaDevices.enumerateDevices)
+ {
+ try{
+ navigator.mediaDevices.enumerateDevices()
+ .then(function(devices) {
+ devices.forEach(function(device) {
+ console.log("deb1");
+ if (device.kind === 'videoinput') {
+ if(device.label.toLowerCase().search("back") >-1)
+ options=[{'sourceId': device.deviceId}] ;
+ }
+ console.log(device.kind + ": " + device.label +
+ " id = " + device.deviceId);
+ });
+ })
+
+ }
+ catch(e)
+ {
+ console.log(e);
+ }
+ }
+ else{
+ console.log("no navigator.mediaDevices.enumerateDevices" );
+ }
+
+ if(n.getUserMedia)
+ n.getUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
+ else
+ if(n.webkitGetUserMedia)
+ {
+ qrcode.webkit=true;
+ n.webkitGetUserMedia({video:options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
+ }
+ else
+ if(n.mozGetUserMedia)
+ {
+ qrcode.moz=true;
+ n.mozGetUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
+ }
+}
+
+qrcode.decode = function(src){
+
+ if(arguments.length==0)
+ {
+ if(qrcode.canvas_qr2)
+ {
+ var canvas_qr = qrcode.canvas_qr2;
+ var context = qrcode.qrcontext2;
+ }
+ else
+ {
+ var canvas_qr = document.getElementById("qr-canvas");
+ var context = canvas_qr.getContext('2d');
+ }
+ qrcode.width = canvas_qr.width;
+ qrcode.height = canvas_qr.height;
+ qrcode.imagedata = context.getImageData(0, 0, qrcode.width, qrcode.height);
+ qrcode.result = qrcode.process(context);
+ if(qrcode.callback!=null)
+ qrcode.callback(qrcode.result);
+ return qrcode.result;
+ }
+ else
+ {
+ var image = new Image();
+ image.crossOrigin = "Anonymous";
+ image.onload=function(){
+ //var canvas_qr = document.getElementById("qr-canvas");
+ var canvas_out = document.getElementById("out-canvas");
+ if(canvas_out!=null)
+ {
+ var outctx = canvas_out.getContext('2d');
+ outctx.clearRect(0, 0, 320, 240);
+ outctx.drawImage(image, 0, 0, 320, 240);
+ }
+
+ var canvas_qr = document.createElement('canvas');
+ var context = canvas_qr.getContext('2d');
+ var nheight = image.height;
+ var nwidth = image.width;
+ if(image.width*image.height>qrcode.maxImgSize)
+ {
+ var ir = image.width / image.height;
+ nheight = Math.sqrt(qrcode.maxImgSize/ir);
+ nwidth=ir*nheight;
+ }
+
+ canvas_qr.width = nwidth;
+ canvas_qr.height = nheight;
+
+ context.drawImage(image, 0, 0, canvas_qr.width, canvas_qr.height );
+ qrcode.width = canvas_qr.width;
+ qrcode.height = canvas_qr.height;
+ try{
+ qrcode.imagedata = context.getImageData(0, 0, canvas_qr.width, canvas_qr.height);
+ }catch(e){
+ qrcode.result = "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!";
+ if(qrcode.callback!=null)
+ qrcode.callback(qrcode.result);
+ return;
+ }
+
+ try
+ {
+ qrcode.result = qrcode.process(context);
+ }
+ catch(e)
+ {
+ console.log(e);
+ qrcode.result = "error decoding QR Code";
+ }
+ if(qrcode.callback!=null)
+ qrcode.callback(qrcode.result);
+ }
+ image.onerror = function ()
+ {
+ if(qrcode.callback!=null)
+ qrcode.callback("Failed to load the image");
+ }
+ image.src = src;
+ }
+}
+
+qrcode.isUrl = function(s)
+{
+ var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
+ return regexp.test(s);
+}
+
+qrcode.decode_url = function (s)
+{
+ var escaped = "";
+ try{
+ escaped = escape( s );
+ }
+ catch(e)
+ {
+ console.log(e);
+ escaped = s;
+ }
+ var ret = "";
+ try{
+ ret = decodeURIComponent( escaped );
+ }
+ catch(e)
+ {
+ console.log(e);
+ ret = escaped;
+ }
+ return ret;
+}
+
+qrcode.decode_utf8 = function ( s )
+{
+ if(qrcode.isUrl(s))
+ return qrcode.decode_url(s);
+ else
+ return s;
+}
+
+qrcode.process = function(ctx){
+
+ var start = new Date().getTime();
+
+ var image = qrcode.grayScaleToBitmap(qrcode.grayscale());
+ //var image = qrcode.binarize(128);
+
+ if(qrcode.debug)
+ {
+ for (var y = 0; y < qrcode.height; y++)
+ {
+ for (var x = 0; x < qrcode.width; x++)
+ {
+ var point = (x * 4) + (y * qrcode.width * 4);
+ qrcode.imagedata.data[point] = image[x+y*qrcode.width]?0:0;
+ qrcode.imagedata.data[point+1] = image[x+y*qrcode.width]?0:0;
+ qrcode.imagedata.data[point+2] = image[x+y*qrcode.width]?255:0;
+ }
+ }
+ ctx.putImageData(qrcode.imagedata, 0, 0);
+ }
+
+ //var finderPatternInfo = new FinderPatternFinder().findFinderPattern(image);
+
+ var detector = new Detector(image);
+
+ var qRCodeMatrix = detector.detect();
+
+ if(qrcode.debug)
+ {
+ for (var y = 0; y < qRCodeMatrix.bits.Height; y++)
+ {
+ for (var x = 0; x < qRCodeMatrix.bits.Width; x++)
+ {
+ var point = (x * 4*2) + (y*2 * qrcode.width * 4);
+ qrcode.imagedata.data[point] = qRCodeMatrix.bits.get_Renamed(x,y)?0:0;
+ qrcode.imagedata.data[point+1] = qRCodeMatrix.bits.get_Renamed(x,y)?0:0;
+ qrcode.imagedata.data[point+2] = qRCodeMatrix.bits.get_Renamed(x,y)?255:0;
+ }
+ }
+ ctx.putImageData(qrcode.imagedata, 0, 0);
+ }
+
+
+ var reader = Decoder.decode(qRCodeMatrix.bits);
+ var data = reader.DataByte;
+ var str="";
+ for(var i=0;i minmax[ax][ay][1])
+ minmax[ax][ay][1] = target;
+ }
+ }
+ //minmax[ax][ay][0] = (minmax[ax][ay][0] + minmax[ax][ay][1]) / 2;
+ }
+ }
+ var middle = new Array(numSqrtArea);
+ for (var i3 = 0; i3 < numSqrtArea; i3++)
+ {
+ middle[i3] = new Array(numSqrtArea);
+ }
+ for (var ay = 0; ay < numSqrtArea; ay++)
+ {
+ for (var ax = 0; ax < numSqrtArea; ax++)
+ {
+ middle[ax][ay] = Math.floor((minmax[ax][ay][0] + minmax[ax][ay][1]) / 2);
+ //Console.out.print(middle[ax][ay] + ",");
+ }
+ //Console.out.println("");
+ }
+ //Console.out.println("");
+
+ return middle;
+}
+
+qrcode.grayScaleToBitmap=function(grayScale)
+{
+ var middle = qrcode.getMiddleBrightnessPerArea(grayScale);
+ var sqrtNumArea = middle.length;
+ var areaWidth = Math.floor(qrcode.width / sqrtNumArea);
+ var areaHeight = Math.floor(qrcode.height / sqrtNumArea);
+
+ var buff = new ArrayBuffer(qrcode.width*qrcode.height);
+ var bitmap = new Uint8Array(buff);
+
+ //var bitmap = new Array(qrcode.height*qrcode.width);
+
+ for (var ay = 0; ay < sqrtNumArea; ay++)
+ {
+ for (var ax = 0; ax < sqrtNumArea; ax++)
+ {
+ for (var dy = 0; dy < areaHeight; dy++)
+ {
+ for (var dx = 0; dx < areaWidth; dx++)
+ {
+ bitmap[areaWidth * ax + dx+ (areaHeight * ay + dy)*qrcode.width] = (grayScale[areaWidth * ax + dx+ (areaHeight * ay + dy)*qrcode.width] < middle[ax][ay])?true:false;
+ }
+ }
+ }
+ }
+ return bitmap;
+}
+
+qrcode.grayscale = function()
+{
+ var buff = new ArrayBuffer(qrcode.width*qrcode.height);
+ var ret = new Uint8Array(buff);
+ //var ret = new Array(qrcode.width*qrcode.height);
+
+ for (var y = 0; y < qrcode.height; y++)
+ {
+ for (var x = 0; x < qrcode.width; x++)
+ {
+ var gray = qrcode.getPixel(x, y);
+
+ ret[x+y*qrcode.width] = gray;
+ }
+ }
+ return ret;
+}
+
+
+
+
+function URShift( number, bits)
+{
+ if (number >= 0)
+ return number >> bits;
+ else
+ return (number >> bits) + (2 << ~bits);
+}
+
diff --git a/js/jsqrcode/rsdecoder.js b/js/jsqrcode/rsdecoder.js
index 640769a..c110c43 100644
--- a/js/jsqrcode/rsdecoder.js
+++ b/js/jsqrcode/rsdecoder.js
@@ -36,9 +36,9 @@ function ReedSolomonDecoder(field)
for (var i = 0; i < twoS; i++)
{
// Thanks to sanfordsquires for this fix:
- var eval = poly.evaluateAt(this.field.exp(dataMatrix?i + 1:i));
- syndromeCoefficients[syndromeCoefficients.length - 1 - i] = eval;
- if (eval != 0)
+ var evalu = poly.evaluateAt(this.field.exp(dataMatrix?i + 1:i));
+ syndromeCoefficients[syndromeCoefficients.length - 1 - i] = evalu;
+ if (evalu != 0)
{
noError = false;
}
diff --git a/js/jsqrcode/version.js b/js/jsqrcode/version.js
index c395a3b..4e19c7f 100644
--- a/js/jsqrcode/version.js
+++ b/js/jsqrcode/version.js
@@ -1,278 +1,261 @@
-/*
- Ported to JavaScript by Lazar Laszlo 2011
-
- lazarsoft@gmail.com, www.lazarsoft.info
-
-*/
-
-/*
-*
-* Copyright 2007 ZXing authors
-*
-* 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.
-*/
-
-
-
-function ECB(count, dataCodewords)
-{
- this.count = count;
- this.dataCodewords = dataCodewords;
-
- Object.defineProperties(this, {
- 'Count': {
- get: function () {
- return this.count;
- }
- },
-
- 'DataCodewords': {
- get: function () {
- return this.dataCodewords;
- }
- }
- });
-}
-
-function ECBlocks( ecCodewordsPerBlock, ecBlocks1, ecBlocks2)
-{
- this.ecCodewordsPerBlock = ecCodewordsPerBlock;
-
- if (ecBlocks2)
- this.ecBlocks = new Array(ecBlocks1, ecBlocks2);
- else
- this.ecBlocks = new Array(ecBlocks1);
-
- Object.defineProperties(this, {
- "ECCodewordsPerBlock": {
- get: function () {
- return this.ecCodewordsPerBlock;
-
- }
- },
-
- "TotalECCodewords": {
- get: function () {
- return this.ecCodewordsPerBlock * this.NumBlocks;
- }
- },
-
- "NumBlocks": {
- get: function () {
- var total = 0;
-
- for (var i = 0; i < this.ecBlocks.length; i++)
- total += this.ecBlocks[i].length;
-
- return total;
- }
- }
- });
-
- this.getECBlocks = function() {
- return this.ecBlocks;
- };
-}
-
-function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4)
-{
- this.versionNumber = versionNumber;
- this.alignmentPatternCenters = alignmentPatternCenters;
- this.ecBlocks = new Array(ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4);
-
- var total = 0;
- var ecCodewords = ecBlocks1.ECCodewordsPerBlock;
- var ecbArray = ecBlocks1.getECBlocks();
- for (var i = 0; i < ecbArray.length; i++)
- {
- var ecBlock = ecbArray[i];
- total += ecBlock.Count * (ecBlock.DataCodewords + ecCodewords);
- }
- this.totalCodewords = total;
-
- Object.defineProperties(this, {
- "VersionNumber": {
- get: function () {
- return this.versionNumber;
- }
- },
-
- "AlignmentPatternCenters": {
- get: function () {
- return this.alignmentPatternCenters;
- }
- },
- "TotalCodewords": {
- get: function () {
- return this.totalCodewords;
- }
- },
- "DimensionForVersion": {
- get: function () {
- return 17 + 4 * this.versionNumber;
- }
- }
- });
-
- this.buildFunctionPattern=function()
- {
- var dimension = this.DimensionForVersion;
- var bitMatrix = new BitMatrix(dimension);
-
- // Top left finder pattern + separator + format
- bitMatrix.setRegion(0, 0, 9, 9);
- // Top right finder pattern + separator + format
- bitMatrix.setRegion(dimension - 8, 0, 8, 9);
- // Bottom left finder pattern + separator + format
- bitMatrix.setRegion(0, dimension - 8, 9, 8);
-
- // Alignment patterns
- var max = this.alignmentPatternCenters.length;
- for (var x = 0; x < max; x++)
- {
- var i = this.alignmentPatternCenters[x] - 2;
- for (var y = 0; y < max; y++)
- {
- if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0))
- {
- // No alignment patterns near the three finder paterns
- continue;
- }
- bitMatrix.setRegion(this.alignmentPatternCenters[y] - 2, i, 5, 5);
- }
- }
-
- // Vertical timing pattern
- bitMatrix.setRegion(6, 9, 1, dimension - 17);
- // Horizontal timing pattern
- bitMatrix.setRegion(9, 6, dimension - 17, 1);
-
- if (this.versionNumber > 6)
- {
- // Version info, top right
- bitMatrix.setRegion(dimension - 11, 0, 3, 6);
- // Version info, bottom left
- bitMatrix.setRegion(0, dimension - 11, 6, 3);
- }
-
- return bitMatrix;
- }
- this.getECBlocksForLevel=function( ecLevel)
- {
- return this.ecBlocks[ecLevel.ordinal()];
- }
-}
-
-Version.VERSION_DECODE_INFO = new Array(0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, 0x2542E, 0x26A64, 0x27541, 0x28C69);
-
-Version.VERSIONS = buildVersions();
-
-Version.getVersionForNumber=function( versionNumber)
-{
- if (versionNumber < 1 || versionNumber > 40)
- {
- throw "ArgumentException";
- }
- return Version.VERSIONS[versionNumber - 1];
-}
-
-Version.getProvisionalVersionForDimension=function(dimension)
-{
- if (dimension % 4 != 1)
- {
- throw "Error getProvisionalVersionForDimension";
- }
- try
- {
- return Version.getVersionForNumber((dimension - 17) >> 2);
- }
- catch ( iae)
- {
- throw "Error getVersionForNumber";
- }
-}
-
-Version.decodeVersionInformation=function( versionBits)
-{
- var bestDifference = 0xffffffff;
- var bestVersion = 0;
- for (var i = 0; i < Version.VERSION_DECODE_INFO.length; i++)
- {
- var targetVersion = Version.VERSION_DECODE_INFO[i];
- // Do the version info bits match exactly? done.
- if (targetVersion == versionBits)
- {
- return this.getVersionForNumber(i + 7);
- }
- // Otherwise see if this is the closest to a real version info bit string
- // we have seen so far
- var bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion);
- if (bitsDifference < bestDifference)
- {
- bestVersion = i + 7;
- bestDifference = bitsDifference;
- }
- }
- // We can tolerate up to 3 bits of error since no two version info codewords will
- // differ in less than 4 bits.
- if (bestDifference <= 3)
- {
- return this.getVersionForNumber(bestVersion);
- }
- // If we didn't find a close enough match, fail
- return null;
-}
-
-function buildVersions()
-{
- return new Array(new Version(1, new Array(), new ECBlocks(7, new ECB(1, 19)), new ECBlocks(10, new ECB(1, 16)), new ECBlocks(13, new ECB(1, 13)), new ECBlocks(17, new ECB(1, 9))),
- new Version(2, new Array(6, 18), new ECBlocks(10, new ECB(1, 34)), new ECBlocks(16, new ECB(1, 28)), new ECBlocks(22, new ECB(1, 22)), new ECBlocks(28, new ECB(1, 16))),
- new Version(3, new Array(6, 22), new ECBlocks(15, new ECB(1, 55)), new ECBlocks(26, new ECB(1, 44)), new ECBlocks(18, new ECB(2, 17)), new ECBlocks(22, new ECB(2, 13))),
- new Version(4, new Array(6, 26), new ECBlocks(20, new ECB(1, 80)), new ECBlocks(18, new ECB(2, 32)), new ECBlocks(26, new ECB(2, 24)), new ECBlocks(16, new ECB(4, 9))),
- new Version(5, new Array(6, 30), new ECBlocks(26, new ECB(1, 108)), new ECBlocks(24, new ECB(2, 43)), new ECBlocks(18, new ECB(2, 15), new ECB(2, 16)), new ECBlocks(22, new ECB(2, 11), new ECB(2, 12))),
- new Version(6, new Array(6, 34), new ECBlocks(18, new ECB(2, 68)), new ECBlocks(16, new ECB(4, 27)), new ECBlocks(24, new ECB(4, 19)), new ECBlocks(28, new ECB(4, 15))),
- new Version(7, new Array(6, 22, 38), new ECBlocks(20, new ECB(2, 78)), new ECBlocks(18, new ECB(4, 31)), new ECBlocks(18, new ECB(2, 14), new ECB(4, 15)), new ECBlocks(26, new ECB(4, 13), new ECB(1, 14))),
- new Version(8, new Array(6, 24, 42), new ECBlocks(24, new ECB(2, 97)), new ECBlocks(22, new ECB(2, 38), new ECB(2, 39)), new ECBlocks(22, new ECB(4, 18), new ECB(2, 19)), new ECBlocks(26, new ECB(4, 14), new ECB(2, 15))),
- new Version(9, new Array(6, 26, 46), new ECBlocks(30, new ECB(2, 116)), new ECBlocks(22, new ECB(3, 36), new ECB(2, 37)), new ECBlocks(20, new ECB(4, 16), new ECB(4, 17)), new ECBlocks(24, new ECB(4, 12), new ECB(4, 13))),
- new Version(10, new Array(6, 28, 50), new ECBlocks(18, new ECB(2, 68), new ECB(2, 69)), new ECBlocks(26, new ECB(4, 43), new ECB(1, 44)), new ECBlocks(24, new ECB(6, 19), new ECB(2, 20)), new ECBlocks(28, new ECB(6, 15), new ECB(2, 16))),
- new Version(11, new Array(6, 30, 54), new ECBlocks(20, new ECB(4, 81)), new ECBlocks(30, new ECB(1, 50), new ECB(4, 51)), new ECBlocks(28, new ECB(4, 22), new ECB(4, 23)), new ECBlocks(24, new ECB(3, 12), new ECB(8, 13))),
- new Version(12, new Array(6, 32, 58), new ECBlocks(24, new ECB(2, 92), new ECB(2, 93)), new ECBlocks(22, new ECB(6, 36), new ECB(2, 37)), new ECBlocks(26, new ECB(4, 20), new ECB(6, 21)), new ECBlocks(28, new ECB(7, 14), new ECB(4, 15))),
- new Version(13, new Array(6, 34, 62), new ECBlocks(26, new ECB(4, 107)), new ECBlocks(22, new ECB(8, 37), new ECB(1, 38)), new ECBlocks(24, new ECB(8, 20), new ECB(4, 21)), new ECBlocks(22, new ECB(12, 11), new ECB(4, 12))),
- new Version(14, new Array(6, 26, 46, 66), new ECBlocks(30, new ECB(3, 115), new ECB(1, 116)), new ECBlocks(24, new ECB(4, 40), new ECB(5, 41)), new ECBlocks(20, new ECB(11, 16), new ECB(5, 17)), new ECBlocks(24, new ECB(11, 12), new ECB(5, 13))),
- new Version(15, new Array(6, 26, 48, 70), new ECBlocks(22, new ECB(5, 87), new ECB(1, 88)), new ECBlocks(24, new ECB(5, 41), new ECB(5, 42)), new ECBlocks(30, new ECB(5, 24), new ECB(7, 25)), new ECBlocks(24, new ECB(11, 12), new ECB(7, 13))),
- new Version(16, new Array(6, 26, 50, 74), new ECBlocks(24, new ECB(5, 98), new ECB(1, 99)), new ECBlocks(28, new ECB(7, 45), new ECB(3, 46)), new ECBlocks(24, new ECB(15, 19), new ECB(2, 20)), new ECBlocks(30, new ECB(3, 15), new ECB(13, 16))),
- new Version(17, new Array(6, 30, 54, 78), new ECBlocks(28, new ECB(1, 107), new ECB(5, 108)), new ECBlocks(28, new ECB(10, 46), new ECB(1, 47)), new ECBlocks(28, new ECB(1, 22), new ECB(15, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(17, 15))),
- new Version(18, new Array(6, 30, 56, 82), new ECBlocks(30, new ECB(5, 120), new ECB(1, 121)), new ECBlocks(26, new ECB(9, 43), new ECB(4, 44)), new ECBlocks(28, new ECB(17, 22), new ECB(1, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(19, 15))),
- new Version(19, new Array(6, 30, 58, 86), new ECBlocks(28, new ECB(3, 113), new ECB(4, 114)), new ECBlocks(26, new ECB(3, 44), new ECB(11, 45)), new ECBlocks(26, new ECB(17, 21), new ECB(4, 22)), new ECBlocks(26, new ECB(9, 13), new ECB(16, 14))),
- new Version(20, new Array(6, 34, 62, 90), new ECBlocks(28, new ECB(3, 107), new ECB(5, 108)), new ECBlocks(26, new ECB(3, 41), new ECB(13, 42)), new ECBlocks(30, new ECB(15, 24), new ECB(5, 25)), new ECBlocks(28, new ECB(15, 15), new ECB(10, 16))),
- new Version(21, new Array(6, 28, 50, 72, 94), new ECBlocks(28, new ECB(4, 116), new ECB(4, 117)), new ECBlocks(26, new ECB(17, 42)), new ECBlocks(28, new ECB(17, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(19, 16), new ECB(6, 17))),
- new Version(22, new Array(6, 26, 50, 74, 98), new ECBlocks(28, new ECB(2, 111), new ECB(7, 112)), new ECBlocks(28, new ECB(17, 46)), new ECBlocks(30, new ECB(7, 24), new ECB(16, 25)), new ECBlocks(24, new ECB(34, 13))),
- new Version(23, new Array(6, 30, 54, 74, 102), new ECBlocks(30, new ECB(4, 121), new ECB(5, 122)), new ECBlocks(28, new ECB(4, 47), new ECB(14, 48)), new ECBlocks(30, new ECB(11, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(16, 15), new ECB(14, 16))),
- new Version(24, new Array(6, 28, 54, 80, 106), new ECBlocks(30, new ECB(6, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(6, 45), new ECB(14, 46)), new ECBlocks(30, new ECB(11, 24), new ECB(16, 25)), new ECBlocks(30, new ECB(30, 16), new ECB(2, 17))),
- new Version(25, new Array(6, 32, 58, 84, 110), new ECBlocks(26, new ECB(8, 106), new ECB(4, 107)), new ECBlocks(28, new ECB(8, 47), new ECB(13, 48)), new ECBlocks(30, new ECB(7, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(22, 15), new ECB(13, 16))),
- new Version(26, new Array(6, 30, 58, 86, 114), new ECBlocks(28, new ECB(10, 114), new ECB(2, 115)), new ECBlocks(28, new ECB(19, 46), new ECB(4, 47)), new ECBlocks(28, new ECB(28, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(33, 16), new ECB(4, 17))),
- new Version(27, new Array(6, 34, 62, 90, 118), new ECBlocks(30, new ECB(8, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(22, 45), new ECB(3, 46)), new ECBlocks(30, new ECB(8, 23), new ECB(26, 24)), new ECBlocks(30, new ECB(12, 15), new ECB(28, 16))),
- new Version(28, new Array(6, 26, 50, 74, 98, 122), new ECBlocks(30, new ECB(3, 117), new ECB(10, 118)), new ECBlocks(28, new ECB(3, 45), new ECB(23, 46)), new ECBlocks(30, new ECB(4, 24), new ECB(31, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(31, 16))),
- new Version(29, new Array(6, 30, 54, 78, 102, 126), new ECBlocks(30, new ECB(7, 116), new ECB(7, 117)), new ECBlocks(28, new ECB(21, 45), new ECB(7, 46)), new ECBlocks(30, new ECB(1, 23), new ECB(37, 24)), new ECBlocks(30, new ECB(19, 15), new ECB(26, 16))),
- new Version(30, new Array(6, 26, 52, 78, 104, 130), new ECBlocks(30, new ECB(5, 115), new ECB(10, 116)), new ECBlocks(28, new ECB(19, 47), new ECB(10, 48)), new ECBlocks(30, new ECB(15, 24), new ECB(25, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(25, 16))),
- new Version(31, new Array(6, 30, 56, 82, 108, 134), new ECBlocks(30, new ECB(13, 115), new ECB(3, 116)), new ECBlocks(28, new ECB(2, 46), new ECB(29, 47)), new ECBlocks(30, new ECB(42, 24), new ECB(1, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(28, 16))),
- new Version(32, new Array(6, 34, 60, 86, 112, 138), new ECBlocks(30, new ECB(17, 115)), new ECBlocks(28, new ECB(10, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(10, 24), new ECB(35, 25)), new ECBlocks(30, new ECB(19, 15), new ECB(35, 16))),
- new Version(33, new Array(6, 30, 58, 86, 114, 142), new ECBlocks(30, new ECB(17, 115), new ECB(1, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(21, 47)), new ECBlocks(30, new ECB(29, 24), new ECB(19, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(46, 16))),
- new Version(34, new Array(6, 34, 62, 90, 118, 146), new ECBlocks(30, new ECB(13, 115), new ECB(6, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(44, 24), new ECB(7, 25)), new ECBlocks(30, new ECB(59, 16), new ECB(1, 17))),
- new Version(35, new Array(6, 30, 54, 78, 102, 126, 150), new ECBlocks(30, new ECB(12, 121), new ECB(7, 122)), new ECBlocks(28, new ECB(12, 47), new ECB(26, 48)), new ECBlocks(30, new ECB(39, 24), new ECB(14, 25)),new ECBlocks(30, new ECB(22, 15), new ECB(41, 16))),
- new Version(36, new Array(6, 24, 50, 76, 102, 128, 154), new ECBlocks(30, new ECB(6, 121), new ECB(14, 122)), new ECBlocks(28, new ECB(6, 47), new ECB(34, 48)), new ECBlocks(30, new ECB(46, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(2, 15), new ECB(64, 16))),
- new Version(37, new Array(6, 28, 54, 80, 106, 132, 158), new ECBlocks(30, new ECB(17, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(29, 46), new ECB(14, 47)), new ECBlocks(30, new ECB(49, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(24, 15), new ECB(46, 16))),
- new Version(38, new Array(6, 32, 58, 84, 110, 136, 162), new ECBlocks(30, new ECB(4, 122), new ECB(18, 123)), new ECBlocks(28, new ECB(13, 46), new ECB(32, 47)), new ECBlocks(30, new ECB(48, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(42, 15), new ECB(32, 16))),
- new Version(39, new Array(6, 26, 54, 82, 110, 138, 166), new ECBlocks(30, new ECB(20, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(40, 47), new ECB(7, 48)), new ECBlocks(30, new ECB(43, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(10, 15), new ECB(67, 16))),
- new Version(40, new Array(6, 30, 58, 86, 114, 142, 170), new ECBlocks(30, new ECB(19, 118), new ECB(6, 119)), new ECBlocks(28, new ECB(18, 47), new ECB(31, 48)), new ECBlocks(30, new ECB(34, 24), new ECB(34, 25)), new ECBlocks(30, new ECB(20, 15), new ECB(61, 16))));
-}
+/*
+ Ported to JavaScript by Lazar Laszlo 2011
+
+ lazarsoft@gmail.com, www.lazarsoft.info
+
+*/
+
+/*
+*
+* Copyright 2007 ZXing authors
+*
+* 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.
+*/
+
+
+
+function ECB(count, dataCodewords)
+{
+ this.count = count;
+ this.dataCodewords = dataCodewords;
+
+ this.__defineGetter__("Count", function()
+ {
+ return this.count;
+ });
+ this.__defineGetter__("DataCodewords", function()
+ {
+ return this.dataCodewords;
+ });
+}
+
+function ECBlocks( ecCodewordsPerBlock, ecBlocks1, ecBlocks2)
+{
+ this.ecCodewordsPerBlock = ecCodewordsPerBlock;
+ if(ecBlocks2)
+ this.ecBlocks = new Array(ecBlocks1, ecBlocks2);
+ else
+ this.ecBlocks = new Array(ecBlocks1);
+
+ this.__defineGetter__("ECCodewordsPerBlock", function()
+ {
+ return this.ecCodewordsPerBlock;
+ });
+
+ this.__defineGetter__("TotalECCodewords", function()
+ {
+ return this.ecCodewordsPerBlock * this.NumBlocks;
+ });
+
+ this.__defineGetter__("NumBlocks", function()
+ {
+ var total = 0;
+ for (var i = 0; i < this.ecBlocks.length; i++)
+ {
+ total += this.ecBlocks[i].length;
+ }
+ return total;
+ });
+
+ this.getECBlocks=function()
+ {
+ return this.ecBlocks;
+ }
+}
+
+function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4)
+{
+ this.versionNumber = versionNumber;
+ this.alignmentPatternCenters = alignmentPatternCenters;
+ this.ecBlocks = new Array(ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4);
+
+ var total = 0;
+ var ecCodewords = ecBlocks1.ECCodewordsPerBlock;
+ var ecbArray = ecBlocks1.getECBlocks();
+ for (var i = 0; i < ecbArray.length; i++)
+ {
+ var ecBlock = ecbArray[i];
+ total += ecBlock.Count * (ecBlock.DataCodewords + ecCodewords);
+ }
+ this.totalCodewords = total;
+
+ this.__defineGetter__("VersionNumber", function()
+ {
+ return this.versionNumber;
+ });
+
+ this.__defineGetter__("AlignmentPatternCenters", function()
+ {
+ return this.alignmentPatternCenters;
+ });
+ this.__defineGetter__("TotalCodewords", function()
+ {
+ return this.totalCodewords;
+ });
+ this.__defineGetter__("DimensionForVersion", function()
+ {
+ return 17 + 4 * this.versionNumber;
+ });
+
+ this.buildFunctionPattern=function()
+ {
+ var dimension = this.DimensionForVersion;
+ var bitMatrix = new BitMatrix(dimension);
+
+ // Top left finder pattern + separator + format
+ bitMatrix.setRegion(0, 0, 9, 9);
+ // Top right finder pattern + separator + format
+ bitMatrix.setRegion(dimension - 8, 0, 8, 9);
+ // Bottom left finder pattern + separator + format
+ bitMatrix.setRegion(0, dimension - 8, 9, 8);
+
+ // Alignment patterns
+ var max = this.alignmentPatternCenters.length;
+ for (var x = 0; x < max; x++)
+ {
+ var i = this.alignmentPatternCenters[x] - 2;
+ for (var y = 0; y < max; y++)
+ {
+ if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0))
+ {
+ // No alignment patterns near the three finder paterns
+ continue;
+ }
+ bitMatrix.setRegion(this.alignmentPatternCenters[y] - 2, i, 5, 5);
+ }
+ }
+
+ // Vertical timing pattern
+ bitMatrix.setRegion(6, 9, 1, dimension - 17);
+ // Horizontal timing pattern
+ bitMatrix.setRegion(9, 6, dimension - 17, 1);
+
+ if (this.versionNumber > 6)
+ {
+ // Version info, top right
+ bitMatrix.setRegion(dimension - 11, 0, 3, 6);
+ // Version info, bottom left
+ bitMatrix.setRegion(0, dimension - 11, 6, 3);
+ }
+
+ return bitMatrix;
+ }
+ this.getECBlocksForLevel=function( ecLevel)
+ {
+ return this.ecBlocks[ecLevel.ordinal()];
+ }
+}
+
+Version.VERSION_DECODE_INFO = new Array(0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, 0x2542E, 0x26A64, 0x27541, 0x28C69);
+
+Version.VERSIONS = buildVersions();
+
+Version.getVersionForNumber=function( versionNumber)
+{
+ if (versionNumber < 1 || versionNumber > 40)
+ {
+ throw "ArgumentException";
+ }
+ return Version.VERSIONS[versionNumber - 1];
+}
+
+Version.getProvisionalVersionForDimension=function(dimension)
+{
+ if (dimension % 4 != 1)
+ {
+ throw "Error getProvisionalVersionForDimension";
+ }
+ try
+ {
+ return Version.getVersionForNumber((dimension - 17) >> 2);
+ }
+ catch ( iae)
+ {
+ throw "Error getVersionForNumber";
+ }
+}
+
+Version.decodeVersionInformation=function( versionBits)
+{
+ var bestDifference = 0xffffffff;
+ var bestVersion = 0;
+ for (var i = 0; i < Version.VERSION_DECODE_INFO.length; i++)
+ {
+ var targetVersion = Version.VERSION_DECODE_INFO[i];
+ // Do the version info bits match exactly? done.
+ if (targetVersion == versionBits)
+ {
+ return this.getVersionForNumber(i + 7);
+ }
+ // Otherwise see if this is the closest to a real version info bit string
+ // we have seen so far
+ var bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion);
+ if (bitsDifference < bestDifference)
+ {
+ bestVersion = i + 7;
+ bestDifference = bitsDifference;
+ }
+ }
+ // We can tolerate up to 3 bits of error since no two version info codewords will
+ // differ in less than 4 bits.
+ if (bestDifference <= 3)
+ {
+ return this.getVersionForNumber(bestVersion);
+ }
+ // If we didn't find a close enough match, fail
+ return null;
+}
+
+function buildVersions()
+{
+ return new Array(new Version(1, new Array(), new ECBlocks(7, new ECB(1, 19)), new ECBlocks(10, new ECB(1, 16)), new ECBlocks(13, new ECB(1, 13)), new ECBlocks(17, new ECB(1, 9))),
+ new Version(2, new Array(6, 18), new ECBlocks(10, new ECB(1, 34)), new ECBlocks(16, new ECB(1, 28)), new ECBlocks(22, new ECB(1, 22)), new ECBlocks(28, new ECB(1, 16))),
+ new Version(3, new Array(6, 22), new ECBlocks(15, new ECB(1, 55)), new ECBlocks(26, new ECB(1, 44)), new ECBlocks(18, new ECB(2, 17)), new ECBlocks(22, new ECB(2, 13))),
+ new Version(4, new Array(6, 26), new ECBlocks(20, new ECB(1, 80)), new ECBlocks(18, new ECB(2, 32)), new ECBlocks(26, new ECB(2, 24)), new ECBlocks(16, new ECB(4, 9))),
+ new Version(5, new Array(6, 30), new ECBlocks(26, new ECB(1, 108)), new ECBlocks(24, new ECB(2, 43)), new ECBlocks(18, new ECB(2, 15), new ECB(2, 16)), new ECBlocks(22, new ECB(2, 11), new ECB(2, 12))),
+ new Version(6, new Array(6, 34), new ECBlocks(18, new ECB(2, 68)), new ECBlocks(16, new ECB(4, 27)), new ECBlocks(24, new ECB(4, 19)), new ECBlocks(28, new ECB(4, 15))),
+ new Version(7, new Array(6, 22, 38), new ECBlocks(20, new ECB(2, 78)), new ECBlocks(18, new ECB(4, 31)), new ECBlocks(18, new ECB(2, 14), new ECB(4, 15)), new ECBlocks(26, new ECB(4, 13), new ECB(1, 14))),
+ new Version(8, new Array(6, 24, 42), new ECBlocks(24, new ECB(2, 97)), new ECBlocks(22, new ECB(2, 38), new ECB(2, 39)), new ECBlocks(22, new ECB(4, 18), new ECB(2, 19)), new ECBlocks(26, new ECB(4, 14), new ECB(2, 15))),
+ new Version(9, new Array(6, 26, 46), new ECBlocks(30, new ECB(2, 116)), new ECBlocks(22, new ECB(3, 36), new ECB(2, 37)), new ECBlocks(20, new ECB(4, 16), new ECB(4, 17)), new ECBlocks(24, new ECB(4, 12), new ECB(4, 13))),
+ new Version(10, new Array(6, 28, 50), new ECBlocks(18, new ECB(2, 68), new ECB(2, 69)), new ECBlocks(26, new ECB(4, 43), new ECB(1, 44)), new ECBlocks(24, new ECB(6, 19), new ECB(2, 20)), new ECBlocks(28, new ECB(6, 15), new ECB(2, 16))),
+ new Version(11, new Array(6, 30, 54), new ECBlocks(20, new ECB(4, 81)), new ECBlocks(30, new ECB(1, 50), new ECB(4, 51)), new ECBlocks(28, new ECB(4, 22), new ECB(4, 23)), new ECBlocks(24, new ECB(3, 12), new ECB(8, 13))),
+ new Version(12, new Array(6, 32, 58), new ECBlocks(24, new ECB(2, 92), new ECB(2, 93)), new ECBlocks(22, new ECB(6, 36), new ECB(2, 37)), new ECBlocks(26, new ECB(4, 20), new ECB(6, 21)), new ECBlocks(28, new ECB(7, 14), new ECB(4, 15))),
+ new Version(13, new Array(6, 34, 62), new ECBlocks(26, new ECB(4, 107)), new ECBlocks(22, new ECB(8, 37), new ECB(1, 38)), new ECBlocks(24, new ECB(8, 20), new ECB(4, 21)), new ECBlocks(22, new ECB(12, 11), new ECB(4, 12))),
+ new Version(14, new Array(6, 26, 46, 66), new ECBlocks(30, new ECB(3, 115), new ECB(1, 116)), new ECBlocks(24, new ECB(4, 40), new ECB(5, 41)), new ECBlocks(20, new ECB(11, 16), new ECB(5, 17)), new ECBlocks(24, new ECB(11, 12), new ECB(5, 13))),
+ new Version(15, new Array(6, 26, 48, 70), new ECBlocks(22, new ECB(5, 87), new ECB(1, 88)), new ECBlocks(24, new ECB(5, 41), new ECB(5, 42)), new ECBlocks(30, new ECB(5, 24), new ECB(7, 25)), new ECBlocks(24, new ECB(11, 12), new ECB(7, 13))),
+ new Version(16, new Array(6, 26, 50, 74), new ECBlocks(24, new ECB(5, 98), new ECB(1, 99)), new ECBlocks(28, new ECB(7, 45), new ECB(3, 46)), new ECBlocks(24, new ECB(15, 19), new ECB(2, 20)), new ECBlocks(30, new ECB(3, 15), new ECB(13, 16))),
+ new Version(17, new Array(6, 30, 54, 78), new ECBlocks(28, new ECB(1, 107), new ECB(5, 108)), new ECBlocks(28, new ECB(10, 46), new ECB(1, 47)), new ECBlocks(28, new ECB(1, 22), new ECB(15, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(17, 15))),
+ new Version(18, new Array(6, 30, 56, 82), new ECBlocks(30, new ECB(5, 120), new ECB(1, 121)), new ECBlocks(26, new ECB(9, 43), new ECB(4, 44)), new ECBlocks(28, new ECB(17, 22), new ECB(1, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(19, 15))),
+ new Version(19, new Array(6, 30, 58, 86), new ECBlocks(28, new ECB(3, 113), new ECB(4, 114)), new ECBlocks(26, new ECB(3, 44), new ECB(11, 45)), new ECBlocks(26, new ECB(17, 21), new ECB(4, 22)), new ECBlocks(26, new ECB(9, 13), new ECB(16, 14))),
+ new Version(20, new Array(6, 34, 62, 90), new ECBlocks(28, new ECB(3, 107), new ECB(5, 108)), new ECBlocks(26, new ECB(3, 41), new ECB(13, 42)), new ECBlocks(30, new ECB(15, 24), new ECB(5, 25)), new ECBlocks(28, new ECB(15, 15), new ECB(10, 16))),
+ new Version(21, new Array(6, 28, 50, 72, 94), new ECBlocks(28, new ECB(4, 116), new ECB(4, 117)), new ECBlocks(26, new ECB(17, 42)), new ECBlocks(28, new ECB(17, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(19, 16), new ECB(6, 17))),
+ new Version(22, new Array(6, 26, 50, 74, 98), new ECBlocks(28, new ECB(2, 111), new ECB(7, 112)), new ECBlocks(28, new ECB(17, 46)), new ECBlocks(30, new ECB(7, 24), new ECB(16, 25)), new ECBlocks(24, new ECB(34, 13))),
+ new Version(23, new Array(6, 30, 54, 74, 102), new ECBlocks(30, new ECB(4, 121), new ECB(5, 122)), new ECBlocks(28, new ECB(4, 47), new ECB(14, 48)), new ECBlocks(30, new ECB(11, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(16, 15), new ECB(14, 16))),
+ new Version(24, new Array(6, 28, 54, 80, 106), new ECBlocks(30, new ECB(6, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(6, 45), new ECB(14, 46)), new ECBlocks(30, new ECB(11, 24), new ECB(16, 25)), new ECBlocks(30, new ECB(30, 16), new ECB(2, 17))),
+ new Version(25, new Array(6, 32, 58, 84, 110), new ECBlocks(26, new ECB(8, 106), new ECB(4, 107)), new ECBlocks(28, new ECB(8, 47), new ECB(13, 48)), new ECBlocks(30, new ECB(7, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(22, 15), new ECB(13, 16))),
+ new Version(26, new Array(6, 30, 58, 86, 114), new ECBlocks(28, new ECB(10, 114), new ECB(2, 115)), new ECBlocks(28, new ECB(19, 46), new ECB(4, 47)), new ECBlocks(28, new ECB(28, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(33, 16), new ECB(4, 17))),
+ new Version(27, new Array(6, 34, 62, 90, 118), new ECBlocks(30, new ECB(8, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(22, 45), new ECB(3, 46)), new ECBlocks(30, new ECB(8, 23), new ECB(26, 24)), new ECBlocks(30, new ECB(12, 15), new ECB(28, 16))),
+ new Version(28, new Array(6, 26, 50, 74, 98, 122), new ECBlocks(30, new ECB(3, 117), new ECB(10, 118)), new ECBlocks(28, new ECB(3, 45), new ECB(23, 46)), new ECBlocks(30, new ECB(4, 24), new ECB(31, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(31, 16))),
+ new Version(29, new Array(6, 30, 54, 78, 102, 126), new ECBlocks(30, new ECB(7, 116), new ECB(7, 117)), new ECBlocks(28, new ECB(21, 45), new ECB(7, 46)), new ECBlocks(30, new ECB(1, 23), new ECB(37, 24)), new ECBlocks(30, new ECB(19, 15), new ECB(26, 16))),
+ new Version(30, new Array(6, 26, 52, 78, 104, 130), new ECBlocks(30, new ECB(5, 115), new ECB(10, 116)), new ECBlocks(28, new ECB(19, 47), new ECB(10, 48)), new ECBlocks(30, new ECB(15, 24), new ECB(25, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(25, 16))),
+ new Version(31, new Array(6, 30, 56, 82, 108, 134), new ECBlocks(30, new ECB(13, 115), new ECB(3, 116)), new ECBlocks(28, new ECB(2, 46), new ECB(29, 47)), new ECBlocks(30, new ECB(42, 24), new ECB(1, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(28, 16))),
+ new Version(32, new Array(6, 34, 60, 86, 112, 138), new ECBlocks(30, new ECB(17, 115)), new ECBlocks(28, new ECB(10, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(10, 24), new ECB(35, 25)), new ECBlocks(30, new ECB(19, 15), new ECB(35, 16))),
+ new Version(33, new Array(6, 30, 58, 86, 114, 142), new ECBlocks(30, new ECB(17, 115), new ECB(1, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(21, 47)), new ECBlocks(30, new ECB(29, 24), new ECB(19, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(46, 16))),
+ new Version(34, new Array(6, 34, 62, 90, 118, 146), new ECBlocks(30, new ECB(13, 115), new ECB(6, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(44, 24), new ECB(7, 25)), new ECBlocks(30, new ECB(59, 16), new ECB(1, 17))),
+ new Version(35, new Array(6, 30, 54, 78, 102, 126, 150), new ECBlocks(30, new ECB(12, 121), new ECB(7, 122)), new ECBlocks(28, new ECB(12, 47), new ECB(26, 48)), new ECBlocks(30, new ECB(39, 24), new ECB(14, 25)),new ECBlocks(30, new ECB(22, 15), new ECB(41, 16))),
+ new Version(36, new Array(6, 24, 50, 76, 102, 128, 154), new ECBlocks(30, new ECB(6, 121), new ECB(14, 122)), new ECBlocks(28, new ECB(6, 47), new ECB(34, 48)), new ECBlocks(30, new ECB(46, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(2, 15), new ECB(64, 16))),
+ new Version(37, new Array(6, 28, 54, 80, 106, 132, 158), new ECBlocks(30, new ECB(17, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(29, 46), new ECB(14, 47)), new ECBlocks(30, new ECB(49, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(24, 15), new ECB(46, 16))),
+ new Version(38, new Array(6, 32, 58, 84, 110, 136, 162), new ECBlocks(30, new ECB(4, 122), new ECB(18, 123)), new ECBlocks(28, new ECB(13, 46), new ECB(32, 47)), new ECBlocks(30, new ECB(48, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(42, 15), new ECB(32, 16))),
+ new Version(39, new Array(6, 26, 54, 82, 110, 138, 166), new ECBlocks(30, new ECB(20, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(40, 47), new ECB(7, 48)), new ECBlocks(30, new ECB(43, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(10, 15), new ECB(67, 16))),
+ new Version(40, new Array(6, 30, 58, 86, 114, 142, 170), new ECBlocks(30, new ECB(19, 118), new ECB(6, 119)), new ECBlocks(28, new ECB(18, 47), new ECB(31, 48)), new ECBlocks(30, new ECB(34, 24), new ECB(34, 25)), new ECBlocks(30, new ECB(20, 15), new ECB(61, 16))));
+}
\ No newline at end of file
diff --git a/js/main.js b/js/main.js
index 5d1d0f5..01dd415 100644
--- a/js/main.js
+++ b/js/main.js
@@ -1,33 +1,42 @@
-var VERSION = '0.2.0';
-
-var qr_version = 1;
-var qr_pixel_size = 15;
-var qr_size = 17+(qr_version*4);
-
-var qr_array = [];
-var qr_format_array = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
-
-var active_painter = "0";
-var fill_painter = false;
-var toggle_painter = false;
-var dragging_painter = false;
-
-var changed_state = false;
-
-var show_grey = true;
-var brute_force_mode = false;
-var analysis_mode = false;
-
-var qr_temp_array = [];
-var qr_data_block = [];
-
-var is_data_module = [];
-
-var history_array = [];
-var active_history = -1;
-
+/*
+****************************************
+ GLOBAL VARIABLES
+****************************************
+*/
+
+var APP_VERSION = '0.3.3';
+
+var qr_version = 1; //Current QR version (1-9)
+var qr_pixel_size = 10; //Current view size of QR code (pixel per module)
+var qr_size = 17+(qr_version*4); //Current size of QR code
+
+var qr_array = []; //Main array to store QR data
+var qr_format_array = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; //Store QR format information
+
+var active_painter = "0"; //Current active painter tool (0,1,2)
+var fill_painter = false; //Is flood fill tool active?
+
+var changed_state = false; //Is document in changed state and not saved yet?
+
+var show_grey = true; //Show grey modules in Decode mode
+var brute_force_mode = false; //Is Brute-force Format Info active?
+var analysis_mode = false; //Is Data Analysis tool active?
+
+var qr_temp_array = []; //Temporary variable to handle qr_array duplicates
+var qr_data_block = []; //Array to store data block in "Data Analysis tool"
+
+var is_data_module = []; //Store data that separate between data module and fixed module (function pattern, alignment pattern, etc)
+
+var history_array = []; //Store history information and its qr_array data
+var active_history = -1; //Current active history
+
+/***
+*
+* generate QR table based on qr_array
+*
+***/
function generateTable(version){
qr_array = JSON.parse(JSON.stringify(qr_templates[version-1]));
changed_state = false;
@@ -57,6 +66,11 @@ function generateTable(version){
updateHistory("New QR code");
}
+/***
+*
+* get format information value
+*
+***/
function getInformation(size){
//Information top-left beside Finder
for(var i=0; i < 9; i++){
@@ -89,7 +103,11 @@ function getInformation(size){
}
}
-
+/***
+*
+* generate QR table in format information overlay dialog
+*
+***/
function generateInfoTable(position){
position = position || "TOP_LEFT";
@@ -134,7 +152,11 @@ function generateInfoTable(position){
}
-
+/***
+*
+* Save format information value to qr_format_array
+*
+***/
function saveInfoTable(size){
for(var i=0; i < 8; i++){
if(i > 5)
@@ -158,6 +180,11 @@ function saveInfoTable(size){
changed_state = true;
}
+/***
+*
+* Reload QR table based on qr_array value
+*
+***/
function refreshTable(){
for(var i=0; i < qr_array.length; i++){
for(var j=0; j < qr_array[i].length; j++){
@@ -174,6 +201,11 @@ function refreshTable(){
}
}
+/***
+*
+* Update qr_array from new array (exclude fixed pattern: function pattern, alignment pattern, timing, and version information)
+*
+***/
function updateQRArray(new_data){
for(var i=0; i < qr_array.length; i++){
for(var j=0; j < qr_array[i].length; j++){
@@ -182,8 +214,33 @@ function updateQRArray(new_data){
}
}
}
+
+ //update format information when using image upload
+ var size = qr_size;
+
+ for(var i=0; i < 8; i++){
+ if(i > 5)
+ qr_array[i+1][8] = new_data[i+1][8];
+ else
+ qr_array[i][8] = new_data[i][8];
+ qr_array[8][size-(i+1)] = new_data[8][size-(i+1)];
+ }
+ var index = 0;
+ for(var i=14; i >= 8; i--){
+ if(index > 5)
+ qr_array[8][index+1] = new_data[8][index+1];
+ else
+ qr_array[8][index] = new_data[8][index];;
+ qr_array[size-(index+1)][8] = new_data[size-(index+1)][8];;
+ index++;
+ }
}
+/***
+*
+* Get format information from format information overlay dialog
+*
+***/
function getInfoBits(){
var result = {ecc:"",mask:-1};
$("#slider-mask div.active").removeClass("active");
@@ -224,6 +281,11 @@ function getInfoBits(){
return result;
}
+/***
+*
+* generate QR code made from canvas based on qr_array values
+*
+***/
function generateResult(){
var c = document.getElementById("qr-result");
@@ -262,17 +324,32 @@ function generateResult(){
$("body").css("background-color","#FFFFFF");
}
+/***
+*
+* Update toolbox values
+*
+***/
function updateToolbox(){
$("#qr-version").val(qr_size+"x"+qr_size+" (ver. "+qr_version+")");
$("#qr-size").val(qr_pixel_size+"px");
}
+/***
+*
+* Resize QR size
+*
+***/
function resize(size){
$("td").each(function(){
$(this).css({"min-width":size+"px","min-height":size+"px","width":size+"px","height":size+"px"});
})
}
+/***
+*
+* Toggle between Editor and Decode mode
+*
+***/
function toggleResult(){
if(!$("#btn-switch-mode").hasClass("active")){
$(".mode-indicator button").removeClass("active");
@@ -313,6 +390,11 @@ function toggleResult(){
}
}
+/***
+*
+* Load image from file and put to {target}
+*
+***/
function loadImage(input, target){
if(input.files && input.files[0]){
var reader = new FileReader();
@@ -324,6 +406,11 @@ function loadImage(input, target){
}
}
+/***
+*
+* Save project to LocalStorage
+*
+***/
function saveProject(projectName){
if(projectName == ""){
@@ -354,6 +441,11 @@ function saveProject(projectName){
changed_state = false;
}
+/***
+*
+* Load project from LocalStorage
+*
+***/
function loadProject(name){
if(changed_state){
if(!confirm("Are you sure want to proceed?\nYour unsaved progress will be lost!"))
@@ -385,6 +477,11 @@ function loadProject(name){
updateHistory("Load project");
}
+/***
+*
+* Remove project from LocalStorage
+*
+***/
function removeProject(name, origin){
if(confirm("Are you sure want to permanently delete this project?")){
var dataList = JSON.parse(localStorage.getItem("dataList"));
@@ -404,6 +501,11 @@ function removeProject(name, origin){
}
}
+/***
+*
+* Refresh list of project in LocalStorage
+*
+***/
function refreshLoadList(origin){
var dataList = JSON.parse(localStorage.getItem("dataList"));
if(dataList == undefined){
@@ -417,6 +519,11 @@ function refreshLoadList(origin){
}
}
+/***
+*
+* Decode Base64 to image
+*
+***/
function decodeFromBase64(img, callback){
qrcode.callback = callback;
qrcode.decode(img, callback);
@@ -463,7 +570,7 @@ function importFromImage(src, cb){
var qrArray = qRCodeMatrix.bits.bits;
var size = qRCodeMatrix.bits.width;
- if(size > 41){
+ if(size > 53){
alert("QR version is unsupported");
return;
}
@@ -484,7 +591,14 @@ function importFromImage(src, cb){
img.src = src;
}
-//Reference : https://jsfiddle.net/eWxNE/2/
+
+/***
+*
+* Flood fill algorithm to perform paint-like bucket tool
+*
+* Reference : https://jsfiddle.net/eWxNE/2/
+*
+***/
function floodFill(x, y, oldVal, newVal){
x = parseInt(x);
@@ -517,6 +631,11 @@ function floodFill(x, y, oldVal, newVal){
}
}
+/***
+*
+* Update history
+*
+***/
function updateHistory(msg){
if(active_history < 10) active_history++;
@@ -538,6 +657,11 @@ function updateHistory(msg){
$(".history").html(html);
}
+/***
+*
+* Get history value and refresh QR table
+*
+***/
function getHistory(index){
qr_array = JSON.parse(history_array[index][1]);
if(qr_array.length != qr_size){
@@ -548,6 +672,11 @@ function getHistory(index){
refreshTable();
}
+/***
+*
+* Clear all history value
+*
+***/
function clearHistory(){
history_array = [];
active_history = -1;
@@ -691,6 +820,11 @@ function bruteForceFormatInfo(){
}
}
+/***
+*
+* Mask qr_array with mask_pattern and refresh QR table
+*
+***/
function maskDataBits(){
var mask_pattern = getFormatInfo(qr_array).mask;
qr_array = maskData(qr_array, mask_pattern);
@@ -787,9 +921,15 @@ function recoverPadding(){
qr_temp_array = Array.prototype.slice.call(result.result_array);
}
+/***
+*
+* Perform Reed-Solomon decode
+*
+***/
function reedSolomonDecode(data, nysm){
var result = [];
+ //console.log('nysm: '+nysm, 'data: '+data);
for(var i=0; i < data.length; i++){
var err_pos = [];
@@ -1155,6 +1295,12 @@ function updateBlock(value, cls){
}
+
+/*******************************************************************
+*
+* EVENT LISTENER USING JQUERY
+*
+********************************************************************/
$(document).ready(function(){
@@ -1308,7 +1454,7 @@ $(document).ready(function(){
$("#btn-version-plus").click(function(){
if(changed_state){
if(confirm("Are you sure want to proceed?\nYour unsaved progress will be lost!")){
- if(qr_version != 6){
+ if(qr_version != 9){
qr_version += 1;
qr_size = 17+(qr_version*4);
$("#qr-version").val(qr_size+"x"+qr_size+" (ver. "+qr_version+")");
@@ -1316,7 +1462,7 @@ $(document).ready(function(){
}
}
} else {
- if(qr_version != 6){
+ if(qr_version != 9){
qr_version += 1;
qr_size = 17+(qr_version*4);
$("#qr-version").val(qr_size+"x"+qr_size+" (ver. "+qr_version+")");
@@ -2048,7 +2194,7 @@ $(document).ready(function(){
}
})
- $("#txt-version").text('QRazyBox v'+VERSION);
+ $("#txt-version").text('QRazyBox v'+APP_VERSION);
$("#mobile-editor-mode, #mobile-decode-mode").click(function(){
toggleResult();
diff --git a/js/reedsolomon.js b/js/reedsolomon.js
index 92b9a7d..df2db0c 100644
--- a/js/reedsolomon.js
+++ b/js/reedsolomon.js
@@ -433,6 +433,8 @@ function rs_forney_syndromes(synd, pos, nmess){
function rs_correct_msg(msg_in, nysm, erase_pos){
+ console.log(msg_in);
+
erase_pos = erase_pos || undefined;
var msg_len = msg_in.length - nysm;
diff --git a/js/sqrd.js b/js/sqrd.js
index 41ca057..6a9fbf4 100644
--- a/js/sqrd.js
+++ b/js/sqrd.js
@@ -222,6 +222,19 @@ function getDataModule(data){
}
}
+ if(version >= 7){
+ for(var i=0; i < 6; i++){
+ for(var j=0; j < 3; j++){
+ is_data_module[i][(width)-11 + j] = false
+ }
+ }
+ for(var j=0; j < 6; j++){
+ for(var i=0; i < 3; i++){
+ is_data_module[(width)-11 + i][j] = false
+ }
+ }
+ }
+
return is_data_module;
}
@@ -905,7 +918,7 @@ function QRDecode(data){
//TODO: Kanji mode
break;
} else {
- console.log("[ERROR]: Invalid Encoding mode");
+ console.log("[ERROR]: Invalid Encoding mode", mode);
result.error.push("Invalid Encoding mode");
break;
}
diff --git a/js/table.js b/js/table.js
index e3b6fc8..4d2cb5e 100644
--- a/js/table.js
+++ b/js/table.js
@@ -3,7 +3,7 @@
*********************************************************************/
-//Pattern (bitmatrix) template for Function pattern and Format info
+//Pattern (bitmatri-1) template for Function pattern and Format info
var function_pattern_with_format_info = {
/*
0 : white
@@ -53,7 +53,10 @@ var alignment_pattern_array = [
[6, 22],
[6, 26],
[6, 30],
- [6, 34]
+ [6, 34],
+ [6, 22, 38],
+ [6, 24, 42],
+ [6, 26, 46]
];
var format_information_bits_raw = {
@@ -226,13 +229,23 @@ var format_information_unmask = [
'111111111111111'
];
+//Version information table for QR version 7 and higher
+var version_information_table = [
+ 000111110010010100,
+ 001000010110111100,
+ 001001101010011001
+]
+
var data_code_num_table = [
[ 16, 19, 9, 13],
[ 28, 34, 16, 22],
[ 44, 55, 26, 34],
[ 64, 80, 36, 48],
[ 86, 108, 46, 62],
- [ 108, 136, 60, 76]
+ [ 108, 136, 60, 76],
+ [ 124, 156, 66, 88],
+ [ 154, 194, 86, 110],
+ [ 182, 232, 100, 132]
];
var RS_block_num_table = [
@@ -241,7 +254,10 @@ var RS_block_num_table = [
[1, 1, 2, 2],
[2, 1, 4, 2],
[2, 1, 4, 4],
- [4, 2, 4, 4]
+ [4, 2, 4, 4],
+ [4, 2, 5, 6],
+ [4, 2, 6, 6],
+ [5, 2, 8, 8]
];
var alphanumeric_table = [
@@ -261,14 +277,17 @@ var error_correction_code_table = [
[26,15,22,18],
[18,20,16,26],
[24,26,22,18],
- [16,18,28,24]
+ [16,18,28,24],
+ [18,20,26,18],
+ [22,24,26,22],
+ [22,30,24,20]
];
-var remainder_bits_table = [0,7,7,7,7,7];
+var remainder_bits_table = [0,7,7,7,7,7,0,0,0];
/************************************************************
- Pre-defined QR matrix template for faster computing
+ Pre-defined QR matri-1 template for faster computing
0 : white
1 : black
@@ -277,6 +296,9 @@ var remainder_bits_table = [0,7,7,7,7,7];
*************************************************************/
var qr_templates = [
[
+ /****************
+ VERSION 1
+ ****************/
[1,1,1,1,1,1,1,0,0,-1,-1,-1,-1,0,1,1,1,1,1,1,1],
[1,0,0,0,0,0,1,0,0,-1,-1,-1,-1,0,1,0,0,0,0,0,1],
[1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,0,1,0,1,1,1,0,1],
@@ -301,6 +323,9 @@ var qr_templates = [
],
[
+ /****************
+ VERSION 2
+ ****************/
[1,1,1,1,1,1,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,0,1,1,1,1,1,1,1],
[1,0,0,0,0,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,0,1,0,0,0,0,0,1],
[1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,0,1,0,1,1,1,0,1],
@@ -329,6 +354,9 @@ var qr_templates = [
],
[
+ /****************
+ VERSION 3
+ ****************/
[1,1,1,1,1,1,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,1,1,1,1,1,1],
[1,0,0,0,0,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,0,0,0,0,0,1],
[1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,0,1,1,1,0,1],
@@ -361,6 +389,9 @@ var qr_templates = [
],
[
+ /****************
+ VERSION 4
+ ****************/
[1,1,1,1,1,1,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,1,1,1,1,1,1],
[1,0,0,0,0,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,0,0,0,0,0,1],
[1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,0,1,1,1,0,1],
@@ -397,6 +428,9 @@ var qr_templates = [
],
[
+ /****************
+ VERSION 5
+ ****************/
[1,1,1,1,1,1,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,1,1,1,1,1,1],
[1,0,0,0,0,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,0,0,0,0,0,1],
[1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,0,1,1,1,0,1],
@@ -437,6 +471,9 @@ var qr_templates = [
],
[
+ /****************
+ VERSION 6
+ ****************/
[1,1,1,1,1,1,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,1,1,1,1,1,1],
[1,0,0,0,0,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,0,0,0,0,0,1],
[1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,0,1,1,1,0,1],
@@ -478,5 +515,170 @@ var qr_templates = [
[1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],
[1,0,0,0,0,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,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-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1],
+ [1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],
+ [1,0,1,1,1,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],
+ [1,0,0,0,0,0,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],
+ [1,1,1,1,1,1,1,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
]
];
\ No newline at end of file
diff --git a/sample/PragyanCTF18-QuickResponse.png b/sample/PragyanCTF18-QuickResponse.png
new file mode 100644
index 0000000..cf19f07
Binary files /dev/null and b/sample/PragyanCTF18-QuickResponse.png differ
diff --git a/sample/qr-v7-damaged.png b/sample/qr-v7-damaged.png
new file mode 100644
index 0000000..2900327
Binary files /dev/null and b/sample/qr-v7-damaged.png differ