mirror of
https://github.com/nimiq/qr-scanner.git
synced 2026-07-27 19:56:28 +00:00
use closure-compiler
This commit is contained in:
+33
-42
@@ -1,47 +1,38 @@
|
||||
var gulp = require('gulp');
|
||||
var concat = require('gulp-concat');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
var babel = require('gulp-babel');
|
||||
var merge = require('merge2');
|
||||
var uglify = require('gulp-uglify');
|
||||
var closureCompiler = require('google-closure-compiler').gulp();
|
||||
|
||||
gulp.task('build', function() {
|
||||
return merge(
|
||||
gulp.src('./src/prefix.js')
|
||||
.pipe(sourcemaps.init()),
|
||||
|
||||
gulp.src([
|
||||
'./src/worker.js',
|
||||
'./src/binarizer.js',
|
||||
'./src/grid.js',
|
||||
'./src/version.js',
|
||||
'./src/detector.js',
|
||||
'./src/formatinf.js',
|
||||
'./src/errorlevel.js',
|
||||
'./src/bitmat.js',
|
||||
'./src/datablock.js',
|
||||
'./src/bmparser.js',
|
||||
'./src/datamask.js',
|
||||
'./src/rsdecoder.js',
|
||||
'./src/gf256poly.js',
|
||||
'./src/gf256.js',
|
||||
'./src/decoder.js',
|
||||
'./src/qrcode.js',
|
||||
'./src/findpat.js',
|
||||
'./src/alignpat.js',
|
||||
'./src/databr.js'
|
||||
])
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(concat('tmp.js'))
|
||||
.pipe(babel({
|
||||
presets: ['env']
|
||||
})),
|
||||
|
||||
gulp.src('./src/suffix.js')
|
||||
.pipe(sourcemaps.init())
|
||||
)
|
||||
.pipe(concat('qr-scanner-worker.min.js'))
|
||||
.pipe(uglify())
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest('.'));
|
||||
return gulp.src([
|
||||
'./src/worker.js',
|
||||
'./src/binarizer.js',
|
||||
'./src/grid.js',
|
||||
'./src/version.js',
|
||||
'./src/detector.js',
|
||||
'./src/formatinf.js',
|
||||
'./src/errorlevel.js',
|
||||
'./src/bitmat.js',
|
||||
'./src/datablock.js',
|
||||
'./src/bmparser.js',
|
||||
'./src/datamask.js',
|
||||
'./src/rsdecoder.js',
|
||||
'./src/gf256poly.js',
|
||||
'./src/gf256.js',
|
||||
'./src/decoder.js',
|
||||
'./src/qrcode.js',
|
||||
'./src/findpat.js',
|
||||
'./src/alignpat.js',
|
||||
'./src/databr.js'
|
||||
], { base: './' })
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(closureCompiler({
|
||||
compilation_level: 'ADVANCED',
|
||||
warning_level: 'DEFAULT',
|
||||
language_in: 'ECMASCRIPT6_STRICT',
|
||||
language_out: 'ECMASCRIPT5_STRICT',
|
||||
output_wrapper: '(function(){\n%output%\n}).call(this)',
|
||||
js_output_file: 'qr-scanner-worker.min.js'
|
||||
}))
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest('.'));
|
||||
});
|
||||
+2
-7
@@ -25,13 +25,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/nimiq/qr-scanner#readme",
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"google-closure-compiler": "^20171112.0.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-babel": "^7.0.0",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-sourcemaps": "^2.6.1",
|
||||
"gulp-uglify": "^3.0.0",
|
||||
"merge2": "^1.2.0"
|
||||
"gulp-sourcemaps": "^2.6.1"
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+66
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+8
-12
@@ -30,22 +30,18 @@ function AlignmentPattern(posX, posY, estimatedModuleSize)
|
||||
this.count = 1;
|
||||
this.estimatedModuleSize = estimatedModuleSize;
|
||||
|
||||
this.__defineGetter__("EstimatedModuleSize", function()
|
||||
{
|
||||
this.getEstimatedModuleSize = function() {
|
||||
return this.estimatedModuleSize;
|
||||
});
|
||||
this.__defineGetter__("Count", function()
|
||||
{
|
||||
};
|
||||
this.getCount = function() {
|
||||
return this.count;
|
||||
});
|
||||
this.__defineGetter__("X", function()
|
||||
{
|
||||
};
|
||||
this.getX = function() {
|
||||
return Math.floor(this.x);
|
||||
});
|
||||
this.__defineGetter__("Y", function()
|
||||
{
|
||||
};
|
||||
this.getY = function() {
|
||||
return Math.floor(this.y);
|
||||
});
|
||||
};
|
||||
this.incrementCount = function()
|
||||
{
|
||||
this.count++;
|
||||
|
||||
+6
-6
@@ -43,22 +43,22 @@ function BitMatrix( width, height)
|
||||
for(var i=0;i<this.bits.length;i++)
|
||||
this.bits[i]=0;
|
||||
|
||||
this.__defineGetter__("Width", function()
|
||||
this.getWidth = function()
|
||||
{
|
||||
return this.width;
|
||||
});
|
||||
this.__defineGetter__("Height", function()
|
||||
};
|
||||
this.getHeight = function()
|
||||
{
|
||||
return this.height;
|
||||
});
|
||||
this.__defineGetter__("Dimension", function()
|
||||
};
|
||||
this.getDimension = function()
|
||||
{
|
||||
if (this.width != this.height)
|
||||
{
|
||||
throw new Error("QR Error: Can't call getDimension() on a non-square matrix");
|
||||
}
|
||||
return this.width;
|
||||
});
|
||||
};
|
||||
|
||||
this.get_Renamed=function( x, y)
|
||||
{
|
||||
|
||||
+9
-9
@@ -25,7 +25,7 @@
|
||||
|
||||
function BitMatrixParser(bitMatrix)
|
||||
{
|
||||
var dimension = bitMatrix.Dimension;
|
||||
var dimension = bitMatrix.getDimension();
|
||||
if (dimension < 21 || (dimension & 0x03) != 1)
|
||||
{
|
||||
throw new Error("QR Error: Error BitMatrixParser");
|
||||
@@ -69,7 +69,7 @@ function BitMatrixParser(bitMatrix)
|
||||
}
|
||||
|
||||
// Hmm, failed. Try the top-right/bottom-left pattern
|
||||
var dimension = this.bitMatrix.Dimension;
|
||||
var dimension = this.bitMatrix.getDimension();
|
||||
formatInfoBits = 0;
|
||||
var iMin = dimension - 8;
|
||||
for (var i = dimension - 1; i >= iMin; i--)
|
||||
@@ -96,7 +96,7 @@ function BitMatrixParser(bitMatrix)
|
||||
return this.parsedVersion;
|
||||
}
|
||||
|
||||
var dimension = this.bitMatrix.Dimension;
|
||||
var dimension = this.bitMatrix.getDimension();
|
||||
|
||||
var provisionalVersion = (dimension - 17) >> 2;
|
||||
if (provisionalVersion <= 6)
|
||||
@@ -116,7 +116,7 @@ function BitMatrixParser(bitMatrix)
|
||||
}
|
||||
|
||||
this.parsedVersion = Version.decodeVersionInformation(versionBits);
|
||||
if (this.parsedVersion != null && this.parsedVersion.DimensionForVersion == dimension)
|
||||
if (this.parsedVersion != null && this.parsedVersion.getDimensionForVersion() == dimension)
|
||||
{
|
||||
return this.parsedVersion;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ function BitMatrixParser(bitMatrix)
|
||||
}
|
||||
|
||||
this.parsedVersion = Version.decodeVersionInformation(versionBits);
|
||||
if (this.parsedVersion != null && this.parsedVersion.DimensionForVersion == dimension)
|
||||
if (this.parsedVersion != null && this.parsedVersion.getDimensionForVersion() == dimension)
|
||||
{
|
||||
return this.parsedVersion;
|
||||
}
|
||||
@@ -146,14 +146,14 @@ function BitMatrixParser(bitMatrix)
|
||||
|
||||
// Get the data mask for the format used in this QR Code. This will exclude
|
||||
// some bits from reading as we wind through the bit matrix.
|
||||
var dataMask = DataMask.forReference( formatInfo.DataMask);
|
||||
var dimension = this.bitMatrix.Dimension;
|
||||
var dataMask = DataMask.forReference( formatInfo.getDataMask());
|
||||
var dimension = this.bitMatrix.getDimension();
|
||||
dataMask.unmaskBitMatrix(this.bitMatrix, dimension);
|
||||
|
||||
var functionPattern = version.buildFunctionPattern();
|
||||
|
||||
var readingUp = true;
|
||||
var result = new Array(version.TotalCodewords);
|
||||
var result = new Array(version.getTotalCodewords());
|
||||
var resultOffset = 0;
|
||||
var currentByte = 0;
|
||||
var bitsRead = 0;
|
||||
@@ -194,7 +194,7 @@ function BitMatrixParser(bitMatrix)
|
||||
}
|
||||
readingUp ^= true; // readingUp = !readingUp; // switch directions
|
||||
}
|
||||
if (resultOffset != version.TotalCodewords)
|
||||
if (resultOffset != version.getTotalCodewords())
|
||||
{
|
||||
throw new Error("QR Error: Error readCodewords");
|
||||
}
|
||||
|
||||
+10
-10
@@ -28,20 +28,20 @@ function DataBlock(numDataCodewords, codewords)
|
||||
this.numDataCodewords = numDataCodewords;
|
||||
this.codewords = codewords;
|
||||
|
||||
this.__defineGetter__("NumDataCodewords", function()
|
||||
this.getNumDataCodewords = function()
|
||||
{
|
||||
return this.numDataCodewords;
|
||||
});
|
||||
this.__defineGetter__("Codewords", function()
|
||||
};
|
||||
this.getCodewords = function()
|
||||
{
|
||||
return this.codewords;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
DataBlock.getDataBlocks=function(rawCodewords, version, ecLevel)
|
||||
{
|
||||
|
||||
if (rawCodewords.length != version.TotalCodewords)
|
||||
if (rawCodewords.length != version.getTotalCodewords())
|
||||
{
|
||||
throw new Error("QR Error: ArgumentException");
|
||||
}
|
||||
@@ -55,7 +55,7 @@ DataBlock.getDataBlocks=function(rawCodewords, version, ecLevel)
|
||||
var ecBlockArray = ecBlocks.getECBlocks();
|
||||
for (var i = 0; i < ecBlockArray.length; i++)
|
||||
{
|
||||
totalBlocks += ecBlockArray[i].Count;
|
||||
totalBlocks += ecBlockArray[i].getCount();
|
||||
}
|
||||
|
||||
// Now establish DataBlocks of the appropriate size and number of data codewords
|
||||
@@ -64,10 +64,10 @@ DataBlock.getDataBlocks=function(rawCodewords, version, ecLevel)
|
||||
for (var j = 0; j < ecBlockArray.length; j++)
|
||||
{
|
||||
var ecBlock = ecBlockArray[j];
|
||||
for (var i = 0; i < ecBlock.Count; i++)
|
||||
for (var i = 0; i < ecBlock.getCount(); i++)
|
||||
{
|
||||
var numDataCodewords = ecBlock.DataCodewords;
|
||||
var numBlockCodewords = ecBlocks.ECCodewordsPerBlock + numDataCodewords;
|
||||
var numDataCodewords = ecBlock.getDataCodewords();
|
||||
var numBlockCodewords = ecBlocks.getECCodewordsPerBlock() + numDataCodewords;
|
||||
result[numResultBlocks++] = new DataBlock(numDataCodewords, new Array(numBlockCodewords));
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ DataBlock.getDataBlocks=function(rawCodewords, version, ecLevel)
|
||||
}
|
||||
longerBlocksStartAt++;
|
||||
|
||||
var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ECCodewordsPerBlock;
|
||||
var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.getECCodewordsPerBlock();
|
||||
// The last elements of result may be 1 element longer;
|
||||
// first fill out as many elements as all of them have
|
||||
var rawCodewordsOffset = 0;
|
||||
|
||||
+2
-2
@@ -264,7 +264,7 @@ function QRCodeDataBlockReader(blocks, version, numErrorCorrectionCode)
|
||||
return intData;
|
||||
}
|
||||
|
||||
this.__defineGetter__("DataByte", function()
|
||||
this.getDataByte = function()
|
||||
{
|
||||
var output = new Array();
|
||||
var MODE_NUMBER = 1;
|
||||
@@ -332,5 +332,5 @@ function QRCodeDataBlockReader(blocks, version, numErrorCorrectionCode)
|
||||
}
|
||||
while (true);
|
||||
return output;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
+5
-5
@@ -58,7 +58,7 @@ Decoder.decode=function(bits)
|
||||
{
|
||||
var parser = new BitMatrixParser(bits);
|
||||
var version = parser.readVersion();
|
||||
var ecLevel = parser.readFormatInformation().ErrorCorrectionLevel;
|
||||
var ecLevel = parser.readFormatInformation().getErrorCorrectionLevel();
|
||||
|
||||
// Read codewords
|
||||
var codewords = parser.readCodewords();
|
||||
@@ -70,7 +70,7 @@ Decoder.decode=function(bits)
|
||||
var totalBytes = 0;
|
||||
for (var i = 0; i < dataBlocks.length; i++)
|
||||
{
|
||||
totalBytes += dataBlocks[i].NumDataCodewords;
|
||||
totalBytes += dataBlocks[i].getNumDataCodewords();
|
||||
}
|
||||
var resultBytes = new Array(totalBytes);
|
||||
var resultOffset = 0;
|
||||
@@ -79,8 +79,8 @@ Decoder.decode=function(bits)
|
||||
for (var j = 0; j < dataBlocks.length; j++)
|
||||
{
|
||||
var dataBlock = dataBlocks[j];
|
||||
var codewordBytes = dataBlock.Codewords;
|
||||
var numDataCodewords = dataBlock.NumDataCodewords;
|
||||
var codewordBytes = dataBlock.getCodewords();
|
||||
var numDataCodewords = dataBlock.getNumDataCodewords();
|
||||
Decoder.correctErrors(codewordBytes, numDataCodewords);
|
||||
for (var i = 0; i < numDataCodewords; i++)
|
||||
{
|
||||
@@ -89,7 +89,7 @@ Decoder.decode=function(bits)
|
||||
}
|
||||
|
||||
// Decode the contents of that stream of bytes
|
||||
var reader = new QRCodeDataBlockReader(resultBytes, version.VersionNumber, ecLevel.Bits);
|
||||
var reader = new QRCodeDataBlockReader(resultBytes, version.getVersionNumber(), ecLevel.getBits());
|
||||
return reader;
|
||||
//return DecodedBitStreamParser.decode(resultBytes, version, ecLevel);
|
||||
}
|
||||
|
||||
+21
-21
@@ -83,8 +83,8 @@ function PerspectiveTransform( a11, a21, a31, a12, a22, a32, a13, a23, a
|
||||
PerspectiveTransform.quadrilateralToQuadrilateral=function( x0, y0, x1, y1, x2, y2, x3, y3, x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p)
|
||||
{
|
||||
|
||||
var qToS = this.quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3);
|
||||
var sToQ = this.squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p);
|
||||
var qToS = PerspectiveTransform.quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3);
|
||||
var sToQ = PerspectiveTransform.squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p);
|
||||
return sToQ.times(qToS);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ PerspectiveTransform.squareToQuadrilateral=function( x0, y0, x1, y1, x2, y2
|
||||
PerspectiveTransform.quadrilateralToSquare=function( x0, y0, x1, y1, x2, y2, x3, y3)
|
||||
{
|
||||
// Here, the adjoint serves as the inverse:
|
||||
return this.squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint();
|
||||
return PerspectiveTransform.squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint();
|
||||
}
|
||||
|
||||
function DetectorResult(bits, points)
|
||||
@@ -234,8 +234,8 @@ function Detector(image)
|
||||
|
||||
this.calculateModuleSizeOneWay=function( pattern, otherPattern)
|
||||
{
|
||||
var moduleSizeEst1 = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor( pattern.X), Math.floor( pattern.Y), Math.floor( otherPattern.X), Math.floor(otherPattern.Y));
|
||||
var moduleSizeEst2 = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(otherPattern.X), Math.floor(otherPattern.Y), Math.floor( pattern.X), Math.floor(pattern.Y));
|
||||
var moduleSizeEst1 = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor( pattern.getX()), Math.floor( pattern.getY()), Math.floor( otherPattern.getX()), Math.floor(otherPattern.getY()));
|
||||
var moduleSizeEst2 = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(otherPattern.getX()), Math.floor(otherPattern.getY()), Math.floor( pattern.getX()), Math.floor(pattern.getY()));
|
||||
if (isNaN(moduleSizeEst1))
|
||||
{
|
||||
return moduleSizeEst2 / 7.0;
|
||||
@@ -258,8 +258,8 @@ function Detector(image)
|
||||
|
||||
this.distance=function( pattern1, pattern2)
|
||||
{
|
||||
var xDiff = pattern1.X - pattern2.X;
|
||||
var yDiff = pattern1.Y - pattern2.Y;
|
||||
var xDiff = pattern1.getX() - pattern2.getX();
|
||||
var yDiff = pattern1.getY() - pattern2.getY();
|
||||
return Math.sqrt( (xDiff * xDiff + yDiff * yDiff));
|
||||
}
|
||||
this.computeDimension=function( topLeft, topRight, bottomLeft, moduleSize)
|
||||
@@ -315,19 +315,19 @@ function Detector(image)
|
||||
var sourceBottomRightY;
|
||||
if (alignmentPattern != null)
|
||||
{
|
||||
bottomRightX = alignmentPattern.X;
|
||||
bottomRightY = alignmentPattern.Y;
|
||||
bottomRightX = alignmentPattern.getX();
|
||||
bottomRightY = alignmentPattern.getY();
|
||||
sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't have an alignment pattern, just make up the bottom-right point
|
||||
bottomRightX = (topRight.X - topLeft.X) + bottomLeft.X;
|
||||
bottomRightY = (topRight.Y - topLeft.Y) + bottomLeft.Y;
|
||||
bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
|
||||
bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
|
||||
sourceBottomRightX = sourceBottomRightY = dimMinusThree;
|
||||
}
|
||||
|
||||
var transform = PerspectiveTransform.quadrilateralToQuadrilateral(3.5, 3.5, dimMinusThree, 3.5, sourceBottomRightX, sourceBottomRightY, 3.5, dimMinusThree, topLeft.X, topLeft.Y, topRight.X, topRight.Y, bottomRightX, bottomRightY, bottomLeft.X, bottomLeft.Y);
|
||||
var transform = PerspectiveTransform.quadrilateralToQuadrilateral(3.5, 3.5, dimMinusThree, 3.5, sourceBottomRightX, sourceBottomRightY, 3.5, dimMinusThree, topLeft.getX(), topLeft.getY(), topRight.getX(), topRight.getY(), bottomRightX, bottomRightY, bottomLeft.getX(), bottomLeft.getY());
|
||||
|
||||
return transform;
|
||||
}
|
||||
@@ -342,9 +342,9 @@ function Detector(image)
|
||||
this.processFinderPatternInfo = function( info)
|
||||
{
|
||||
|
||||
var topLeft = info.TopLeft;
|
||||
var topRight = info.TopRight;
|
||||
var bottomLeft = info.BottomLeft;
|
||||
var topLeft = info.getTopLeft();
|
||||
var topRight = info.getTopRight();
|
||||
var bottomLeft = info.getBottomLeft();
|
||||
|
||||
var moduleSize = this.calculateModuleSize(topLeft, topRight, bottomLeft);
|
||||
if (moduleSize < 1.0)
|
||||
@@ -353,22 +353,22 @@ function Detector(image)
|
||||
}
|
||||
var dimension = this.computeDimension(topLeft, topRight, bottomLeft, moduleSize);
|
||||
var provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
|
||||
var modulesBetweenFPCenters = provisionalVersion.DimensionForVersion - 7;
|
||||
var modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;
|
||||
|
||||
var alignmentPattern = null;
|
||||
// Anything above version 1 has an alignment pattern
|
||||
if (provisionalVersion.AlignmentPatternCenters.length > 0)
|
||||
if (provisionalVersion.getAlignmentPatternCenters().length > 0)
|
||||
{
|
||||
|
||||
// Guess where a "bottom right" finder pattern would have been
|
||||
var bottomRightX = topRight.X - topLeft.X + bottomLeft.X;
|
||||
var bottomRightY = topRight.Y - topLeft.Y + bottomLeft.Y;
|
||||
var bottomRightX = topRight.getX() - topLeft.getX() + bottomLeft.getX();
|
||||
var bottomRightY = topRight.getY() - topLeft.getY() + bottomLeft.getY();
|
||||
|
||||
// Estimate that alignment pattern is closer by 3 modules
|
||||
// from "bottom right" to known top left location
|
||||
var correctionToTopLeft = 1.0 - 3.0 / modulesBetweenFPCenters;
|
||||
var estAlignmentX = Math.floor (topLeft.X + correctionToTopLeft * (bottomRightX - topLeft.X));
|
||||
var estAlignmentY = Math.floor (topLeft.Y + correctionToTopLeft * (bottomRightY - topLeft.Y));
|
||||
var estAlignmentX = Math.floor (topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));
|
||||
var estAlignmentY = Math.floor (topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY()));
|
||||
|
||||
// Kind of arbitrary -- expand search radius before giving up
|
||||
for (var i = 4; i <= 16; i <<= 1)
|
||||
|
||||
+4
-4
@@ -28,14 +28,14 @@ function ErrorCorrectionLevel(ordinal, bits, name)
|
||||
this.ordinal_Renamed_Field = ordinal;
|
||||
this.bits = bits;
|
||||
this.name = name;
|
||||
this.__defineGetter__("Bits", function()
|
||||
this.getBits = function()
|
||||
{
|
||||
return this.bits;
|
||||
});
|
||||
this.__defineGetter__("Name", function()
|
||||
};
|
||||
this.getName = function()
|
||||
{
|
||||
return this.name;
|
||||
});
|
||||
};
|
||||
this.ordinal=function()
|
||||
{
|
||||
return this.ordinal_Renamed_Field;
|
||||
|
||||
+31
-31
@@ -32,8 +32,8 @@ qrcode.orderBestPatterns=function(patterns)
|
||||
|
||||
function distance( pattern1, pattern2)
|
||||
{
|
||||
var xDiff = pattern1.X - pattern2.X;
|
||||
var yDiff = pattern1.Y - pattern2.Y;
|
||||
var xDiff = pattern1.getX() - pattern2.getX();
|
||||
var yDiff = pattern1.getY() - pattern2.getY();
|
||||
return Math.sqrt( (xDiff * xDiff + yDiff * yDiff));
|
||||
}
|
||||
|
||||
@@ -96,22 +96,22 @@ function FinderPattern(posX, posY, estimatedModuleSize)
|
||||
this.count = 1;
|
||||
this.estimatedModuleSize = estimatedModuleSize;
|
||||
|
||||
this.__defineGetter__("EstimatedModuleSize", function()
|
||||
this.getEstimatedModuleSize = function()
|
||||
{
|
||||
return this.estimatedModuleSize;
|
||||
});
|
||||
this.__defineGetter__("Count", function()
|
||||
};
|
||||
this.getCount = function()
|
||||
{
|
||||
return this.count;
|
||||
});
|
||||
this.__defineGetter__("X", function()
|
||||
};
|
||||
this.getX = function()
|
||||
{
|
||||
return this.x;
|
||||
});
|
||||
this.__defineGetter__("Y", function()
|
||||
};
|
||||
this.getY = function()
|
||||
{
|
||||
return this.y;
|
||||
});
|
||||
};
|
||||
this.incrementCount = function()
|
||||
{
|
||||
this.count++;
|
||||
@@ -133,18 +133,18 @@ function FinderPatternInfo(patternCenters)
|
||||
this.bottomLeft = patternCenters[0];
|
||||
this.topLeft = patternCenters[1];
|
||||
this.topRight = patternCenters[2];
|
||||
this.__defineGetter__("BottomLeft", function()
|
||||
this.getBottomLeft = function()
|
||||
{
|
||||
return this.bottomLeft;
|
||||
});
|
||||
this.__defineGetter__("TopLeft", function()
|
||||
};
|
||||
this.getTopLeft = function()
|
||||
{
|
||||
return this.topLeft;
|
||||
});
|
||||
this.__defineGetter__("TopRight", function()
|
||||
};
|
||||
this.getTopRight = function()
|
||||
{
|
||||
return this.topRight;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,7 +162,7 @@ function FinderPatternFinder()
|
||||
this.crossCheckStateCount = new Array(0,0,0,0,0);
|
||||
this.resultPointCallback = null;
|
||||
|
||||
this.__defineGetter__("CrossCheckStateCount", function()
|
||||
this.getCrossCheckStateCount = function()
|
||||
{
|
||||
this.crossCheckStateCount[0] = 0;
|
||||
this.crossCheckStateCount[1] = 0;
|
||||
@@ -170,7 +170,7 @@ function FinderPatternFinder()
|
||||
this.crossCheckStateCount[3] = 0;
|
||||
this.crossCheckStateCount[4] = 0;
|
||||
return this.crossCheckStateCount;
|
||||
});
|
||||
};
|
||||
|
||||
this.foundPatternCross=function( stateCount)
|
||||
{
|
||||
@@ -206,7 +206,7 @@ function FinderPatternFinder()
|
||||
var image = this.image;
|
||||
|
||||
var maxI = qrcode.height;
|
||||
var stateCount = this.CrossCheckStateCount;
|
||||
var stateCount = this.getCrossCheckStateCount();
|
||||
|
||||
// Start counting up from center
|
||||
var i = startI;
|
||||
@@ -284,7 +284,7 @@ function FinderPatternFinder()
|
||||
var image = this.image;
|
||||
|
||||
var maxJ = qrcode.width;
|
||||
var stateCount = this.CrossCheckStateCount;
|
||||
var stateCount = this.getCrossCheckStateCount();
|
||||
|
||||
var j = startJ;
|
||||
while (j >= 0 && image[j+ centerI*qrcode.width])
|
||||
@@ -412,15 +412,15 @@ function FinderPatternFinder()
|
||||
var square = 0.0;
|
||||
for (var i = 0; i < startSize; i++)
|
||||
{
|
||||
//totalModuleSize += this.possibleCenters[i].EstimatedModuleSize;
|
||||
var centerValue=this.possibleCenters[i].EstimatedModuleSize;
|
||||
//totalModuleSize += this.possibleCenters[i].getEstimatedModuleSize();
|
||||
var centerValue=this.possibleCenters[i].getEstimatedModuleSize();
|
||||
totalModuleSize += centerValue;
|
||||
square += (centerValue * centerValue);
|
||||
}
|
||||
var average = totalModuleSize / startSize;
|
||||
this.possibleCenters.sort(function(center1,center2) {
|
||||
var dA=Math.abs(center2.EstimatedModuleSize - average);
|
||||
var dB=Math.abs(center1.EstimatedModuleSize - average);
|
||||
var dA=Math.abs(center2.getEstimatedModuleSize() - average);
|
||||
var dB=Math.abs(center1.getEstimatedModuleSize() - average);
|
||||
if (dA < dB) {
|
||||
return (-1);
|
||||
} else if (dA == dB) {
|
||||
@@ -436,8 +436,8 @@ function FinderPatternFinder()
|
||||
for (var i = this.possibleCenters.length - 1; i >= 0 ; i--)
|
||||
{
|
||||
var pattern = this.possibleCenters[i];
|
||||
//if (Math.abs(pattern.EstimatedModuleSize - average) > 0.2 * average)
|
||||
if (Math.abs(pattern.EstimatedModuleSize - average) > limit)
|
||||
//if (Math.abs(pattern.getEstimatedModuleSize() - average) > 0.2 * average)
|
||||
if (Math.abs(pattern.getEstimatedModuleSize() - average) > limit)
|
||||
{
|
||||
//this.possibleCenters.remove(i);
|
||||
this.possibleCenters.splice(i,1);
|
||||
@@ -470,7 +470,7 @@ function FinderPatternFinder()
|
||||
for (var i = 0; i < max; i++)
|
||||
{
|
||||
var center = this.possibleCenters[i];
|
||||
if (center.Count >= CENTER_QUORUM)
|
||||
if (center.getCount() >= CENTER_QUORUM)
|
||||
{
|
||||
if (firstConfirmedCenter == null)
|
||||
{
|
||||
@@ -484,7 +484,7 @@ function FinderPatternFinder()
|
||||
// difference in the x / y coordinates of the two centers.
|
||||
// This is the case where you find top left last.
|
||||
this.hasSkipped = true;
|
||||
return Math.floor ((Math.abs(firstConfirmedCenter.X - center.X) - Math.abs(firstConfirmedCenter.Y - center.Y)) / 2);
|
||||
return Math.floor ((Math.abs(firstConfirmedCenter.getX() - center.getX()) - Math.abs(firstConfirmedCenter.getY() - center.getY())) / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -499,10 +499,10 @@ function FinderPatternFinder()
|
||||
for (var i = 0; i < max; i++)
|
||||
{
|
||||
var pattern = this.possibleCenters[i];
|
||||
if (pattern.Count >= CENTER_QUORUM)
|
||||
if (pattern.getCount() >= CENTER_QUORUM)
|
||||
{
|
||||
confirmedCount++;
|
||||
totalModuleSize += pattern.EstimatedModuleSize;
|
||||
totalModuleSize += pattern.getEstimatedModuleSize();
|
||||
}
|
||||
}
|
||||
if (confirmedCount < 3)
|
||||
@@ -518,7 +518,7 @@ function FinderPatternFinder()
|
||||
for (var i = 0; i < max; i++)
|
||||
{
|
||||
pattern = this.possibleCenters[i];
|
||||
totalDeviation += Math.abs(pattern.EstimatedModuleSize - average);
|
||||
totalDeviation += Math.abs(pattern.getEstimatedModuleSize() - average);
|
||||
}
|
||||
return totalDeviation <= 0.05 * totalModuleSize;
|
||||
}
|
||||
|
||||
+5
-5
@@ -33,14 +33,14 @@ function FormatInformation(formatInfo)
|
||||
this.errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03);
|
||||
this.dataMask = (formatInfo & 0x07);
|
||||
|
||||
this.__defineGetter__("ErrorCorrectionLevel", function()
|
||||
this.getErrorCorrectionLevel = function()
|
||||
{
|
||||
return this.errorCorrectionLevel;
|
||||
});
|
||||
this.__defineGetter__("DataMask", function()
|
||||
};
|
||||
this.getDataMask = function()
|
||||
{
|
||||
return this.dataMask;
|
||||
});
|
||||
};
|
||||
this.GetHashCode=function()
|
||||
{
|
||||
return (this.errorCorrectionLevel.ordinal() << 3) | this.dataMask;
|
||||
@@ -85,7 +85,7 @@ FormatInformation.doDecodeFormatInformation=function( maskedFormatInfo)
|
||||
// Found an exact match
|
||||
return new FormatInformation(decodeInfo[1]);
|
||||
}
|
||||
var bitsDifference = this.numBitsDiffering(maskedFormatInfo, targetInfo);
|
||||
var bitsDifference = FormatInformation.numBitsDiffering(maskedFormatInfo, targetInfo);
|
||||
if (bitsDifference < bestDifference)
|
||||
{
|
||||
bestFormatInfo = decodeInfo[1];
|
||||
|
||||
+4
-4
@@ -47,14 +47,14 @@ function GF256( primitive)
|
||||
var at1=new Array(1);at1[0]=1;
|
||||
this.one = new GF256Poly(this, new Array(at1));
|
||||
|
||||
this.__defineGetter__("Zero", function()
|
||||
this.getZero = function()
|
||||
{
|
||||
return this.zero;
|
||||
});
|
||||
this.__defineGetter__("One", function()
|
||||
};
|
||||
this.getOne = function()
|
||||
{
|
||||
return this.one;
|
||||
});
|
||||
};
|
||||
this.buildMonomial=function( degree, coefficient)
|
||||
{
|
||||
if (degree < 0)
|
||||
|
||||
+19
-19
@@ -41,7 +41,7 @@ function GF256Poly(field, coefficients)
|
||||
}
|
||||
if (firstNonZero == coefficientsLength)
|
||||
{
|
||||
this.coefficients = field.Zero.coefficients;
|
||||
this.coefficients = field.getZero().coefficients;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -56,18 +56,18 @@ function GF256Poly(field, coefficients)
|
||||
this.coefficients = coefficients;
|
||||
}
|
||||
|
||||
this.__defineGetter__("Zero", function()
|
||||
this.getZero = function()
|
||||
{
|
||||
return this.coefficients[0] == 0;
|
||||
});
|
||||
this.__defineGetter__("Degree", function()
|
||||
};
|
||||
this.getDegree = function()
|
||||
{
|
||||
return this.coefficients.length - 1;
|
||||
});
|
||||
this.__defineGetter__("Coefficients", function()
|
||||
};
|
||||
this.getCoefficients = function()
|
||||
{
|
||||
return this.coefficients;
|
||||
});
|
||||
};
|
||||
|
||||
this.getCoefficient=function( degree)
|
||||
{
|
||||
@@ -106,11 +106,11 @@ function GF256Poly(field, coefficients)
|
||||
{
|
||||
throw new Error("QR Error: GF256Polys do not have same GF256 field");
|
||||
}
|
||||
if (this.Zero)
|
||||
if (this.getZero())
|
||||
{
|
||||
return other;
|
||||
}
|
||||
if (other.Zero)
|
||||
if (other.getZero())
|
||||
{
|
||||
return this;
|
||||
}
|
||||
@@ -142,9 +142,9 @@ function GF256Poly(field, coefficients)
|
||||
{
|
||||
throw new Error("QR Error: GF256Polys do not have same GF256 field");
|
||||
}
|
||||
if (this.Zero || other.Zero)
|
||||
if (this.getZero() || other.getZero())
|
||||
{
|
||||
return this.field.Zero;
|
||||
return this.field.getZero();
|
||||
}
|
||||
var aCoefficients = this.coefficients;
|
||||
var aLength = aCoefficients.length;
|
||||
@@ -165,7 +165,7 @@ function GF256Poly(field, coefficients)
|
||||
{
|
||||
if (scalar == 0)
|
||||
{
|
||||
return this.field.Zero;
|
||||
return this.field.getZero();
|
||||
}
|
||||
if (scalar == 1)
|
||||
{
|
||||
@@ -187,7 +187,7 @@ function GF256Poly(field, coefficients)
|
||||
}
|
||||
if (coefficient == 0)
|
||||
{
|
||||
return this.field.Zero;
|
||||
return this.field.getZero();
|
||||
}
|
||||
var size = this.coefficients.length;
|
||||
var product = new Array(size + degree);
|
||||
@@ -204,21 +204,21 @@ function GF256Poly(field, coefficients)
|
||||
{
|
||||
throw new Error("QR Error: GF256Polys do not have same GF256 field");
|
||||
}
|
||||
if (other.Zero)
|
||||
if (other.getZero())
|
||||
{
|
||||
throw new Error("QR Error: Divide by 0");
|
||||
}
|
||||
|
||||
var quotient = this.field.Zero;
|
||||
var quotient = this.field.getZero();
|
||||
var remainder = this;
|
||||
|
||||
var denominatorLeadingTerm = other.getCoefficient(other.Degree);
|
||||
var denominatorLeadingTerm = other.getCoefficient(other.getDegree());
|
||||
var inverseDenominatorLeadingTerm = this.field.inverse(denominatorLeadingTerm);
|
||||
|
||||
while (remainder.Degree >= other.Degree && !remainder.Zero)
|
||||
while (remainder.getDegree() >= other.getDegree() && !remainder.getZero())
|
||||
{
|
||||
var degreeDifference = remainder.Degree - other.Degree;
|
||||
var scale = this.field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm);
|
||||
var degreeDifference = remainder.getDegree() - other.getDegree();
|
||||
var scale = this.field.multiply(remainder.getCoefficient(remainder.getDegree()), inverseDenominatorLeadingTerm);
|
||||
var term = other.multiplyByMonomial(degreeDifference, scale);
|
||||
var iterationQuotient = this.field.buildMonomial(degreeDifference, scale);
|
||||
quotient = quotient.addOrSubtract(iterationQuotient);
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
(function() {
|
||||
+3
-3
@@ -116,8 +116,8 @@ qrcode.process = function(){
|
||||
var qRCodeMatrix = detector.detect(); // throws if no qr code was found
|
||||
|
||||
if (qrcode.debug) {
|
||||
for (var y = 0; y < qRCodeMatrix.bits.Height; y++) {
|
||||
for (var x = 0; x < qRCodeMatrix.bits.Width; x++) {
|
||||
for (var y = 0; y < qRCodeMatrix.bits.getHeight(); y++) {
|
||||
for (var x = 0; x < qRCodeMatrix.bits.getWidth(); x++) {
|
||||
var point = (x * 4 * 2) + (y * 2 * qrcode.width * 4);
|
||||
var isSet = qRCodeMatrix.bits.get_Renamed(x, y)
|
||||
debugImage.data[point] = isSet ? 0 : 255;
|
||||
@@ -135,7 +135,7 @@ qrcode.process = function(){
|
||||
|
||||
|
||||
var reader = Decoder.decode(qRCodeMatrix.bits);
|
||||
var data = reader.DataByte;
|
||||
var data = reader.getDataByte();
|
||||
var str="";
|
||||
for(var i=0;i<data.length;i++)
|
||||
{
|
||||
|
||||
+13
-13
@@ -67,7 +67,7 @@ function ReedSolomonDecoder(field)
|
||||
this.runEuclideanAlgorithm=function( a, b, R)
|
||||
{
|
||||
// Assume a's degree is >= b's
|
||||
if (a.Degree < b.Degree)
|
||||
if (a.getDegree() < b.getDegree())
|
||||
{
|
||||
var temp = a;
|
||||
a = b;
|
||||
@@ -76,13 +76,13 @@ function ReedSolomonDecoder(field)
|
||||
|
||||
var rLast = a;
|
||||
var r = b;
|
||||
var sLast = this.field.One;
|
||||
var s = this.field.Zero;
|
||||
var tLast = this.field.Zero;
|
||||
var t = this.field.One;
|
||||
var sLast = this.field.getOne();
|
||||
var s = this.field.getZero();
|
||||
var tLast = this.field.getZero();
|
||||
var t = this.field.getOne();
|
||||
|
||||
// Run Euclidean algorithm until r's degree is less than R/2
|
||||
while (r.Degree >= Math.floor(R / 2))
|
||||
while (r.getDegree() >= Math.floor(R / 2))
|
||||
{
|
||||
var rLastLast = rLast;
|
||||
var sLastLast = sLast;
|
||||
@@ -92,19 +92,19 @@ function ReedSolomonDecoder(field)
|
||||
tLast = t;
|
||||
|
||||
// Divide rLastLast by rLast, with quotient in q and remainder in r
|
||||
if (rLast.Zero)
|
||||
if (rLast.getZero())
|
||||
{
|
||||
// Oops, Euclidean algorithm already terminated?
|
||||
throw new Error("QR Error: r_{i-1} was zero");
|
||||
}
|
||||
r = rLastLast;
|
||||
var q = this.field.Zero;
|
||||
var denominatorLeadingTerm = rLast.getCoefficient(rLast.Degree);
|
||||
var q = this.field.getZero();
|
||||
var denominatorLeadingTerm = rLast.getCoefficient(rLast.getDegree());
|
||||
var dltInverse = this.field.inverse(denominatorLeadingTerm);
|
||||
while (r.Degree >= rLast.Degree && !r.Zero)
|
||||
while (r.getDegree() >= rLast.getDegree() && !r.getZero())
|
||||
{
|
||||
var degreeDiff = r.Degree - rLast.Degree;
|
||||
var scale = this.field.multiply(r.getCoefficient(r.Degree), dltInverse);
|
||||
var degreeDiff = r.getDegree() - rLast.getDegree();
|
||||
var scale = this.field.multiply(r.getCoefficient(r.getDegree()), dltInverse);
|
||||
q = q.addOrSubtract(this.field.buildMonomial(degreeDiff, scale));
|
||||
r = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale));
|
||||
//r.EXE();
|
||||
@@ -128,7 +128,7 @@ function ReedSolomonDecoder(field)
|
||||
this.findErrorLocations=function( errorLocator)
|
||||
{
|
||||
// This is a direct application of Chien's search
|
||||
var numErrors = errorLocator.Degree;
|
||||
var numErrors = errorLocator.getDegree();
|
||||
if (numErrors == 1)
|
||||
{
|
||||
// shortcut
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
})();
|
||||
+24
-24
@@ -29,14 +29,14 @@ function ECB(count, dataCodewords)
|
||||
this.count = count;
|
||||
this.dataCodewords = dataCodewords;
|
||||
|
||||
this.__defineGetter__("Count", function()
|
||||
this.getCount = function()
|
||||
{
|
||||
return this.count;
|
||||
});
|
||||
this.__defineGetter__("DataCodewords", function()
|
||||
};
|
||||
this.getDataCodewords = function()
|
||||
{
|
||||
return this.dataCodewords;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function ECBlocks( ecCodewordsPerBlock, ecBlocks1, ecBlocks2)
|
||||
@@ -47,17 +47,17 @@ function ECBlocks( ecCodewordsPerBlock, ecBlocks1, ecBlocks2)
|
||||
else
|
||||
this.ecBlocks = new Array(ecBlocks1);
|
||||
|
||||
this.__defineGetter__("ECCodewordsPerBlock", function()
|
||||
this.getECCodewordsPerBlock = function()
|
||||
{
|
||||
return this.ecCodewordsPerBlock;
|
||||
});
|
||||
};
|
||||
|
||||
this.__defineGetter__("TotalECCodewords", function()
|
||||
this.getTotalECCodewords = function()
|
||||
{
|
||||
return this.ecCodewordsPerBlock * this.NumBlocks;
|
||||
});
|
||||
return this.ecCodewordsPerBlock * this.getNumBlocks();
|
||||
};
|
||||
|
||||
this.__defineGetter__("NumBlocks", function()
|
||||
this.getNumBlocks = function()
|
||||
{
|
||||
var total = 0;
|
||||
for (var i = 0; i < this.ecBlocks.length; i++)
|
||||
@@ -65,7 +65,7 @@ function ECBlocks( ecCodewordsPerBlock, ecBlocks1, ecBlocks2)
|
||||
total += this.ecBlocks[i].length;
|
||||
}
|
||||
return total;
|
||||
});
|
||||
};
|
||||
|
||||
this.getECBlocks=function()
|
||||
{
|
||||
@@ -80,36 +80,36 @@ function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks
|
||||
this.ecBlocks = new Array(ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4);
|
||||
|
||||
var total = 0;
|
||||
var ecCodewords = ecBlocks1.ECCodewordsPerBlock;
|
||||
var ecCodewords = ecBlocks1.getECCodewordsPerBlock();
|
||||
var ecbArray = ecBlocks1.getECBlocks();
|
||||
for (var i = 0; i < ecbArray.length; i++)
|
||||
{
|
||||
var ecBlock = ecbArray[i];
|
||||
total += ecBlock.Count * (ecBlock.DataCodewords + ecCodewords);
|
||||
total += ecBlock.getCount() * (ecBlock.getDataCodewords() + ecCodewords);
|
||||
}
|
||||
this.totalCodewords = total;
|
||||
|
||||
this.__defineGetter__("VersionNumber", function()
|
||||
this.getVersionNumber = function()
|
||||
{
|
||||
return this.versionNumber;
|
||||
});
|
||||
};
|
||||
|
||||
this.__defineGetter__("AlignmentPatternCenters", function()
|
||||
this.getAlignmentPatternCenters = function()
|
||||
{
|
||||
return this.alignmentPatternCenters;
|
||||
});
|
||||
this.__defineGetter__("TotalCodewords", function()
|
||||
};
|
||||
this.getTotalCodewords = function()
|
||||
{
|
||||
return this.totalCodewords;
|
||||
});
|
||||
this.__defineGetter__("DimensionForVersion", function()
|
||||
};
|
||||
this.getDimensionForVersion = function()
|
||||
{
|
||||
return 17 + 4 * this.versionNumber;
|
||||
});
|
||||
};
|
||||
|
||||
this.buildFunctionPattern=function()
|
||||
{
|
||||
var dimension = this.DimensionForVersion;
|
||||
var dimension = this.getDimensionForVersion();
|
||||
var bitMatrix = new BitMatrix(dimension);
|
||||
|
||||
// Top left finder pattern + separator + format
|
||||
@@ -195,7 +195,7 @@ Version.decodeVersionInformation=function( versionBits)
|
||||
// Do the version info bits match exactly? done.
|
||||
if (targetVersion == versionBits)
|
||||
{
|
||||
return this.getVersionForNumber(i + 7);
|
||||
return Version.getVersionForNumber(i + 7);
|
||||
}
|
||||
// Otherwise see if this is the closest to a real version info bit string
|
||||
// we have seen so far
|
||||
@@ -210,7 +210,7 @@ Version.decodeVersionInformation=function( versionBits)
|
||||
// differ in less than 4 bits.
|
||||
if (bestDifference <= 3)
|
||||
{
|
||||
return this.getVersionForNumber(bestVersion);
|
||||
return Version.getVersionForNumber(bestVersion);
|
||||
}
|
||||
// If we didn't find a close enough match, fail
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user