Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
- '6'
install: npm install
script: gulp release
script: npx gulp release
env:
global:
- COMMIT_AUTHOR_NAME: "'Chris Schmich'"
Expand Down
21 changes: 11 additions & 10 deletions src/scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ class Analyzer {
this.canvas = document.createElement('canvas');
this.canvas.style.display = 'none';
this.canvasContext = null;

this.decodeCallback = ZXing.Runtime.addFunction(function (ptr, len, resultIndex, resultCount) {
let result = new Uint8Array(ZXing.HEAPU8.buffer, ptr, len);
let str = String.fromCharCode.apply(null, result);
if (resultIndex === 0) {
window.zxDecodeResult = '';
}
window.zxDecodeResult += str;
});
if (!Analyzer.decodeCallback) {
Analyzer.decodeCallback = ZXing.Runtime.addFunction(function (ptr, len, resultIndex, resultCount) {
let result = new Uint8Array(ZXing.HEAPU8.buffer, ptr, len);
let str = String.fromCharCode.apply(null, result);
if (resultIndex === 0) {
window.zxDecodeResult = '';
}
window.zxDecodeResult += str;
});
}
}

analyze() {
Expand Down Expand Up @@ -142,7 +143,7 @@ class Analyzer {
ZXing.HEAPU8[this.imageBuffer + j] = Math.trunc((r + g + b) / 3);
}

let err = ZXing._decode_qr(this.decodeCallback);
let err = ZXing._decode_qr(Analyzer.decodeCallback);
if (err) {
return null;
}
Expand Down