Update support for QR version 7 to 9

This commit is contained in:
Merricx 2018-05-11 03:30:12 +07:00
parent a521c5b30a
commit ce2de974bd
23 changed files with 3297 additions and 2815 deletions

View file

@ -89,7 +89,7 @@
</div> </div>
<div class="clear"></div> <div class="clear"></div>
<h5>Module Size :</h5> <h5>Module Size :</h5>
<input id="qr-size" type="text" readonly value="15px"> <input id="qr-size" type="text" readonly value="10px">
<div class="toolbox"> <div class="toolbox">
<div id="btn-size-min" class="minus"><img src="img/minus.png"></div> <div id="btn-size-min" class="minus"><img src="img/minus.png"></div>
<div id="btn-size-plus" class="plus"><img src="img/plus.png"></div> <div id="btn-size-plus" class="plus"><img src="img/plus.png"></div>
@ -329,7 +329,7 @@
<h3>QR Decoder</h3> <h3>QR Decoder</h3>
<div class="space"></div> <div class="space"></div>
<h5>Decoded Message : </h5> <h5>Decoded Message : </h5>
<input id="decode-message" type="text" readonly> <textarea id="decode-message" spellcheck="false" style="width: 100%; margin: 0;" readonly></textarea>
<div class="clear"></div> <div class="clear"></div>
<div id="div-decode-error" class="hide"> <div id="div-decode-error" class="hide">
<h5>Error : </h5> <h5>Error : </h5>

View file

@ -1,289 +1,279 @@
/* /*
Ported to JavaScript by Lazar Laszlo 2011 Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info lazarsoft@gmail.com, www.lazarsoft.info
*/ */
/* /*
* *
* Copyright 2007 ZXing authors * Copyright 2007 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
function AlignmentPattern(posX, posY, estimatedModuleSize) function AlignmentPattern(posX, posY, estimatedModuleSize)
{ {
this.x=posX; this.x=posX;
this.y=posY; this.y=posY;
this.count = 1; this.count = 1;
this.estimatedModuleSize = estimatedModuleSize; this.estimatedModuleSize = estimatedModuleSize;
Object.defineProperties(this, { this.__defineGetter__("EstimatedModuleSize", function()
'EstimatedModuleSize': { {
get: function () { return this.estimatedModuleSize;
return this.estimatedModuleSize; });
} this.__defineGetter__("Count", function()
}, {
return this.count;
"Count": { });
get: function() { this.__defineGetter__("X", function()
return this.count; {
} return Math.floor(this.x);
}, });
this.__defineGetter__("Y", function()
"X": { {
get: function() { return Math.floor(this.y);
return Math.floor(this.x); });
} this.incrementCount = function()
}, {
this.count++;
"Y": { }
get: function() { this.aboutEquals=function( moduleSize, i, j)
return Math.floor(this.y); {
} 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;
this.incrementCount = function() }
{ return false;
this.count++; }
}
this.aboutEquals=function( moduleSize, i, j) }
{
if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize) function AlignmentPatternFinder( image, startX, startY, width, height, moduleSize, resultPointCallback)
{ {
var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize); this.image = image;
return moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0; this.possibleCenters = new Array();
} this.startX = startX;
return false; this.startY = startY;
} this.width = width;
this.height = height;
} this.moduleSize = moduleSize;
this.crossCheckStateCount = new Array(0,0,0);
function AlignmentPatternFinder( image, startX, startY, width, height, moduleSize, resultPointCallback) this.resultPointCallback = resultPointCallback;
{
this.image = image; this.centerFromEnd=function(stateCount, end)
this.possibleCenters = new Array(); {
this.startX = startX; return (end - stateCount[2]) - stateCount[1] / 2.0;
this.startY = startY; }
this.width = width; this.foundPatternCross = function(stateCount)
this.height = height; {
this.moduleSize = moduleSize; var moduleSize = this.moduleSize;
this.crossCheckStateCount = new Array(0,0,0); var maxVariance = moduleSize / 2.0;
this.resultPointCallback = resultPointCallback; for (var i = 0; i < 3; i++)
{
this.centerFromEnd=function(stateCount, end) if (Math.abs(moduleSize - stateCount[i]) >= maxVariance)
{ {
return (end - stateCount[2]) - stateCount[1] / 2.0; return false;
} }
this.foundPatternCross = function(stateCount) }
{ return true;
var moduleSize = this.moduleSize; }
var maxVariance = moduleSize / 2.0;
for (var i = 0; i < 3; i++) this.crossCheckVertical=function( startI, centerJ, maxCount, originalStateCountTotal)
{ {
if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) var image = this.image;
{
return false; var maxI = qrcode.height;
} var stateCount = this.crossCheckStateCount;
} stateCount[0] = 0;
return true; stateCount[1] = 0;
} stateCount[2] = 0;
this.crossCheckVertical=function( startI, centerJ, maxCount, originalStateCountTotal) // Start counting up from center
{ var i = startI;
var image = this.image; while (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)
{
var maxI = qrcode.height; stateCount[1]++;
var stateCount = this.crossCheckStateCount; i--;
stateCount[0] = 0; }
stateCount[1] = 0; // If already too many modules in this state or ran off the edge:
stateCount[2] = 0; if (i < 0 || stateCount[1] > maxCount)
{
// Start counting up from center return NaN;
var i = startI; }
while (i >= 0 && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount) while (i >= 0 && !image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount)
{ {
stateCount[1]++; stateCount[0]++;
i--; i--;
} }
// If already too many modules in this state or ran off the edge: if (stateCount[0] > maxCount)
if (i < 0 || stateCount[1] > maxCount) {
{ return NaN;
return NaN; }
}
while (i >= 0 && !image[centerJ + i*qrcode.width] && stateCount[0] <= maxCount) // Now also count down from center
{ i = startI + 1;
stateCount[0]++; while (i < maxI && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount)
i--; {
} stateCount[1]++;
if (stateCount[0] > maxCount) i++;
{ }
return NaN; if (i == maxI || stateCount[1] > maxCount)
} {
return NaN;
// Now also count down from center }
i = startI + 1; while (i < maxI && !image[centerJ + i*qrcode.width] && stateCount[2] <= maxCount)
while (i < maxI && image[centerJ + i*qrcode.width] && stateCount[1] <= maxCount) {
{ stateCount[2]++;
stateCount[1]++; i++;
i++; }
} if (stateCount[2] > maxCount)
if (i == maxI || stateCount[1] > maxCount) {
{ return NaN;
return NaN; }
}
while (i < maxI && !image[centerJ + i*qrcode.width] && stateCount[2] <= maxCount) var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
{ if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal)
stateCount[2]++; {
i++; return NaN;
} }
if (stateCount[2] > maxCount)
{ return this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, i):NaN;
return NaN; }
}
this.handlePossibleCenter=function( stateCount, i, j)
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; {
if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
{ var centerJ = this.centerFromEnd(stateCount, j);
return NaN; var centerI = this.crossCheckVertical(i, Math.floor (centerJ), 2 * stateCount[1], stateCountTotal);
} if (!isNaN(centerI))
{
return this.foundPatternCross(stateCount)?this.centerFromEnd(stateCount, i):NaN; var estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0;
} var max = this.possibleCenters.length;
for (var index = 0; index < max; index++)
this.handlePossibleCenter=function( stateCount, i, j) {
{ var center = this.possibleCenters[index];
var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; // Look for about the same center and module size:
var centerJ = this.centerFromEnd(stateCount, j); if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
var centerI = this.crossCheckVertical(i, Math.floor (centerJ), 2 * stateCount[1], stateCountTotal); {
if (!isNaN(centerI)) return new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
{ }
var estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0; }
var max = this.possibleCenters.length; // Hadn't found this before; save it
for (var index = 0; index < max; index++) var point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
{ this.possibleCenters.push(point);
var center = this.possibleCenters[index]; if (this.resultPointCallback != null)
// Look for about the same center and module size: {
if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) this.resultPointCallback.foundPossibleResultPoint(point);
{ }
return new AlignmentPattern(centerJ, centerI, estimatedModuleSize); }
} return null;
} }
// Hadn't found this before; save it
var point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize); this.find = function()
this.possibleCenters.push(point); {
if (this.resultPointCallback != null) var startX = this.startX;
{ var height = this.height;
this.resultPointCallback.foundPossibleResultPoint(point); var maxJ = startX + width;
} var middleI = startY + (height >> 1);
} // We are looking for black/white/black modules in 1:1:1 ratio;
return null; // 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++)
this.find = function() {
{ // Search from middle outwards
var startX = this.startX; var i = middleI + ((iGen & 0x01) == 0?((iGen + 1) >> 1):- ((iGen + 1) >> 1));
var height = this.height; stateCount[0] = 0;
var maxJ = startX + width; stateCount[1] = 0;
var middleI = startY + (height >> 1); stateCount[2] = 0;
// We are looking for black/white/black modules in 1:1:1 ratio; var j = startX;
// this tracks the number of black/white/black modules seen so far // Burn off leading white pixels before anything else; if we start in the middle of
var stateCount = new Array(0,0,0); // a white run, it doesn't make sense to count its length, since we don't know if the
for (var iGen = 0; iGen < height; iGen++) // white run continued to the left of the start point
{ while (j < maxJ && !image[j + qrcode.width* i])
// Search from middle outwards {
var i = middleI + ((iGen & 0x01) == 0?((iGen + 1) >> 1):- ((iGen + 1) >> 1)); j++;
stateCount[0] = 0; }
stateCount[1] = 0; var currentState = 0;
stateCount[2] = 0; while (j < maxJ)
var j = startX; {
// Burn off leading white pixels before anything else; if we start in the middle of if (image[j + i*qrcode.width])
// 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 // Black pixel
while (j < maxJ && !image[j + qrcode.width* i]) if (currentState == 1)
{ {
j++; // Counting black pixels
} stateCount[currentState]++;
var currentState = 0; }
while (j < maxJ) else
{ {
if (image[j + i*qrcode.width]) // Counting white pixels
{ if (currentState == 2)
// Black pixel {
if (currentState == 1) // A winner?
{ if (this.foundPatternCross(stateCount))
// Counting black pixels {
stateCount[currentState]++; // Yes
} var confirmed = this.handlePossibleCenter(stateCount, i, j);
else if (confirmed != null)
{ {
// Counting white pixels return confirmed;
if (currentState == 2) }
{ }
// A winner? stateCount[0] = stateCount[2];
if (this.foundPatternCross(stateCount)) stateCount[1] = 1;
{ stateCount[2] = 0;
// Yes currentState = 1;
var confirmed = this.handlePossibleCenter(stateCount, i, j); }
if (confirmed != null) else
{ {
return confirmed; stateCount[++currentState]++;
} }
} }
stateCount[0] = stateCount[2]; }
stateCount[1] = 1; else
stateCount[2] = 0; {
currentState = 1; // White pixel
} if (currentState == 1)
else {
{ // Counting black pixels
stateCount[++currentState]++; currentState++;
} }
} stateCount[currentState]++;
} }
else j++;
{ }
// White pixel if (this.foundPatternCross(stateCount))
if (currentState == 1) {
{ var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
// Counting black pixels if (confirmed != null)
currentState++; {
} return confirmed;
stateCount[currentState]++; }
} }
j++; }
}
if (this.foundPatternCross(stateCount)) // Hmm, nothing we saw was observed and confirmed twice. If we had
{ // any guess at all, return it.
var confirmed = this.handlePossibleCenter(stateCount, i, maxJ); if (!(this.possibleCenters.length == 0))
if (confirmed != null) {
{ return this.possibleCenters[0];
return confirmed; }
}
} throw "Couldn't find enough alignment patterns";
} }
// 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";
}
}

View file

@ -1,119 +1,111 @@
/* /*
Ported to JavaScript by Lazar Laszlo 2011 Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info lazarsoft@gmail.com, www.lazarsoft.info
*/ */
/* /*
* *
* Copyright 2007 ZXing authors * Copyright 2007 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
function BitMatrix( width, height) function BitMatrix( width, height)
{ {
if(!height) if(!height)
height=width; height=width;
if (width < 1 || height < 1) if (width < 1 || height < 1)
{ {
throw "Both dimensions must be greater than 0"; throw "Both dimensions must be greater than 0";
} }
this.width = width; this.width = width;
this.height = height; this.height = height;
var rowSize = width >> 5; var rowSize = width >> 5;
if ((width & 0x1f) != 0) { if ((width & 0x1f) != 0)
rowSize++; {
} rowSize++;
}
this.rowSize = rowSize; this.rowSize = rowSize;
this.bits = new Array(rowSize * height); this.bits = new Array(rowSize * height);
for(var i=0;i<this.bits.length;i++)
for(var i=0;i<this.bits.length;i++) this.bits[i]=0;
this.bits[i]=0;
this.__defineGetter__("Width", function()
Object.defineProperties(this, { {
'Width': { return this.width;
get: function () { });
return this.width; this.__defineGetter__("Height", function()
} {
}, return this.height;
});
'Height': { this.__defineGetter__("Dimension", function()
get: function () { {
return this.height; if (this.width != this.height)
} {
}, throw "Can't call getDimension() on a non-square matrix";
}
'Dimension': { return this.width;
get: function () { });
if (this.width != this.height) {
throw "Can't call getDimension() on a non-square matrix"; this.get_Renamed=function( x, y)
} {
var offset = y * this.rowSize + (x >> 5);
return this.width; return ((URShift(this.bits[offset], (x & 0x1f))) & 1) != 0;
} }
} this.set_Renamed=function( x, y)
}); {
var offset = y * this.rowSize + (x >> 5);
this.get_Renamed=function( x, y) this.bits[offset] |= 1 << (x & 0x1f);
{ }
var offset = y * this.rowSize + (x >> 5); this.flip=function( x, y)
return ((URShift(this.bits[offset], (x & 0x1f))) & 1) != 0; {
} var offset = y * this.rowSize + (x >> 5);
this.set_Renamed=function( x, y) this.bits[offset] ^= 1 << (x & 0x1f);
{ }
var offset = y * this.rowSize + (x >> 5); this.clear=function()
this.bits[offset] |= 1 << (x & 0x1f); {
} var max = this.bits.length;
this.flip=function( x, y) for (var i = 0; i < max; i++)
{ {
var offset = y * this.rowSize + (x >> 5); this.bits[i] = 0;
this.bits[offset] ^= 1 << (x & 0x1f); }
} }
this.clear=function() this.setRegion=function( left, top, width, height)
{ {
var max = this.bits.length; if (top < 0 || left < 0)
for (var i = 0; i < max; i++) {
{ throw "Left and top must be nonnegative";
this.bits[i] = 0; }
} if (height < 1 || width < 1)
} {
this.setRegion=function( left, top, width, height) throw "Height and width must be at least 1";
{ }
if (top < 0 || left < 0) var right = left + width;
{ var bottom = top + height;
throw "Left and top must be nonnegative"; if (bottom > this.height || right > this.width)
} {
if (height < 1 || width < 1) throw "The region must fit inside the matrix";
{ }
throw "Height and width must be at least 1"; for (var y = top; y < bottom; y++)
} {
var right = left + width; var offset = y * this.rowSize;
var bottom = top + height; for (var x = left; x < right; x++)
if (bottom > this.height || right > this.width) {
{ this.bits[offset + (x >> 5)] |= 1 << (x & 0x1f);
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);
}
}
}
}

View file

@ -1,122 +1,117 @@
/* /*
Ported to JavaScript by Lazar Laszlo 2011 Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info lazarsoft@gmail.com, www.lazarsoft.info
*/ */
/* /*
* *
* Copyright 2007 ZXing authors * Copyright 2007 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
function DataBlock(numDataCodewords, codewords) function DataBlock(numDataCodewords, codewords)
{ {
this.numDataCodewords = numDataCodewords; this.numDataCodewords = numDataCodewords;
this.codewords = codewords; this.codewords = codewords;
Object.defineProperties(this, { this.__defineGetter__("NumDataCodewords", function()
'NumDataCodewords': { {
get: function () { return this.numDataCodewords;
return this.numDataCodewords; });
} this.__defineGetter__("Codewords", function()
}, {
return this.codewords;
'Codewords': { });
get: function () { }
return this.codewords;
} DataBlock.getDataBlocks=function(rawCodewords, version, ecLevel)
} {
});
} if (rawCodewords.length != version.TotalCodewords)
{
DataBlock.getDataBlocks=function(rawCodewords, version, ecLevel) throw "ArgumentException";
{ }
if (rawCodewords.length != version.TotalCodewords) // Figure out the number and size of data blocks used by this version and
{ // error correction level
throw "ArgumentException"; var ecBlocks = version.getECBlocksForLevel(ecLevel);
}
// First count the total number of data blocks
// Figure out the number and size of data blocks used by this version and var totalBlocks = 0;
// error correction level var ecBlockArray = ecBlocks.getECBlocks();
var ecBlocks = version.getECBlocksForLevel(ecLevel); for (var i = 0; i < ecBlockArray.length; i++)
{
// First count the total number of data blocks totalBlocks += ecBlockArray[i].Count;
var totalBlocks = 0; }
var ecBlockArray = ecBlocks.getECBlocks();
for (var i = 0; i < ecBlockArray.length; i++) // Now establish DataBlocks of the appropriate size and number of data codewords
{ var result = new Array(totalBlocks);
totalBlocks += ecBlockArray[i].Count; var numResultBlocks = 0;
} for (var j = 0; j < ecBlockArray.length; j++)
{
// Now establish DataBlocks of the appropriate size and number of data codewords var ecBlock = ecBlockArray[j];
var result = new Array(totalBlocks); for (var i = 0; i < ecBlock.Count; i++)
var numResultBlocks = 0; {
for (var j = 0; j < ecBlockArray.length; j++) var numDataCodewords = ecBlock.DataCodewords;
{ var numBlockCodewords = ecBlocks.ECCodewordsPerBlock + numDataCodewords;
var ecBlock = ecBlockArray[j]; result[numResultBlocks++] = new DataBlock(numDataCodewords, new Array(numBlockCodewords));
for (var i = 0; i < ecBlock.Count; i++) }
{ }
var numDataCodewords = ecBlock.DataCodewords;
var numBlockCodewords = ecBlocks.ECCodewordsPerBlock + numDataCodewords; // All blocks have the same amount of data, except that the last n
result[numResultBlocks++] = new DataBlock(numDataCodewords, new Array(numBlockCodewords)); // (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)
// 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 numCodewords = result[longerBlocksStartAt].codewords.length;
var shorterBlocksTotalCodewords = result[0].codewords.length; if (numCodewords == shorterBlocksTotalCodewords)
var longerBlocksStartAt = result.length - 1; {
while (longerBlocksStartAt >= 0) break;
{ }
var numCodewords = result[longerBlocksStartAt].codewords.length; longerBlocksStartAt--;
if (numCodewords == shorterBlocksTotalCodewords) }
{ longerBlocksStartAt++;
break;
} var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ECCodewordsPerBlock;
longerBlocksStartAt--; // The last elements of result may be 1 element longer;
} // first fill out as many elements as all of them have
longerBlocksStartAt++; var rawCodewordsOffset = 0;
for (var i = 0; i < shorterBlocksNumDataCodewords; i++)
var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ECCodewordsPerBlock; {
// The last elements of result may be 1 element longer; for (var j = 0; j < numResultBlocks; j++)
// first fill out as many elements as all of them have {
var rawCodewordsOffset = 0; result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
for (var i = 0; i < shorterBlocksNumDataCodewords; i++) }
{ }
for (var j = 0; j < numResultBlocks; j++) // Fill out the last data block in the longer ones
{ for (var j = longerBlocksStartAt; j < numResultBlocks; j++)
result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; {
} result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];
} }
// Fill out the last data block in the longer ones // Now add in error correction blocks
for (var j = longerBlocksStartAt; j < numResultBlocks; j++) var max = result[0].codewords.length;
{ for (var i = shorterBlocksNumDataCodewords; i < max; i++)
result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++]; {
} for (var j = 0; j < numResultBlocks; j++)
// Now add in error correction blocks {
var max = result[0].codewords.length; var iOffset = j < longerBlocksStartAt?i:i + 1;
for (var i = shorterBlocksNumDataCodewords; i < max; i++) result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
{ }
for (var j = 0; j < numResultBlocks; j++) }
{ return result;
var iOffset = j < longerBlocksStartAt?i:i + 1; }
result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
}
}
return result;
}

View file

@ -1,284 +1,337 @@
/* /*
Ported to JavaScript by Lazar Laszlo 2011 Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info lazarsoft@gmail.com, www.lazarsoft.info
*/ */
/* /*
* *
* Copyright 2007 ZXing authors * Copyright 2007 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
function QRCodeDataBlockReader (blocks, version, numErrorCorrectionCode) { function QRCodeDataBlockReader(blocks, version, numErrorCorrectionCode)
this.blockPointer = 0; {
this.bitPointer = 7; this.blockPointer = 0;
this.dataLength = 0; this.bitPointer = 7;
this.blocks = blocks; this.dataLength = 0;
this.numErrorCorrectionCode = numErrorCorrectionCode; this.blocks = blocks;
if (version <= 9) this.numErrorCorrectionCode = numErrorCorrectionCode;
this.dataLengthMode = 0; if (version <= 9)
else if (version >= 10 && version <= 26) this.dataLengthMode = 0;
this.dataLengthMode = 1; else if (version >= 10 && version <= 26)
else if (version >= 27 && version <= 40) this.dataLengthMode = 1;
this.dataLengthMode = 2; else if (version >= 27 && version <= 40)
this.dataLengthMode = 2;
this.getNextBits = function (numBits) {
var bits = 0; this.getNextBits = function( numBits)
{
if (numBits < this.bitPointer + 1) { var bits = 0;
// next word fits into current data block if (numBits < this.bitPointer + 1)
var mask = 0; {
for (var i = 0; i < numBits; i++) { // next word fits into current data block
mask += (1 << i); var mask = 0;
} for (var i = 0; i < numBits; i++)
mask <<= (this.bitPointer - numBits + 1); {
mask += (1 << i);
bits = (this.blocks[this.blockPointer] & mask) >> (this.bitPointer - numBits + 1); }
this.bitPointer -= numBits; mask <<= (this.bitPointer - numBits + 1);
return bits;
} else if (numBits < this.bitPointer + 1 + 8) { bits = (this.blocks[this.blockPointer] & mask) >> (this.bitPointer - numBits + 1);
// next word crosses 2 data blocks this.bitPointer -= numBits;
var mask1 = 0; return bits;
for (var i = 0; i < this.bitPointer + 1; i++) }
{ else if (numBits < this.bitPointer + 1 + 8)
mask1 += (1 << i); {
} // next word crosses 2 data blocks
bits = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1)); var mask1 = 0;
this.blockPointer++; for (var i = 0; i < this.bitPointer + 1; i++)
bits += ((this.blocks[this.blockPointer]) >> (8 - (numBits - (this.bitPointer + 1)))); {
mask1 += (1 << i);
this.bitPointer = this.bitPointer - numBits % 8; }
if (this.bitPointer < 0) bits = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));
{ this.blockPointer++;
this.bitPointer = 8 + this.bitPointer; bits += ((this.blocks[this.blockPointer]) >> (8 - (numBits - (this.bitPointer + 1))));
}
return bits; this.bitPointer = this.bitPointer - numBits % 8;
} else if (numBits < this.bitPointer + 1 + 16) { if (this.bitPointer < 0)
// next word crosses 3 data blocks {
var mask1 = 0; // mask of first block this.bitPointer = 8 + this.bitPointer;
var mask3 = 0; // mask of 3rd block }
//bitPointer + 1 : number of bits of the 1st block return bits;
//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 else if (numBits < this.bitPointer + 1 + 16)
for (var i = 0; i < this.bitPointer + 1; i++) {
{ // next word crosses 3 data blocks
mask1 += (1 << i); var mask1 = 0; // mask of first block
} var mask3 = 0; // mask of 3rd block
var bitsFirstBlock = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1)); //bitPointer + 1 : number of bits of the 1st block
this.blockPointer++; //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
var bitsSecondBlock = this.blocks[this.blockPointer] << (numBits - (this.bitPointer + 1 + 8)); for (var i = 0; i < this.bitPointer + 1; i++)
this.blockPointer++; {
mask1 += (1 << i);
for (var i = 0; i < numBits - (this.bitPointer + 1 + 8); i++) { }
mask3 += (1 << i); var bitsFirstBlock = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));
} this.blockPointer++;
mask3 <<= 8 - (numBits - (this.bitPointer + 1 + 8)); var bitsSecondBlock = this.blocks[this.blockPointer] << (numBits - (this.bitPointer + 1 + 8));
var bitsThirdBlock = (this.blocks[this.blockPointer] & mask3) >> (8 - (numBits - (this.bitPointer + 1 + 8))); this.blockPointer++;
bits = bitsFirstBlock + bitsSecondBlock + bitsThirdBlock; for (var i = 0; i < numBits - (this.bitPointer + 1 + 8); i++)
this.bitPointer = this.bitPointer - (numBits - 8) % 8; {
if (this.bitPointer < 0) { mask3 += (1 << i);
this.bitPointer = 8 + this.bitPointer; }
} mask3 <<= 8 - (numBits - (this.bitPointer + 1 + 8));
var bitsThirdBlock = (this.blocks[this.blockPointer] & mask3) >> (8 - (numBits - (this.bitPointer + 1 + 8)));
return bits;
} else { bits = bitsFirstBlock + bitsSecondBlock + bitsThirdBlock;
return 0; this.bitPointer = this.bitPointer - (numBits - 8) % 8;
} if (this.bitPointer < 0)
}; {
this.bitPointer = 8 + this.bitPointer;
this.NextMode = function () { }
if ((this.blockPointer > this.blocks.length - this.numErrorCorrectionCode - 2)) return bits;
return 0; }
else else
return this.getNextBits(4); {
}; return 0;
}
this.getDataLength=function( modeIndicator) { }
var index = 0; this.NextMode=function()
while (true) {
{ if ((this.blockPointer > this.blocks.length - this.numErrorCorrectionCode - 2))
if ((modeIndicator >> index) == 1) return 0;
break; else
index++; return this.getNextBits(4);
} }
this.getDataLength=function( modeIndicator)
return this.getNextBits(qrcode.sizeOfDataLengthInfo[this.dataLengthMode][index]); {
}; var index = 0;
while (true)
this.getRomanAndFigureString = function (dataLength) { {
var length = dataLength; if ((modeIndicator >> index) == 1)
var intData = 0; break;
var strData = ""; index++;
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 { return this.getNextBits(qrcode.sizeOfDataLengthInfo[this.dataLengthMode][index]);
if (length > 1) { }
intData = this.getNextBits(11); this.getRomanAndFigureString=function( dataLength)
var firstLetter = Math.floor(intData / 45); {
var secondLetter = intData % 45; var length = dataLength;
strData += tableRomanAndFigure[firstLetter]; var intData = 0;
strData += tableRomanAndFigure[secondLetter]; var strData = "";
length -= 2; 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', ' ', '$', '%', '*', '+', '-', '.', '/', ':');
} else if (length == 1) { do
intData = this.getNextBits(6); {
strData += tableRomanAndFigure[intData]; if (length > 1)
length -= 1; {
} intData = this.getNextBits(11);
} while (length > 0); var firstLetter = Math.floor(intData / 45);
var secondLetter = intData % 45;
return strData; strData += tableRomanAndFigure[firstLetter];
}; strData += tableRomanAndFigure[secondLetter];
length -= 2;
this.getFigureString=function( dataLength) { }
var length = dataLength; else if (length == 1)
var intData = 0; {
var strData = ""; intData = this.getNextBits(6);
do strData += tableRomanAndFigure[intData];
{ length -= 1;
if (length >= 3) }
{ }
intData = this.getNextBits(10); while (length > 0);
if (intData < 100)
strData += "0"; return strData;
if (intData < 10) }
strData += "0"; this.getFigureString=function( dataLength)
length -= 3; {
} var length = dataLength;
else if (length == 2) var intData = 0;
{ var strData = "";
intData = this.getNextBits(7); do
if (intData < 10) {
strData += "0"; if (length >= 3)
length -= 2; {
} intData = this.getNextBits(10);
else if (length == 1) if (intData < 100)
{ strData += "0";
intData = this.getNextBits(4); if (intData < 10)
length -= 1; strData += "0";
} length -= 3;
strData += intData; }
} else if (length == 2)
while (length > 0); {
intData = this.getNextBits(7);
return strData; if (intData < 10)
}; strData += "0";
length -= 2;
this.get8bitByteArray=function( dataLength) { }
var length = dataLength; else if (length == 1)
var intData = 0; {
var output = new Array(); intData = this.getNextBits(4);
length -= 1;
do { }
intData = this.getNextBits(8); strData += intData;
output.push( intData); }
length--; while (length > 0);
} while (length > 0);
return strData;
return output; }
}; this.get8bitByteArray=function( dataLength)
{
this.getKanjiString = function (dataLength) { var length = dataLength;
var length = dataLength; var intData = 0;
var intData = 0; var output = new Array();
var unicodeString = "";
do { do
intData = getNextBits(13); {
var lowerByte = intData % 0xC0; intData = this.getNextBits(8);
var higherByte = intData / 0xC0; output.push( intData);
length--;
var tempWord = (higherByte << 8) + lowerByte; }
var shiftjisWord = 0; while (length > 0);
if (tempWord + 0x8140 <= 0x9FFC) { return output;
// between 8140 - 9FFC on Shift_JIS character set }
shiftjisWord = tempWord + 0x8140; this.getKanjiString=function( dataLength)
} else { {
// between E040 - EBBF on Shift_JIS character set var length = dataLength;
shiftjisWord = tempWord + 0xC140; var intData = 0;
} var unicodeString = "";
do
unicodeString += String.fromCharCode(shiftjisWord); {
length--; intData = this.getNextBits(13);
} while (length > 0); var lowerByte = intData % 0xC0;
var higherByte = intData / 0xC0;
return unicodeString;
}; var tempWord = (higherByte << 8) + lowerByte;
var shiftjisWord = 0;
Object.defineProperty(this, 'DataByte', { if (tempWord + 0x8140 <= 0x9FFC)
get: function () { {
var output = new Array(); // between 8140 - 9FFC on Shift_JIS character set
var MODE_NUMBER = 1; shiftjisWord = tempWord + 0x8140;
var MODE_ROMAN_AND_NUMBER = 2; }
var MODE_8BIT_BYTE = 4; else
var MODE_KANJI = 8; {
do { // between E040 - EBBF on Shift_JIS character set
var mode = this.NextMode(); shiftjisWord = tempWord + 0xC140;
if (mode == 0) { }
if (output.length > 0)
break; //var tempByte = new Array(0,0);
else //tempByte[0] = (sbyte) (shiftjisWord >> 8);
throw "Empty data block"; //tempByte[1] = (sbyte) (shiftjisWord & 0xFF);
} //unicodeString += new String(SystemUtils.ToCharArray(SystemUtils.ToByteArray(tempByte)));
unicodeString += String.fromCharCode(shiftjisWord);
if (mode != MODE_NUMBER && length--;
mode != MODE_ROMAN_AND_NUMBER && }
mode != MODE_8BIT_BYTE && while (length > 0);
mode != MODE_KANJI) {
mode = guessMode(mode); return unicodeString;
throw "Invalid mode: " + mode + " in (block:" + this.blockPointer + " bit:" + this.bitPointer + ")"; }
}
this.parseECIValue = function ()
dataLength = this.getDataLength(mode); {
var intData = 0;
if (dataLength < 1) var firstByte = this.getNextBits(8);
throw "Invalid data length: " + dataLength; if ((firstByte & 0x80) == 0) {
switch (mode) { intData = firstByte & 0x7F;
case MODE_NUMBER: }
var temp_str = this.getFigureString(dataLength); if ((firstByte & 0xC0) == 0x80) {
var ta = new Array(temp_str.length); // two bytes
for(var j=0;j<temp_str.length;j++) var secondByte = this.getNextBits(8);
ta[j]=temp_str.charCodeAt(j); intData = ((firstByte & 0x3F) << 8) | secondByte;
output.push(ta); }
break; if ((firstByte & 0xE0) == 0xC0) {
// three bytes
case MODE_ROMAN_AND_NUMBER: var secondThirdBytes = this.getNextBits(8);;
var temp_str = this.getRomanAndFigureString(dataLength); intData = ((firstByte & 0x1F) << 16) | secondThirdBytes;
var ta = new Array(temp_str.length); }
for(var j=0;j<temp_str.length;j++) return intData;
ta[j]=temp_str.charCodeAt(j); }
output.push(ta );
break; this.__defineGetter__("DataByte", function()
{
case MODE_8BIT_BYTE: var output = new Array();
var temp_sbyteArray3 = this.get8bitByteArray(dataLength); var MODE_NUMBER = 1;
output.push(temp_sbyteArray3); var MODE_ROMAN_AND_NUMBER = 2;
break; var MODE_8BIT_BYTE = 4;
var MODE_ECI = 7;
case MODE_KANJI: var MODE_KANJI = 8;
var temp_str = this.getKanjiString(dataLength); do
output.push(temp_str); {
break; var mode = this.NextMode();
} console.log(mode);
} while (true); //canvas.println("mode: " + mode);
return output; 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<temp_str.length;j++)
ta[j]=temp_str.charCodeAt(j);
output.push(ta);
break;
case MODE_ROMAN_AND_NUMBER:
var temp_str = this.getRomanAndFigureString(dataLength);
var ta = new Array(temp_str.length);
for(var j=0;j<temp_str.length;j++)
ta[j]=temp_str.charCodeAt(j);
output.push(ta );
break;
case MODE_8BIT_BYTE:
var temp_sbyteArray3 = this.get8bitByteArray(dataLength);
output.push(temp_sbyteArray3);
break;
case MODE_KANJI:
var temp_str = this.getKanjiString(dataLength);
output.push(temp_str);
break;
}
}
}
while (true);
return output;
});
}

View file

@ -23,7 +23,7 @@
*/ */
DataMask = {}; var DataMask = {};
DataMask.forReference = function(reference) DataMask.forReference = function(reference)
{ {

View file

@ -23,7 +23,7 @@
*/ */
Decoder={}; var Decoder={};
Decoder.rsDecoder = new ReedSolomonDecoder(GF256.QR_CODE_FIELD); Decoder.rsDecoder = new ReedSolomonDecoder(GF256.QR_CODE_FIELD);
Decoder.correctErrors=function( codewordBytes, numDataCodewords) Decoder.correctErrors=function( codewordBytes, numDataCodewords)
@ -56,7 +56,7 @@ Decoder.correctErrors=function( codewordBytes, numDataCodewords)
Decoder.decode=function(bits) Decoder.decode=function(bits)
{ {
var parser = new BitMatrixParser(bits);console.log(JSON.stringify(bits)); var parser = new BitMatrixParser(bits);
var version = parser.readVersion(); var version = parser.readVersion();
var ecLevel = parser.readFormatInformation().ErrorCorrectionLevel; var ecLevel = parser.readFormatInformation().ErrorCorrectionLevel;

View file

@ -90,21 +90,21 @@ PerspectiveTransform.quadrilateralToQuadrilateral=function( x0, y0, x1, y1,
PerspectiveTransform.squareToQuadrilateral=function( x0, y0, x1, y1, x2, y2, x3, y3) PerspectiveTransform.squareToQuadrilateral=function( x0, y0, x1, y1, x2, y2, x3, y3)
{ {
dy2 = y3 - y2; var dy2 = y3 - y2;
dy3 = y0 - y1 + y2 - y3; var dy3 = y0 - y1 + y2 - y3;
if (dy2 == 0.0 && dy3 == 0.0) if (dy2 == 0.0 && dy3 == 0.0)
{ {
return new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0, 0.0, 1.0); return new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0, 0.0, 1.0);
} }
else else
{ {
dx1 = x1 - x2; var dx1 = x1 - x2;
dx2 = x3 - x2; var dx2 = x3 - x2;
dx3 = x0 - x1 + x2 - x3; var dx3 = x0 - x1 + x2 - x3;
dy1 = y1 - y2; var dy1 = y1 - y2;
denominator = dx1 * dy2 - dx2 * dy1; var denominator = dx1 * dy2 - dx2 * dy1;
a13 = (dx3 * dy2 - dx2 * dy3) / denominator; var a13 = (dx3 * dy2 - dx2 * dy3) / denominator;
a23 = (dx1 * dy3 - dx3 * dy1) / denominator; var a23 = (dx1 * dy3 - dx3 * dy1) / denominator;
return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0); return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0);
} }
} }
@ -258,8 +258,8 @@ function Detector(image)
this.distance=function( pattern1, pattern2) this.distance=function( pattern1, pattern2)
{ {
xDiff = pattern1.X - pattern2.X; var xDiff = pattern1.X - pattern2.X;
yDiff = pattern1.Y - pattern2.Y; var yDiff = pattern1.Y - pattern2.Y;
return Math.sqrt( (xDiff * xDiff + yDiff * yDiff)); return Math.sqrt( (xDiff * xDiff + yDiff * yDiff));
} }
this.computeDimension=function( topLeft, topRight, bottomLeft, moduleSize) this.computeDimension=function( topLeft, topRight, bottomLeft, moduleSize)

View file

@ -1,64 +1,58 @@
/* /*
Ported to JavaScript by Lazar Laszlo 2011 Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info lazarsoft@gmail.com, www.lazarsoft.info
*/ */
/* /*
* *
* Copyright 2007 ZXing authors * Copyright 2007 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
function ErrorCorrectionLevel(ordinal, bits, name) function ErrorCorrectionLevel(ordinal, bits, name)
{ {
this.ordinal_Renamed_Field = ordinal; this.ordinal_Renamed_Field = ordinal;
this.bits = bits; this.bits = bits;
this.name = name; this.name = name;
this.__defineGetter__("Bits", function()
Object.defineProperties(this, { {
'Bits': { return this.bits;
get: function () { });
return this.bits; this.__defineGetter__("Name", function()
} {
}, return this.name;
});
'Name': { this.ordinal=function()
get: function () { {
return this.name; return this.ordinal_Renamed_Field;
} }
} }
});
ErrorCorrectionLevel.forBits=function( bits)
this.ordinal=function() { {
return this.ordinal_Renamed_Field; if (bits < 0 || bits >= FOR_BITS.length)
} {
} throw "ArgumentException";
}
ErrorCorrectionLevel.forBits=function( bits) return FOR_BITS[bits];
{ }
if (bits < 0 || bits >= FOR_BITS.length) {
throw "ArgumentException"; var L = new ErrorCorrectionLevel(0, 0x01, "L");
} var M = new ErrorCorrectionLevel(1, 0x00, "M");
var Q = new ErrorCorrectionLevel(2, 0x03, "Q");
return FOR_BITS[bits]; var H = new ErrorCorrectionLevel(3, 0x02, "H");
} var FOR_BITS = new Array( M, L, H, Q);
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);

File diff suppressed because it is too large Load diff

View file

@ -1,110 +1,104 @@
/* /*
Ported to JavaScript by Lazar Laszlo 2011 Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info lazarsoft@gmail.com, www.lazarsoft.info
*/ */
/* /*
* *
* Copyright 2007 ZXing authors * Copyright 2007 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
var FORMAT_INFO_MASK_QR = 0x5412; 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 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); 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) function FormatInformation(formatInfo)
{ {
this.errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03); this.errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03);
this.dataMask = (formatInfo & 0x07); this.dataMask = (formatInfo & 0x07);
Object.defineProperties(this, { this.__defineGetter__("ErrorCorrectionLevel", function()
'ErrorCorrectionLevel': { {
get: function () { return this.errorCorrectionLevel;
return this.errorCorrectionLevel; });
} this.__defineGetter__("DataMask", function()
}, {
return this.dataMask;
'DataMask': { });
get: function () { this.GetHashCode=function()
return this.dataMask; {
} return (this.errorCorrectionLevel.ordinal() << 3) | this.dataMask;
} }
}); this.Equals=function( o)
{
this.GetHashCode=function() var other = o;
{ return this.errorCorrectionLevel == other.errorCorrectionLevel && this.dataMask == other.dataMask;
return (this.errorCorrectionLevel.ordinal() << 3) | dataMask; }
} }
this.Equals=function( o)
{ FormatInformation.numBitsDiffering=function( a, b)
var other = o; {
return this.errorCorrectionLevel == other.errorCorrectionLevel && this.dataMask == other.dataMask; 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.numBitsDiffering=function( a, b)
{ FormatInformation.decodeFormatInformation=function( maskedFormatInfo)
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: var formatInfo = FormatInformation.doDecodeFormatInformation(maskedFormatInfo);
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)]; if (formatInfo != null)
} {
return formatInfo;
FormatInformation.decodeFormatInformation=function( maskedFormatInfo) }
{ // Should return null, but, some QR codes apparently
var formatInfo = FormatInformation.doDecodeFormatInformation(maskedFormatInfo); // do not mask this info. Try again by actually masking the pattern
if (formatInfo != null) // first
{ return FormatInformation.doDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR);
return formatInfo; }
} FormatInformation.doDecodeFormatInformation=function( maskedFormatInfo)
// Should return null, but, some QR codes apparently {
// do not mask this info. Try again by actually masking the pattern // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing
// first var bestDifference = 0xffffffff;
return FormatInformation.doDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR); var bestFormatInfo = 0;
} for (var i = 0; i < FORMAT_INFO_DECODE_LOOKUP.length; i++)
FormatInformation.doDecodeFormatInformation=function( maskedFormatInfo) {
{ var decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i];
// Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing var targetInfo = decodeInfo[0];
var bestDifference = 0xffffffff; if (targetInfo == maskedFormatInfo)
var bestFormatInfo = 0; {
for (var i = 0; i < FORMAT_INFO_DECODE_LOOKUP.length; i++) // Found an exact match
{ return new FormatInformation(decodeInfo[1]);
var decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i]; }
var targetInfo = decodeInfo[0]; var bitsDifference = this.numBitsDiffering(maskedFormatInfo, targetInfo);
if (targetInfo == maskedFormatInfo) if (bitsDifference < bestDifference)
{ {
// Found an exact match bestFormatInfo = decodeInfo[1];
return new FormatInformation(decodeInfo[1]); bestDifference = bitsDifference;
} }
var bitsDifference = this.numBitsDiffering(maskedFormatInfo, targetInfo); }
if (bitsDifference < bestDifference) // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits
{ // differing means we found a match
bestFormatInfo = decodeInfo[1]; if (bestDifference <= 3)
bestDifference = bitsDifference; {
} return new FormatInformation(bestFormatInfo);
} }
// Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits return null;
// differing means we found a match }
if (bestDifference <= 3)
{
return new FormatInformation(bestFormatInfo);
}
return null;
}

View file

@ -1,123 +1,117 @@
/* /*
Ported to JavaScript by Lazar Laszlo 2011 Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info lazarsoft@gmail.com, www.lazarsoft.info
*/ */
/* /*
* *
* Copyright 2007 ZXing authors * Copyright 2007 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
function GF256( primitive) function GF256( primitive)
{ {
this.expTable = new Array(256); this.expTable = new Array(256);
this.logTable = new Array(256); this.logTable = new Array(256);
var x = 1; var x = 1;
for (var i = 0; i < 256; i++) for (var i = 0; i < 256; i++)
{ {
this.expTable[i] = x; this.expTable[i] = x;
x <<= 1; // x = x * 2; we're assuming the generator alpha is 2 x <<= 1; // x = x * 2; we're assuming the generator alpha is 2
if (x >= 0x100) if (x >= 0x100)
{ {
x ^= primitive; x ^= primitive;
} }
} }
for (var i = 0; i < 255; i++) for (var i = 0; i < 255; i++)
{ {
this.logTable[this.expTable[i]] = i; this.logTable[this.expTable[i]] = i;
} }
// logTable[0] == 0 but this should never be used // logTable[0] == 0 but this should never be used
var at0=new Array(1);at0[0]=0; var at0=new Array(1);at0[0]=0;
this.zero = new GF256Poly(this, new Array(at0)); this.zero = new GF256Poly(this, new Array(at0));
var at1=new Array(1);at1[0]=1; var at1=new Array(1);at1[0]=1;
this.one = new GF256Poly(this, new Array(at1)); this.one = new GF256Poly(this, new Array(at1));
Object.defineProperties(this, { this.__defineGetter__("Zero", function()
'Zero': { {
get: function () { return this.zero;
return this.zero; });
} this.__defineGetter__("One", function()
}, {
return this.one;
'One': { });
get: function () { this.buildMonomial=function( degree, coefficient)
return this.one; {
} if (degree < 0)
} {
}); throw "System.ArgumentException";
}
this.buildMonomial=function( degree, coefficient) if (coefficient == 0)
{ {
if (degree < 0) return this.zero;
{ }
throw "System.ArgumentException"; var coefficients = new Array(degree + 1);
} for(var i=0;i<coefficients.length;i++)coefficients[i]=0;
if (coefficient == 0) coefficients[0] = coefficient;
{ return new GF256Poly(this, coefficients);
return zero; }
} this.exp=function( a)
var coefficients = new Array(degree + 1); {
for(var i=0;i<coefficients.length;i++)coefficients[i]=0; return this.expTable[a];
coefficients[0] = coefficient; }
return new GF256Poly(this, coefficients); this.log=function( a)
} {
this.exp=function( a) if (a == 0)
{ {
return this.expTable[a]; throw "System.ArgumentException";
} }
this.log=function( a) return this.logTable[a];
{ }
if (a == 0) this.inverse=function( a)
{ {
throw "System.ArgumentException"; if (a == 0)
} {
return this.logTable[a]; throw "System.ArithmeticException";
} }
this.inverse=function( a) return this.expTable[255 - this.logTable[a]];
{ }
if (a == 0) this.multiply=function( a, b)
{ {
throw "System.ArithmeticException"; if (a == 0 || b == 0)
} {
return this.expTable[255 - this.logTable[a]]; return 0;
} }
this.multiply=function( a, b) if (a == 1)
{ {
if (a == 0 || b == 0) return b;
{ }
return 0; if (b == 1)
} {
if (a == 1) return a;
{ }
return b; return this.expTable[(this.logTable[a] + this.logTable[b]) % 255];
} }
if (b == 1) }
{
return a; GF256.QR_CODE_FIELD = new GF256(0x011D);
} GF256.DATA_MATRIX_FIELD = new GF256(0x012D);
return this.expTable[(this.logTable[a] + this.logTable[b]) % 255];
} GF256.addOrSubtract=function( a, b)
} {
return a ^ b;
GF256.QR_CODE_FIELD = new GF256(0x011D); }
GF256.DATA_MATRIX_FIELD = new GF256(0x012D);
GF256.addOrSubtract=function( a, b)
{
return a ^ b;
}

View file

@ -1,237 +1,230 @@
/* /*
Ported to JavaScript by Lazar Laszlo 2011 Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info lazarsoft@gmail.com, www.lazarsoft.info
*/ */
/* /*
* *
* Copyright 2007 ZXing authors * Copyright 2007 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
function GF256Poly(field, coefficients) function GF256Poly(field, coefficients)
{ {
if (coefficients == null || coefficients.length == 0) if (coefficients == null || coefficients.length == 0)
{ {
throw "System.ArgumentException"; throw "System.ArgumentException";
} }
this.field = field; this.field = field;
var coefficientsLength = coefficients.length; var coefficientsLength = coefficients.length;
if (coefficientsLength > 1 && coefficients[0] == 0) if (coefficientsLength > 1 && coefficients[0] == 0)
{ {
// Leading term must be non-zero for anything except the constant polynomial "0" // Leading term must be non-zero for anything except the constant polynomial "0"
var firstNonZero = 1; var firstNonZero = 1;
while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0)
{ {
firstNonZero++; firstNonZero++;
} }
if (firstNonZero == coefficientsLength) if (firstNonZero == coefficientsLength)
{ {
this.coefficients = field.Zero.coefficients; this.coefficients = field.Zero.coefficients;
} }
else else
{ {
this.coefficients = new Array(coefficientsLength - firstNonZero); this.coefficients = new Array(coefficientsLength - firstNonZero);
for(var i=0;i<this.coefficients.length;i++)this.coefficients[i]=0; for(var i=0;i<this.coefficients.length;i++)this.coefficients[i]=0;
//Array.Copy(coefficients, firstNonZero, this.coefficients, 0, this.coefficients.length); //Array.Copy(coefficients, firstNonZero, this.coefficients, 0, this.coefficients.length);
for(var ci=0;ci<this.coefficients.length;ci++)this.coefficients[ci]=coefficients[firstNonZero+ci]; for(var ci=0;ci<this.coefficients.length;ci++)this.coefficients[ci]=coefficients[firstNonZero+ci];
} }
} }
else else
{ {
this.coefficients = coefficients; this.coefficients = coefficients;
} }
Object.defineProperties(this, { this.__defineGetter__("Zero", function()
"Zero": { {
get: function () { return this.coefficients[0] == 0;
return this.coefficients[0] == 0; });
} this.__defineGetter__("Degree", function()
}, {
return this.coefficients.length - 1;
"Degree": { });
get: function () { this.__defineGetter__("Coefficients", function()
return this.coefficients.length - 1; {
} return this.coefficients;
}, });
"Coefficients": { this.getCoefficient=function( degree)
get: function () { {
return this.coefficients; return this.coefficients[this.coefficients.length - 1 - degree];
} }
}
}); this.evaluateAt=function( a)
{
this.getCoefficient=function( degree) if (a == 0)
{ {
return this.coefficients[this.coefficients.length - 1 - degree]; // Just return the x^0 coefficient
} return this.getCoefficient(0);
}
this.evaluateAt=function( a) var size = this.coefficients.length;
{ if (a == 1)
if (a == 0) {
{ // Just the sum of the coefficients
// Just return the x^0 coefficient var result = 0;
return this.getCoefficient(0); for (var i = 0; i < size; i++)
} {
var size = this.coefficients.length; result = GF256.addOrSubtract(result, this.coefficients[i]);
if (a == 1) }
{ return result;
// Just the sum of the coefficients }
var result = 0; var result2 = this.coefficients[0];
for (var i = 0; i < size; i++) for (var i = 1; i < size; i++)
{ {
result = GF256.addOrSubtract(result, this.coefficients[i]); result2 = GF256.addOrSubtract(this.field.multiply(a, result2), this.coefficients[i]);
} }
return result; return result2;
} }
var result2 = this.coefficients[0];
for (var i = 1; i < size; i++) this.addOrSubtract=function( other)
{ {
result2 = GF256.addOrSubtract(this.field.multiply(a, result2), this.coefficients[i]); if (this.field != other.field)
} {
return result2; throw "GF256Polys do not have same GF256 field";
} }
if (this.Zero)
this.addOrSubtract=function( other) {
{ return other;
if (this.field != other.field) }
{ if (other.Zero)
throw "GF256Polys do not have same GF256 field"; {
} return this;
if (this.Zero) }
{
return other; var smallerCoefficients = this.coefficients;
} var largerCoefficients = other.coefficients;
if (other.Zero) if (smallerCoefficients.length > largerCoefficients.length)
{ {
return this; var temp = smallerCoefficients;
} smallerCoefficients = largerCoefficients;
largerCoefficients = temp;
var smallerCoefficients = this.coefficients; }
var largerCoefficients = other.coefficients; var sumDiff = new Array(largerCoefficients.length);
if (smallerCoefficients.length > largerCoefficients.length) var lengthDiff = largerCoefficients.length - smallerCoefficients.length;
{ // Copy high-order terms only found in higher-degree polynomial's coefficients
var temp = smallerCoefficients; //Array.Copy(largerCoefficients, 0, sumDiff, 0, lengthDiff);
smallerCoefficients = largerCoefficients; for(var ci=0;ci<lengthDiff;ci++)sumDiff[ci]=largerCoefficients[ci];
largerCoefficients = temp;
} for (var i = lengthDiff; i < largerCoefficients.length; i++)
var sumDiff = new Array(largerCoefficients.length); {
var lengthDiff = largerCoefficients.length - smallerCoefficients.length; sumDiff[i] = GF256.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);
// Copy high-order terms only found in higher-degree polynomial's coefficients }
//Array.Copy(largerCoefficients, 0, sumDiff, 0, lengthDiff);
for(var ci=0;ci<lengthDiff;ci++)sumDiff[ci]=largerCoefficients[ci]; return new GF256Poly(field, sumDiff);
}
for (var i = lengthDiff; i < largerCoefficients.length; i++) this.multiply1=function( other)
{ {
sumDiff[i] = GF256.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]); if (this.field!=other.field)
} {
throw "GF256Polys do not have same GF256 field";
return new GF256Poly(field, sumDiff); }
} if (this.Zero || other.Zero)
this.multiply1=function( other) {
{ return this.field.Zero;
if (this.field!=other.field) }
{ var aCoefficients = this.coefficients;
throw "GF256Polys do not have same GF256 field"; var aLength = aCoefficients.length;
} var bCoefficients = other.coefficients;
if (this.Zero || other.Zero) var bLength = bCoefficients.length;
{ var product = new Array(aLength + bLength - 1);
return this.field.Zero; for (var i = 0; i < aLength; i++)
} {
var aCoefficients = this.coefficients; var aCoeff = aCoefficients[i];
var aLength = aCoefficients.length; for (var j = 0; j < bLength; j++)
var bCoefficients = other.coefficients; {
var bLength = bCoefficients.length; product[i + j] = GF256.addOrSubtract(product[i + j], this.field.multiply(aCoeff, bCoefficients[j]));
var product = new Array(aLength + bLength - 1); }
for (var i = 0; i < aLength; i++) }
{ return new GF256Poly(this.field, product);
var aCoeff = aCoefficients[i]; }
for (var j = 0; j < bLength; j++) this.multiply2=function( scalar)
{ {
product[i + j] = GF256.addOrSubtract(product[i + j], this.field.multiply(aCoeff, bCoefficients[j])); if (scalar == 0)
} {
} return this.field.Zero;
return new GF256Poly(this.field, product); }
} if (scalar == 1)
this.multiply2=function( scalar) {
{ return this;
if (scalar == 0) }
{ var size = this.coefficients.length;
return this.field.Zero; var product = new Array(size);
} for (var i = 0; i < size; i++)
if (scalar == 1) {
{ product[i] = this.field.multiply(this.coefficients[i], scalar);
return this; }
} return new GF256Poly(this.field, product);
var size = this.coefficients.length; }
var product = new Array(size); this.multiplyByMonomial=function( degree, coefficient)
for (var i = 0; i < size; i++) {
{ if (degree < 0)
product[i] = this.field.multiply(this.coefficients[i], scalar); {
} throw "System.ArgumentException";
return new GF256Poly(this.field, product); }
} if (coefficient == 0)
this.multiplyByMonomial=function( degree, coefficient) {
{ return this.field.Zero;
if (degree < 0) }
{ var size = this.coefficients.length;
throw "System.ArgumentException"; var product = new Array(size + degree);
} for(var i=0;i<product.length;i++)product[i]=0;
if (coefficient == 0) for (var i = 0; i < size; i++)
{ {
return this.field.Zero; product[i] = this.field.multiply(this.coefficients[i], coefficient);
} }
var size = this.coefficients.length; return new GF256Poly(this.field, product);
var product = new Array(size + degree); }
for(var i=0;i<product.length;i++)product[i]=0; this.divide=function( other)
for (var i = 0; i < size; i++) {
{ if (this.field!=other.field)
product[i] = this.field.multiply(this.coefficients[i], coefficient); {
} throw "GF256Polys do not have same GF256 field";
return new GF256Poly(this.field, product); }
} if (other.Zero)
this.divide=function( other) {
{ throw "Divide by 0";
if (this.field!=other.field) }
{
throw "GF256Polys do not have same GF256 field"; var quotient = this.field.Zero;
} var remainder = this;
if (other.Zero)
{ var denominatorLeadingTerm = other.getCoefficient(other.Degree);
throw "Divide by 0"; var inverseDenominatorLeadingTerm = this.field.inverse(denominatorLeadingTerm);
}
while (remainder.Degree >= other.Degree && !remainder.Zero)
var quotient = this.field.Zero; {
var remainder = this; var degreeDifference = remainder.Degree - other.Degree;
var scale = this.field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm);
var denominatorLeadingTerm = other.getCoefficient(other.Degree); var term = other.multiplyByMonomial(degreeDifference, scale);
var inverseDenominatorLeadingTerm = this.field.inverse(denominatorLeadingTerm); var iterationQuotient = this.field.buildMonomial(degreeDifference, scale);
quotient = quotient.addOrSubtract(iterationQuotient);
while (remainder.Degree >= other.Degree && !remainder.Zero) remainder = remainder.addOrSubtract(term);
{ }
var degreeDifference = remainder.Degree - other.Degree;
var scale = this.field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm); return new Array(quotient, remainder);
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);
}
}

View file

@ -1,152 +1,152 @@
/* /*
Ported to JavaScript by Lazar Laszlo 2011 Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info lazarsoft@gmail.com, www.lazarsoft.info
*/ */
/* /*
* *
* Copyright 2007 ZXing authors * Copyright 2007 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
GridSampler = {}; var GridSampler = {};
GridSampler.checkAndNudgePoints=function( image, points) GridSampler.checkAndNudgePoints=function( image, points)
{ {
var width = qrcode.width; var width = qrcode.width;
var height = qrcode.height; var height = qrcode.height;
// Check and nudge points from start until we see some that are OK: // Check and nudge points from start until we see some that are OK:
var nudged = true; var nudged = true;
for (var offset = 0; offset < points.length && nudged; offset += 2) for (var offset = 0; offset < points.length && nudged; offset += 2)
{ {
var x = Math.floor (points[offset]); var x = Math.floor (points[offset]);
var y = Math.floor( points[offset + 1]); var y = Math.floor( points[offset + 1]);
if (x < - 1 || x > width || y < - 1 || y > height) if (x < - 1 || x > width || y < - 1 || y > height)
{ {
throw "Error.checkAndNudgePoints "; throw "Error.checkAndNudgePoints ";
} }
nudged = false; nudged = false;
if (x == - 1) if (x == - 1)
{ {
points[offset] = 0.0; points[offset] = 0.0;
nudged = true; nudged = true;
} }
else if (x == width) else if (x == width)
{ {
points[offset] = width - 1; points[offset] = width - 1;
nudged = true; nudged = true;
} }
if (y == - 1) if (y == - 1)
{ {
points[offset + 1] = 0.0; points[offset + 1] = 0.0;
nudged = true; nudged = true;
} }
else if (y == height) else if (y == height)
{ {
points[offset + 1] = height - 1; points[offset + 1] = height - 1;
nudged = true; nudged = true;
} }
} }
// Check and nudge points from end: // Check and nudge points from end:
nudged = true; nudged = true;
for (var offset = points.length - 2; offset >= 0 && nudged; offset -= 2) for (var offset = points.length - 2; offset >= 0 && nudged; offset -= 2)
{ {
var x = Math.floor( points[offset]); var x = Math.floor( points[offset]);
var y = Math.floor( points[offset + 1]); var y = Math.floor( points[offset + 1]);
if (x < - 1 || x > width || y < - 1 || y > height) if (x < - 1 || x > width || y < - 1 || y > height)
{ {
throw "Error.checkAndNudgePoints "; throw "Error.checkAndNudgePoints ";
} }
nudged = false; nudged = false;
if (x == - 1) if (x == - 1)
{ {
points[offset] = 0.0; points[offset] = 0.0;
nudged = true; nudged = true;
} }
else if (x == width) else if (x == width)
{ {
points[offset] = width - 1; points[offset] = width - 1;
nudged = true; nudged = true;
} }
if (y == - 1) if (y == - 1)
{ {
points[offset + 1] = 0.0; points[offset + 1] = 0.0;
nudged = true; nudged = true;
} }
else if (y == height) else if (y == height)
{ {
points[offset + 1] = height - 1; points[offset + 1] = height - 1;
nudged = true; nudged = true;
} }
} }
} }
GridSampler.sampleGrid3=function( image, dimension, transform) GridSampler.sampleGrid3=function( image, dimension, transform)
{ {
var bits = new BitMatrix(dimension); var bits = new BitMatrix(dimension);
var points = new Array(dimension << 1); var points = new Array(dimension << 1);
for (var y = 0; y < dimension; y++) for (var y = 0; y < dimension; y++)
{ {
var max = points.length; var max = points.length;
var iValue = y + 0.5; var iValue = y + 0.5;
for (var x = 0; x < max; x += 2) for (var x = 0; x < max; x += 2)
{ {
points[x] = (x >> 1) + 0.5; points[x] = (x >> 1) + 0.5;
points[x + 1] = iValue; points[x + 1] = iValue;
} }
transform.transformPoints1(points); transform.transformPoints1(points);
// Quick check to see if points transformed to something inside the image; // Quick check to see if points transformed to something inside the image;
// sufficient to check the endpoints // sufficient to check the endpoints
GridSampler.checkAndNudgePoints(image, points); GridSampler.checkAndNudgePoints(image, points);
try try
{ {
for (var x = 0; x < max; x += 2) for (var x = 0; x < max; x += 2)
{ {
var xpoint = (Math.floor( points[x]) * 4) + (Math.floor( points[x + 1]) * qrcode.width * 4); //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])]; 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] = bit?255:0;
qrcode.imagedata.data[xpoint+1] = bit?255:0; //qrcode.imagedata.data[xpoint+1] = bit?255:0;
qrcode.imagedata.data[xpoint+2] = 0; //qrcode.imagedata.data[xpoint+2] = 0;
qrcode.imagedata.data[xpoint+3] = 255; //qrcode.imagedata.data[xpoint+3] = 255;
//bits[x >> 1][ y]=bit; //bits[x >> 1][ y]=bit;
if(bit) if(bit)
bits.set_Renamed(x >> 1, y); bits.set_Renamed(x >> 1, y);
} }
} }
catch ( aioobe) catch ( aioobe)
{ {
// This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting // 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 // 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 // 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. // 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 // 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 // that. We could check each point's coordinates but that feels duplicative. We settle for
// catching and wrapping ArrayIndexOutOfBoundsException. // catching and wrapping ArrayIndexOutOfBoundsException.
throw "Error.checkAndNudgePoints"; throw "Error.checkAndNudgePoints";
} }
} }
return bits; return bits;
} }
GridSampler.sampleGridx=function( image, dimension, p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY) 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); 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); return GridSampler.sampleGrid3(image, dimension, transform);
} }

View file

@ -1,322 +1,455 @@
/* /*
Copyright 2011 Lazar Laszlo (lazarsoft@gmail.com, www.lazarsoft.info) Copyright 2011 Lazar Laszlo (lazarsoft@gmail.com, www.lazarsoft.info)
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
qrcode = {}; var qrcode = {};
qrcode.imagedata = null; qrcode.imagedata = null;
qrcode.width = 0; qrcode.width = 0;
qrcode.height = 0; qrcode.height = 0;
qrcode.qrCodeSymbol = null; qrcode.qrCodeSymbol = null;
qrcode.debug = false; qrcode.debug = false;
qrcode.maxImgSize = 1024*1024; qrcode.maxImgSize = 1024*1024;
qrcode.sizeOfDataLengthInfo = [ [ 10, 9, 8, 8 ], [ 12, 11, 16, 10 ], [ 14, 13, 16, 12 ] ]; qrcode.sizeOfDataLengthInfo = [ [ 10, 9, 8, 8 ], [ 12, 11, 16, 10 ], [ 14, 13, 16, 12 ] ];
qrcode.callback = null; qrcode.callback = null;
qrcode.decode = function(src){ qrcode.vidSuccess = function (stream)
{
if(arguments.length==0) qrcode.localstream = stream;
{ if(qrcode.webkit)
var canvas_qr = document.getElementById("qr-canvas"); qrcode.video.src = window.webkitURL.createObjectURL(stream);
var context = canvas_qr.getContext('2d'); else
qrcode.width = canvas_qr.width; if(qrcode.moz)
qrcode.height = canvas_qr.height; {
qrcode.imagedata = context.getImageData(0, 0, qrcode.width, qrcode.height); qrcode.video.mozSrcObject = stream;
qrcode.result = qrcode.process(context); qrcode.video.play();
if(qrcode.callback!=null) }
qrcode.callback(qrcode.result); else
return qrcode.result; qrcode.video.src = stream;
}
else qrcode.gUM=true;
{
var image = new Image(); qrcode.canvas_qr2 = document.createElement('canvas');
image.crossOrigin = "Anonymous"; qrcode.canvas_qr2.id = "qr-canvas";
image.onload=function(){ qrcode.qrcontext2 = qrcode.canvas_qr2.getContext('2d');
//var canvas_qr = document.getElementById("qr-canvas"); qrcode.canvas_qr2.width = qrcode.video.videoWidth;
var canvas_qr = document.createElement('canvas'); qrcode.canvas_qr2.height = qrcode.video.videoHeight;
var context = canvas_qr.getContext('2d'); setTimeout(qrcode.captureToCanvas, 500);
var nheight = image.height; }
var nwidth = image.width;
if(image.width*image.height>qrcode.maxImgSize) qrcode.vidError = function(error)
{ {
var ir = image.width / image.height; qrcode.gUM=false;
nheight = Math.sqrt(qrcode.maxImgSize/ir); return;
nwidth=ir*nheight; }
}
qrcode.captureToCanvas = function()
canvas_qr.width = nwidth; {
canvas_qr.height = nheight; if(qrcode.gUM)
{
context.drawImage(image, 0, 0, canvas_qr.width, canvas_qr.height ); try{
qrcode.width = canvas_qr.width; if(qrcode.video.videoWidth == 0)
qrcode.height = canvas_qr.height; {
try{ setTimeout(qrcode.captureToCanvas, 500);
qrcode.imagedata = context.getImageData(0, 0, canvas_qr.width, canvas_qr.height); return;
}catch(e){ }
qrcode.result = "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!"; else
if(qrcode.callback!=null) {
qrcode.callback(qrcode.result); qrcode.canvas_qr2.width = qrcode.video.videoWidth;
return; qrcode.canvas_qr2.height = qrcode.video.videoHeight;
} }
qrcode.qrcontext2.drawImage(qrcode.video,0,0);
try try{
{ qrcode.decode();
qrcode.result = qrcode.process(context); }
} catch(e){
catch(e) console.log(e);
{ setTimeout(qrcode.captureToCanvas, 500);
console.log(e); };
qrcode.result = "error decoding QR Code"; }
} catch(e){
if(qrcode.callback!=null) console.log(e);
qrcode.callback(qrcode.result); setTimeout(qrcode.captureToCanvas, 500);
} };
image.src = src; }
} }
}
qrcode.setWebcam = function(videoId)
qrcode.isUrl = function(s) {
{ var n=navigator;
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; qrcode.video=document.getElementById(videoId);
return regexp.test(s);
} var options = true;
if(navigator.mediaDevices && navigator.mediaDevices.enumerateDevices)
qrcode.decode_url = function (s) {
{ try{
var escaped = ""; navigator.mediaDevices.enumerateDevices()
try{ .then(function(devices) {
escaped = escape( s ); devices.forEach(function(device) {
} console.log("deb1");
catch(e) if (device.kind === 'videoinput') {
{ if(device.label.toLowerCase().search("back") >-1)
console.log(e); options=[{'sourceId': device.deviceId}] ;
escaped = s; }
} console.log(device.kind + ": " + device.label +
var ret = ""; " id = " + device.deviceId);
try{ });
ret = decodeURIComponent( escaped ); })
}
catch(e) }
{ catch(e)
console.log(e); {
ret = escaped; console.log(e);
} }
return ret; }
} else{
console.log("no navigator.mediaDevices.enumerateDevices" );
qrcode.decode_utf8 = function ( s ) }
{
if(qrcode.isUrl(s)) if(n.getUserMedia)
return qrcode.decode_url(s); n.getUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
else else
return s; if(n.webkitGetUserMedia)
} {
qrcode.webkit=true;
qrcode.process = function(ctx){ n.webkitGetUserMedia({video:options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
}
var start = new Date().getTime(); else
if(n.mozGetUserMedia)
var image = qrcode.grayScaleToBitmap(qrcode.grayscale()); {
//var image = qrcode.binarize(128); qrcode.moz=true;
n.mozGetUserMedia({video: options, audio: false}, qrcode.vidSuccess, qrcode.vidError);
if(qrcode.debug) }
{ }
for (var y = 0; y < qrcode.height; y++)
{ qrcode.decode = function(src){
for (var x = 0; x < qrcode.width; x++)
{ if(arguments.length==0)
var point = (x * 4) + (y * qrcode.width * 4); {
qrcode.imagedata.data[point] = image[x+y*qrcode.width]?0:0; if(qrcode.canvas_qr2)
qrcode.imagedata.data[point+1] = image[x+y*qrcode.width]?0:0; {
qrcode.imagedata.data[point+2] = image[x+y*qrcode.width]?255:0; var canvas_qr = qrcode.canvas_qr2;
} var context = qrcode.qrcontext2;
} }
ctx.putImageData(qrcode.imagedata, 0, 0); else
} {
var canvas_qr = document.getElementById("qr-canvas");
//var finderPatternInfo = new FinderPatternFinder().findFinderPattern(image); var context = canvas_qr.getContext('2d');
}
var detector = new Detector(image); qrcode.width = canvas_qr.width;
qrcode.height = canvas_qr.height;
var qRCodeMatrix = detector.detect(); qrcode.imagedata = context.getImageData(0, 0, qrcode.width, qrcode.height);
qrcode.result = qrcode.process(context);
/*for (var y = 0; y < qRCodeMatrix.bits.Height; y++) if(qrcode.callback!=null)
{ qrcode.callback(qrcode.result);
for (var x = 0; x < qRCodeMatrix.bits.Width; x++) return qrcode.result;
{ }
var point = (x * 4*2) + (y*2 * qrcode.width * 4); else
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; var image = new Image();
qrcode.imagedata.data[point+2] = qRCodeMatrix.bits.get_Renamed(x,y)?255:0; image.crossOrigin = "Anonymous";
} image.onload=function(){
}*/ //var canvas_qr = document.getElementById("qr-canvas");
if(qrcode.debug) var canvas_out = document.getElementById("out-canvas");
ctx.putImageData(qrcode.imagedata, 0, 0); if(canvas_out!=null)
{
console.log(qRCodeMatrix); var outctx = canvas_out.getContext('2d');
outctx.clearRect(0, 0, 320, 240);
var reader = Decoder.decode(qRCodeMatrix.bits); outctx.drawImage(image, 0, 0, 320, 240);
var data = reader.DataByte; }
var str="";
for(var i=0;i<data.length;i++) var canvas_qr = document.createElement('canvas');
{ var context = canvas_qr.getContext('2d');
for(var j=0;j<data[i].length;j++) var nheight = image.height;
str+=String.fromCharCode(data[i][j]); var nwidth = image.width;
} if(image.width*image.height>qrcode.maxImgSize)
{
var end = new Date().getTime(); var ir = image.width / image.height;
var time = end - start; nheight = Math.sqrt(qrcode.maxImgSize/ir);
console.log(time); nwidth=ir*nheight;
}
return qrcode.decode_utf8(str);
//alert("Time:" + time + " Code: "+str); canvas_qr.width = nwidth;
} canvas_qr.height = nheight;
qrcode.getPixel = function(x,y){ context.drawImage(image, 0, 0, canvas_qr.width, canvas_qr.height );
if (qrcode.width < x) { qrcode.width = canvas_qr.width;
throw "point error"; qrcode.height = canvas_qr.height;
} try{
if (qrcode.height < y) { qrcode.imagedata = context.getImageData(0, 0, canvas_qr.width, canvas_qr.height);
throw "point error"; }catch(e){
} qrcode.result = "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!";
point = (x * 4) + (y * qrcode.width * 4); if(qrcode.callback!=null)
p = (qrcode.imagedata.data[point]*33 + qrcode.imagedata.data[point + 1]*34 + qrcode.imagedata.data[point + 2]*33)/100; qrcode.callback(qrcode.result);
return p; return;
} }
qrcode.binarize = function(th){ try
var ret = new Array(qrcode.width*qrcode.height); {
for (var y = 0; y < qrcode.height; y++) qrcode.result = qrcode.process(context);
{ }
for (var x = 0; x < qrcode.width; x++) catch(e)
{ {
var gray = qrcode.getPixel(x, y); console.log(e);
qrcode.result = "error decoding QR Code";
ret[x+y*qrcode.width] = gray<=th?true:false; }
} if(qrcode.callback!=null)
} qrcode.callback(qrcode.result);
return ret; }
} image.onerror = function ()
{
qrcode.getMiddleBrightnessPerArea=function(image) if(qrcode.callback!=null)
{ qrcode.callback("Failed to load the image");
var numSqrtArea = 4; }
//obtain middle brightness((min + max) / 2) per area image.src = src;
var areaWidth = Math.floor(qrcode.width / numSqrtArea); }
var areaHeight = Math.floor(qrcode.height / numSqrtArea); }
var minmax = new Array(numSqrtArea);
for (var i = 0; i < numSqrtArea; i++) qrcode.isUrl = function(s)
{ {
minmax[i] = new Array(numSqrtArea); var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
for (var i2 = 0; i2 < numSqrtArea; i2++) return regexp.test(s);
{ }
minmax[i][i2] = new Array(0,0);
} qrcode.decode_url = function (s)
} {
for (var ay = 0; ay < numSqrtArea; ay++) var escaped = "";
{ try{
for (var ax = 0; ax < numSqrtArea; ax++) escaped = escape( s );
{ }
minmax[ax][ay][0] = 0xFF; catch(e)
for (var dy = 0; dy < areaHeight; dy++) {
{ console.log(e);
for (var dx = 0; dx < areaWidth; dx++) escaped = s;
{ }
var target = image[areaWidth * ax + dx+(areaHeight * ay + dy)*qrcode.width]; var ret = "";
if (target < minmax[ax][ay][0]) try{
minmax[ax][ay][0] = target; ret = decodeURIComponent( escaped );
if (target > minmax[ax][ay][1]) }
minmax[ax][ay][1] = target; catch(e)
} {
} console.log(e);
//minmax[ax][ay][0] = (minmax[ax][ay][0] + minmax[ax][ay][1]) / 2; ret = escaped;
} }
} return ret;
var middle = new Array(numSqrtArea); }
for (var i3 = 0; i3 < numSqrtArea; i3++)
{ qrcode.decode_utf8 = function ( s )
middle[i3] = new Array(numSqrtArea); {
} if(qrcode.isUrl(s))
for (var ay = 0; ay < numSqrtArea; ay++) return qrcode.decode_url(s);
{ else
for (var ax = 0; ax < numSqrtArea; ax++) return s;
{ }
middle[ax][ay] = Math.floor((minmax[ax][ay][0] + minmax[ax][ay][1]) / 2);
//Console.out.print(middle[ax][ay] + ","); qrcode.process = function(ctx){
}
//Console.out.println(""); var start = new Date().getTime();
}
//Console.out.println(""); var image = qrcode.grayScaleToBitmap(qrcode.grayscale());
//var image = qrcode.binarize(128);
return middle;
} if(qrcode.debug)
{
qrcode.grayScaleToBitmap=function(grayScale) for (var y = 0; y < qrcode.height; y++)
{ {
var middle = qrcode.getMiddleBrightnessPerArea(grayScale); for (var x = 0; x < qrcode.width; x++)
var sqrtNumArea = middle.length; {
var areaWidth = Math.floor(qrcode.width / sqrtNumArea); var point = (x * 4) + (y * qrcode.width * 4);
var areaHeight = Math.floor(qrcode.height / sqrtNumArea); qrcode.imagedata.data[point] = image[x+y*qrcode.width]?0:0;
var bitmap = new Array(qrcode.height*qrcode.width); qrcode.imagedata.data[point+1] = image[x+y*qrcode.width]?0:0;
qrcode.imagedata.data[point+2] = image[x+y*qrcode.width]?255:0;
for (var ay = 0; ay < sqrtNumArea; ay++) }
{ }
for (var ax = 0; ax < sqrtNumArea; ax++) ctx.putImageData(qrcode.imagedata, 0, 0);
{ }
for (var dy = 0; dy < areaHeight; dy++)
{ //var finderPatternInfo = new FinderPatternFinder().findFinderPattern(image);
for (var dx = 0; dx < areaWidth; dx++)
{ var detector = new Detector(image);
bitmap[areaWidth * ax + dx+ (areaHeight * ay + dy)*qrcode.width] = (grayScale[areaWidth * ax + dx+ (areaHeight * ay + dy)*qrcode.width] < middle[ax][ay])?true:false;
} var qRCodeMatrix = detector.detect();
}
} if(qrcode.debug)
} {
return bitmap; for (var y = 0; y < qRCodeMatrix.bits.Height; y++)
} {
for (var x = 0; x < qRCodeMatrix.bits.Width; x++)
qrcode.grayscale = function(){ {
var ret = new Array(qrcode.width*qrcode.height); var point = (x * 4*2) + (y*2 * qrcode.width * 4);
for (var y = 0; y < qrcode.height; y++) 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;
for (var x = 0; x < qrcode.width; x++) qrcode.imagedata.data[point+2] = qRCodeMatrix.bits.get_Renamed(x,y)?255:0;
{ }
var gray = qrcode.getPixel(x, y); }
ctx.putImageData(qrcode.imagedata, 0, 0);
ret[x+y*qrcode.width] = gray; }
}
}
return ret; var reader = Decoder.decode(qRCodeMatrix.bits);
} var data = reader.DataByte;
var str="";
for(var i=0;i<data.length;i++)
{
for(var j=0;j<data[i].length;j++)
function URShift( number, bits) str+=String.fromCharCode(data[i][j]);
{ }
if (number >= 0)
return number >> bits; var end = new Date().getTime();
else var time = end - start;
return (number >> bits) + (2 << ~bits); console.log(time);
}
return qrcode.decode_utf8(str);
//alert("Time:" + time + " Code: "+str);
Array.prototype.remove = function(from, to) { }
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from; qrcode.getPixel = function(x,y){
return this.push.apply(this, rest); if (qrcode.width < x) {
}; throw "point error";
}
if (qrcode.height < y) {
throw "point error";
}
var point = (x * 4) + (y * qrcode.width * 4);
var p = (qrcode.imagedata.data[point]*33 + qrcode.imagedata.data[point + 1]*34 + qrcode.imagedata.data[point + 2]*33)/100;
return p;
}
qrcode.binarize = function(th){
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<=th?true:false;
}
}
return ret;
}
qrcode.getMiddleBrightnessPerArea=function(image)
{
var numSqrtArea = 4;
//obtain middle brightness((min + max) / 2) per area
var areaWidth = Math.floor(qrcode.width / numSqrtArea);
var areaHeight = Math.floor(qrcode.height / numSqrtArea);
var minmax = new Array(numSqrtArea);
for (var i = 0; i < numSqrtArea; i++)
{
minmax[i] = new Array(numSqrtArea);
for (var i2 = 0; i2 < numSqrtArea; i2++)
{
minmax[i][i2] = new Array(0,0);
}
}
for (var ay = 0; ay < numSqrtArea; ay++)
{
for (var ax = 0; ax < numSqrtArea; ax++)
{
minmax[ax][ay][0] = 0xFF;
for (var dy = 0; dy < areaHeight; dy++)
{
for (var dx = 0; dx < areaWidth; dx++)
{
var target = image[areaWidth * ax + dx+(areaHeight * ay + dy)*qrcode.width];
if (target < minmax[ax][ay][0])
minmax[ax][ay][0] = target;
if (target > 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);
}

View file

@ -36,9 +36,9 @@ function ReedSolomonDecoder(field)
for (var i = 0; i < twoS; i++) for (var i = 0; i < twoS; i++)
{ {
// Thanks to sanfordsquires for this fix: // Thanks to sanfordsquires for this fix:
var eval = poly.evaluateAt(this.field.exp(dataMatrix?i + 1:i)); var evalu = poly.evaluateAt(this.field.exp(dataMatrix?i + 1:i));
syndromeCoefficients[syndromeCoefficients.length - 1 - i] = eval; syndromeCoefficients[syndromeCoefficients.length - 1 - i] = evalu;
if (eval != 0) if (evalu != 0)
{ {
noError = false; noError = false;
} }

View file

@ -1,278 +1,261 @@
/* /*
Ported to JavaScript by Lazar Laszlo 2011 Ported to JavaScript by Lazar Laszlo 2011
lazarsoft@gmail.com, www.lazarsoft.info lazarsoft@gmail.com, www.lazarsoft.info
*/ */
/* /*
* *
* Copyright 2007 ZXing authors * Copyright 2007 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
function ECB(count, dataCodewords) function ECB(count, dataCodewords)
{ {
this.count = count; this.count = count;
this.dataCodewords = dataCodewords; this.dataCodewords = dataCodewords;
Object.defineProperties(this, { this.__defineGetter__("Count", function()
'Count': { {
get: function () { return this.count;
return this.count; });
} this.__defineGetter__("DataCodewords", function()
}, {
return this.dataCodewords;
'DataCodewords': { });
get: function () { }
return this.dataCodewords;
} function ECBlocks( ecCodewordsPerBlock, ecBlocks1, ecBlocks2)
} {
}); this.ecCodewordsPerBlock = ecCodewordsPerBlock;
} if(ecBlocks2)
this.ecBlocks = new Array(ecBlocks1, ecBlocks2);
function ECBlocks( ecCodewordsPerBlock, ecBlocks1, ecBlocks2) else
{ this.ecBlocks = new Array(ecBlocks1);
this.ecCodewordsPerBlock = ecCodewordsPerBlock;
this.__defineGetter__("ECCodewordsPerBlock", function()
if (ecBlocks2) {
this.ecBlocks = new Array(ecBlocks1, ecBlocks2); return this.ecCodewordsPerBlock;
else });
this.ecBlocks = new Array(ecBlocks1);
this.__defineGetter__("TotalECCodewords", function()
Object.defineProperties(this, { {
"ECCodewordsPerBlock": { return this.ecCodewordsPerBlock * this.NumBlocks;
get: function () { });
return this.ecCodewordsPerBlock;
this.__defineGetter__("NumBlocks", function()
} {
}, var total = 0;
for (var i = 0; i < this.ecBlocks.length; i++)
"TotalECCodewords": { {
get: function () { total += this.ecBlocks[i].length;
return this.ecCodewordsPerBlock * this.NumBlocks; }
} return total;
}, });
"NumBlocks": { this.getECBlocks=function()
get: function () { {
var total = 0; return this.ecBlocks;
}
for (var i = 0; i < this.ecBlocks.length; i++) }
total += this.ecBlocks[i].length;
function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4)
return total; {
} this.versionNumber = versionNumber;
} this.alignmentPatternCenters = alignmentPatternCenters;
}); this.ecBlocks = new Array(ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4);
this.getECBlocks = function() { var total = 0;
return this.ecBlocks; var ecCodewords = ecBlocks1.ECCodewordsPerBlock;
}; var ecbArray = ecBlocks1.getECBlocks();
} for (var i = 0; i < ecbArray.length; i++)
{
function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4) var ecBlock = ecbArray[i];
{ total += ecBlock.Count * (ecBlock.DataCodewords + ecCodewords);
this.versionNumber = versionNumber; }
this.alignmentPatternCenters = alignmentPatternCenters; this.totalCodewords = total;
this.ecBlocks = new Array(ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4);
this.__defineGetter__("VersionNumber", function()
var total = 0; {
var ecCodewords = ecBlocks1.ECCodewordsPerBlock; return this.versionNumber;
var ecbArray = ecBlocks1.getECBlocks(); });
for (var i = 0; i < ecbArray.length; i++)
{ this.__defineGetter__("AlignmentPatternCenters", function()
var ecBlock = ecbArray[i]; {
total += ecBlock.Count * (ecBlock.DataCodewords + ecCodewords); return this.alignmentPatternCenters;
} });
this.totalCodewords = total; this.__defineGetter__("TotalCodewords", function()
{
Object.defineProperties(this, { return this.totalCodewords;
"VersionNumber": { });
get: function () { this.__defineGetter__("DimensionForVersion", function()
return this.versionNumber; {
} return 17 + 4 * this.versionNumber;
}, });
"AlignmentPatternCenters": { this.buildFunctionPattern=function()
get: function () { {
return this.alignmentPatternCenters; var dimension = this.DimensionForVersion;
} var bitMatrix = new BitMatrix(dimension);
},
"TotalCodewords": { // Top left finder pattern + separator + format
get: function () { bitMatrix.setRegion(0, 0, 9, 9);
return this.totalCodewords; // Top right finder pattern + separator + format
} bitMatrix.setRegion(dimension - 8, 0, 8, 9);
}, // Bottom left finder pattern + separator + format
"DimensionForVersion": { bitMatrix.setRegion(0, dimension - 8, 9, 8);
get: function () {
return 17 + 4 * this.versionNumber; // Alignment patterns
} var max = this.alignmentPatternCenters.length;
} for (var x = 0; x < max; x++)
}); {
var i = this.alignmentPatternCenters[x] - 2;
this.buildFunctionPattern=function() for (var y = 0; y < max; y++)
{ {
var dimension = this.DimensionForVersion; if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0))
var bitMatrix = new BitMatrix(dimension); {
// No alignment patterns near the three finder paterns
// Top left finder pattern + separator + format continue;
bitMatrix.setRegion(0, 0, 9, 9); }
// Top right finder pattern + separator + format bitMatrix.setRegion(this.alignmentPatternCenters[y] - 2, i, 5, 5);
bitMatrix.setRegion(dimension - 8, 0, 8, 9); }
// Bottom left finder pattern + separator + format }
bitMatrix.setRegion(0, dimension - 8, 9, 8);
// Vertical timing pattern
// Alignment patterns bitMatrix.setRegion(6, 9, 1, dimension - 17);
var max = this.alignmentPatternCenters.length; // Horizontal timing pattern
for (var x = 0; x < max; x++) bitMatrix.setRegion(9, 6, dimension - 17, 1);
{
var i = this.alignmentPatternCenters[x] - 2; if (this.versionNumber > 6)
for (var y = 0; y < max; y++) {
{ // Version info, top right
if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) bitMatrix.setRegion(dimension - 11, 0, 3, 6);
{ // Version info, bottom left
// No alignment patterns near the three finder paterns bitMatrix.setRegion(0, dimension - 11, 6, 3);
continue; }
}
bitMatrix.setRegion(this.alignmentPatternCenters[y] - 2, i, 5, 5); return bitMatrix;
} }
} this.getECBlocksForLevel=function( ecLevel)
{
// Vertical timing pattern return this.ecBlocks[ecLevel.ordinal()];
bitMatrix.setRegion(6, 9, 1, dimension - 17); }
// Horizontal timing pattern }
bitMatrix.setRegion(9, 6, dimension - 17, 1);
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);
if (this.versionNumber > 6)
{ Version.VERSIONS = buildVersions();
// Version info, top right
bitMatrix.setRegion(dimension - 11, 0, 3, 6); Version.getVersionForNumber=function( versionNumber)
// Version info, bottom left {
bitMatrix.setRegion(0, dimension - 11, 6, 3); if (versionNumber < 1 || versionNumber > 40)
} {
throw "ArgumentException";
return bitMatrix; }
} return Version.VERSIONS[versionNumber - 1];
this.getECBlocksForLevel=function( ecLevel) }
{
return this.ecBlocks[ecLevel.ordinal()]; Version.getProvisionalVersionForDimension=function(dimension)
} {
} if (dimension % 4 != 1)
{
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); throw "Error getProvisionalVersionForDimension";
}
Version.VERSIONS = buildVersions(); try
{
Version.getVersionForNumber=function( versionNumber) return Version.getVersionForNumber((dimension - 17) >> 2);
{ }
if (versionNumber < 1 || versionNumber > 40) catch ( iae)
{ {
throw "ArgumentException"; throw "Error getVersionForNumber";
} }
return Version.VERSIONS[versionNumber - 1]; }
}
Version.decodeVersionInformation=function( versionBits)
Version.getProvisionalVersionForDimension=function(dimension) {
{ var bestDifference = 0xffffffff;
if (dimension % 4 != 1) var bestVersion = 0;
{ for (var i = 0; i < Version.VERSION_DECODE_INFO.length; i++)
throw "Error getProvisionalVersionForDimension"; {
} var targetVersion = Version.VERSION_DECODE_INFO[i];
try // Do the version info bits match exactly? done.
{ if (targetVersion == versionBits)
return Version.getVersionForNumber((dimension - 17) >> 2); {
} return this.getVersionForNumber(i + 7);
catch ( iae) }
{ // Otherwise see if this is the closest to a real version info bit string
throw "Error getVersionForNumber"; // we have seen so far
} var bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion);
} if (bitsDifference < bestDifference)
{
Version.decodeVersionInformation=function( versionBits) bestVersion = i + 7;
{ bestDifference = bitsDifference;
var bestDifference = 0xffffffff; }
var bestVersion = 0; }
for (var i = 0; i < Version.VERSION_DECODE_INFO.length; i++) // We can tolerate up to 3 bits of error since no two version info codewords will
{ // differ in less than 4 bits.
var targetVersion = Version.VERSION_DECODE_INFO[i]; if (bestDifference <= 3)
// Do the version info bits match exactly? done. {
if (targetVersion == versionBits) return this.getVersionForNumber(bestVersion);
{ }
return this.getVersionForNumber(i + 7); // If we didn't find a close enough match, fail
} return null;
// 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); function buildVersions()
if (bitsDifference < bestDifference) {
{ 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))),
bestVersion = i + 7; 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))),
bestDifference = bitsDifference; 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))),
// We can tolerate up to 3 bits of error since no two version info codewords will 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))),
// differ in less than 4 bits. 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))),
if (bestDifference <= 3) 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))),
return this.getVersionForNumber(bestVersion); 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))),
// If we didn't find a close enough match, fail 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))),
return null; 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))),
function buildVersions() 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))),
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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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))));
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))));
}

View file

@ -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){ function generateTable(version){
qr_array = JSON.parse(JSON.stringify(qr_templates[version-1])); qr_array = JSON.parse(JSON.stringify(qr_templates[version-1]));
changed_state = false; changed_state = false;
@ -57,6 +66,11 @@ function generateTable(version){
updateHistory("New QR code"); updateHistory("New QR code");
} }
/***
*
* get format information value
*
***/
function getInformation(size){ function getInformation(size){
//Information top-left beside Finder //Information top-left beside Finder
for(var i=0; i < 9; i++){ 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){ function generateInfoTable(position){
position = position || "TOP_LEFT"; position = position || "TOP_LEFT";
@ -134,7 +152,11 @@ function generateInfoTable(position){
} }
/***
*
* Save format information value to qr_format_array
*
***/
function saveInfoTable(size){ function saveInfoTable(size){
for(var i=0; i < 8; i++){ for(var i=0; i < 8; i++){
if(i > 5) if(i > 5)
@ -158,6 +180,11 @@ function saveInfoTable(size){
changed_state = true; changed_state = true;
} }
/***
*
* Reload QR table based on qr_array value
*
***/
function refreshTable(){ function refreshTable(){
for(var i=0; i < qr_array.length; i++){ for(var i=0; i < qr_array.length; i++){
for(var j=0; j < qr_array[i].length; j++){ 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){ function updateQRArray(new_data){
for(var i=0; i < qr_array.length; i++){ for(var i=0; i < qr_array.length; i++){
for(var j=0; j < qr_array[i].length; j++){ 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(){ function getInfoBits(){
var result = {ecc:"",mask:-1}; var result = {ecc:"",mask:-1};
$("#slider-mask div.active").removeClass("active"); $("#slider-mask div.active").removeClass("active");
@ -224,6 +281,11 @@ function getInfoBits(){
return result; return result;
} }
/***
*
* generate QR code made from canvas based on qr_array values
*
***/
function generateResult(){ function generateResult(){
var c = document.getElementById("qr-result"); var c = document.getElementById("qr-result");
@ -262,17 +324,32 @@ function generateResult(){
$("body").css("background-color","#FFFFFF"); $("body").css("background-color","#FFFFFF");
} }
/***
*
* Update toolbox values
*
***/
function updateToolbox(){ function updateToolbox(){
$("#qr-version").val(qr_size+"x"+qr_size+" (ver. "+qr_version+")"); $("#qr-version").val(qr_size+"x"+qr_size+" (ver. "+qr_version+")");
$("#qr-size").val(qr_pixel_size+"px"); $("#qr-size").val(qr_pixel_size+"px");
} }
/***
*
* Resize QR size
*
***/
function resize(size){ function resize(size){
$("td").each(function(){ $("td").each(function(){
$(this).css({"min-width":size+"px","min-height":size+"px","width":size+"px","height":size+"px"}); $(this).css({"min-width":size+"px","min-height":size+"px","width":size+"px","height":size+"px"});
}) })
} }
/***
*
* Toggle between Editor and Decode mode
*
***/
function toggleResult(){ function toggleResult(){
if(!$("#btn-switch-mode").hasClass("active")){ if(!$("#btn-switch-mode").hasClass("active")){
$(".mode-indicator button").removeClass("active"); $(".mode-indicator button").removeClass("active");
@ -313,6 +390,11 @@ function toggleResult(){
} }
} }
/***
*
* Load image from file and put to {target}
*
***/
function loadImage(input, target){ function loadImage(input, target){
if(input.files && input.files[0]){ if(input.files && input.files[0]){
var reader = new FileReader(); var reader = new FileReader();
@ -324,6 +406,11 @@ function loadImage(input, target){
} }
} }
/***
*
* Save project to LocalStorage
*
***/
function saveProject(projectName){ function saveProject(projectName){
if(projectName == ""){ if(projectName == ""){
@ -354,6 +441,11 @@ function saveProject(projectName){
changed_state = false; changed_state = false;
} }
/***
*
* Load project from LocalStorage
*
***/
function loadProject(name){ function loadProject(name){
if(changed_state){ if(changed_state){
if(!confirm("Are you sure want to proceed?\nYour unsaved progress will be lost!")) if(!confirm("Are you sure want to proceed?\nYour unsaved progress will be lost!"))
@ -385,6 +477,11 @@ function loadProject(name){
updateHistory("Load project"); updateHistory("Load project");
} }
/***
*
* Remove project from LocalStorage
*
***/
function removeProject(name, origin){ function removeProject(name, origin){
if(confirm("Are you sure want to permanently delete this project?")){ if(confirm("Are you sure want to permanently delete this project?")){
var dataList = JSON.parse(localStorage.getItem("dataList")); var dataList = JSON.parse(localStorage.getItem("dataList"));
@ -404,6 +501,11 @@ function removeProject(name, origin){
} }
} }
/***
*
* Refresh list of project in LocalStorage
*
***/
function refreshLoadList(origin){ function refreshLoadList(origin){
var dataList = JSON.parse(localStorage.getItem("dataList")); var dataList = JSON.parse(localStorage.getItem("dataList"));
if(dataList == undefined){ if(dataList == undefined){
@ -417,6 +519,11 @@ function refreshLoadList(origin){
} }
} }
/***
*
* Decode Base64 to image
*
***/
function decodeFromBase64(img, callback){ function decodeFromBase64(img, callback){
qrcode.callback = callback; qrcode.callback = callback;
qrcode.decode(img, callback); qrcode.decode(img, callback);
@ -463,7 +570,7 @@ function importFromImage(src, cb){
var qrArray = qRCodeMatrix.bits.bits; var qrArray = qRCodeMatrix.bits.bits;
var size = qRCodeMatrix.bits.width; var size = qRCodeMatrix.bits.width;
if(size > 41){ if(size > 53){
alert("QR version is unsupported"); alert("QR version is unsupported");
return; return;
} }
@ -484,7 +591,14 @@ function importFromImage(src, cb){
img.src = src; 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){ function floodFill(x, y, oldVal, newVal){
x = parseInt(x); x = parseInt(x);
@ -517,6 +631,11 @@ function floodFill(x, y, oldVal, newVal){
} }
} }
/***
*
* Update history
*
***/
function updateHistory(msg){ function updateHistory(msg){
if(active_history < 10) active_history++; if(active_history < 10) active_history++;
@ -538,6 +657,11 @@ function updateHistory(msg){
$(".history").html(html); $(".history").html(html);
} }
/***
*
* Get history value and refresh QR table
*
***/
function getHistory(index){ function getHistory(index){
qr_array = JSON.parse(history_array[index][1]); qr_array = JSON.parse(history_array[index][1]);
if(qr_array.length != qr_size){ if(qr_array.length != qr_size){
@ -548,6 +672,11 @@ function getHistory(index){
refreshTable(); refreshTable();
} }
/***
*
* Clear all history value
*
***/
function clearHistory(){ function clearHistory(){
history_array = []; history_array = [];
active_history = -1; active_history = -1;
@ -691,6 +820,11 @@ function bruteForceFormatInfo(){
} }
} }
/***
*
* Mask qr_array with mask_pattern and refresh QR table
*
***/
function maskDataBits(){ function maskDataBits(){
var mask_pattern = getFormatInfo(qr_array).mask; var mask_pattern = getFormatInfo(qr_array).mask;
qr_array = maskData(qr_array, mask_pattern); qr_array = maskData(qr_array, mask_pattern);
@ -787,9 +921,15 @@ function recoverPadding(){
qr_temp_array = Array.prototype.slice.call(result.result_array); qr_temp_array = Array.prototype.slice.call(result.result_array);
} }
/***
*
* Perform Reed-Solomon decode
*
***/
function reedSolomonDecode(data, nysm){ function reedSolomonDecode(data, nysm){
var result = []; var result = [];
//console.log('nysm: '+nysm, 'data: '+data);
for(var i=0; i < data.length; i++){ for(var i=0; i < data.length; i++){
var err_pos = []; var err_pos = [];
@ -1155,6 +1295,12 @@ function updateBlock(value, cls){
} }
/*******************************************************************
*
* EVENT LISTENER USING JQUERY
*
********************************************************************/
$(document).ready(function(){ $(document).ready(function(){
@ -1308,7 +1454,7 @@ $(document).ready(function(){
$("#btn-version-plus").click(function(){ $("#btn-version-plus").click(function(){
if(changed_state){ if(changed_state){
if(confirm("Are you sure want to proceed?\nYour unsaved progress will be lost!")){ 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_version += 1;
qr_size = 17+(qr_version*4); qr_size = 17+(qr_version*4);
$("#qr-version").val(qr_size+"x"+qr_size+" (ver. "+qr_version+")"); $("#qr-version").val(qr_size+"x"+qr_size+" (ver. "+qr_version+")");
@ -1316,7 +1462,7 @@ $(document).ready(function(){
} }
} }
} else { } else {
if(qr_version != 6){ if(qr_version != 9){
qr_version += 1; qr_version += 1;
qr_size = 17+(qr_version*4); qr_size = 17+(qr_version*4);
$("#qr-version").val(qr_size+"x"+qr_size+" (ver. "+qr_version+")"); $("#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(){ $("#mobile-editor-mode, #mobile-decode-mode").click(function(){
toggleResult(); toggleResult();

View file

@ -433,6 +433,8 @@ function rs_forney_syndromes(synd, pos, nmess){
function rs_correct_msg(msg_in, nysm, erase_pos){ function rs_correct_msg(msg_in, nysm, erase_pos){
console.log(msg_in);
erase_pos = erase_pos || undefined; erase_pos = erase_pos || undefined;
var msg_len = msg_in.length - nysm; var msg_len = msg_in.length - nysm;

View file

@ -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; return is_data_module;
} }
@ -905,7 +918,7 @@ function QRDecode(data){
//TODO: Kanji mode //TODO: Kanji mode
break; break;
} else { } else {
console.log("[ERROR]: Invalid Encoding mode"); console.log("[ERROR]: Invalid Encoding mode", mode);
result.error.push("Invalid Encoding mode"); result.error.push("Invalid Encoding mode");
break; break;
} }

View file

@ -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 = { var function_pattern_with_format_info = {
/* /*
0 : white 0 : white
@ -53,7 +53,10 @@ var alignment_pattern_array = [
[6, 22], [6, 22],
[6, 26], [6, 26],
[6, 30], [6, 30],
[6, 34] [6, 34],
[6, 22, 38],
[6, 24, 42],
[6, 26, 46]
]; ];
var format_information_bits_raw = { var format_information_bits_raw = {
@ -226,13 +229,23 @@ var format_information_unmask = [
'111111111111111' '111111111111111'
]; ];
//Version information table for QR version 7 and higher
var version_information_table = [
000111110010010100,
001000010110111100,
001001101010011001
]
var data_code_num_table = [ var data_code_num_table = [
[ 16, 19, 9, 13], [ 16, 19, 9, 13],
[ 28, 34, 16, 22], [ 28, 34, 16, 22],
[ 44, 55, 26, 34], [ 44, 55, 26, 34],
[ 64, 80, 36, 48], [ 64, 80, 36, 48],
[ 86, 108, 46, 62], [ 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 = [ var RS_block_num_table = [
@ -241,7 +254,10 @@ var RS_block_num_table = [
[1, 1, 2, 2], [1, 1, 2, 2],
[2, 1, 4, 2], [2, 1, 4, 2],
[2, 1, 4, 4], [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 = [ var alphanumeric_table = [
@ -261,14 +277,17 @@ var error_correction_code_table = [
[26,15,22,18], [26,15,22,18],
[18,20,16,26], [18,20,16,26],
[24,26,22,18], [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 0 : white
1 : black 1 : black
@ -277,6 +296,9 @@ var remainder_bits_table = [0,7,7,7,7,7];
*************************************************************/ *************************************************************/
var qr_templates = [ 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,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,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], [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,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,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], [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,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,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], [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,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,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], [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,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,-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