Skip to content

Commit

Permalink
Merge pull request #562 from zxing-js/bugfix/552-readback
Browse files Browse the repository at this point in the history
Bugfix/552 readback
  • Loading branch information
werthdavid authored Apr 19, 2023
2 parents 5c6c504 + 414c0ae commit 72a7cfb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zxing/library",
"version": "0.19.2",
"version": "0.19.3",
"description": "TypeScript port of ZXing multi-format 1D/2D barcode image processing library.",
"keywords": [
"reader",
Expand Down
7 changes: 6 additions & 1 deletion src/browser/BrowserCodeReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,12 @@ export class BrowserCodeReader {

if (!this.captureCanvasContext) {
const elem = this.getCaptureCanvas(mediaElement);
const ctx = elem.getContext('2d');
let ctx;
try {
ctx = elem.getContext('2d', {willReadFrequently: true}) as CanvasRenderingContext2D;
} catch (e) {
ctx = elem.getContext('2d');
}
this.captureCanvasContext = ctx;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/common/detector/MathUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class MathUtils {
* @return nearest {@code int}
*/
public static round(d: number/*float*/): number /*int*/ {
if (NaN === d) return 0;
if (isNaN(d)) return 0;
if (d <= Number.MIN_SAFE_INTEGER) return Number.MIN_SAFE_INTEGER;
if (d >= Number.MAX_SAFE_INTEGER) return Number.MAX_SAFE_INTEGER;
return /*(int) */(d + (d < 0.0 ? -0.5 : 0.5)) | 0;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4820,10 +4820,10 @@ trim-newlines@^1.0.0:
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"
integrity sha1-WIeWa7WCpFA6QetST301ARgVphM=

ts-custom-error@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/ts-custom-error/-/ts-custom-error-3.1.1.tgz#d30c7415461dac93dc2cc9e9eb2dae92e6423901"
integrity sha512-f/syoy+pTE4z82qaiRuthEeZtCGNKzlfs0Zc8jpQFcz/CYMaFSwFSdfFt1sSFnPlDLOEm7RCROdIxZ44N8UlwA==
ts-custom-error@^3.2.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/ts-custom-error/-/ts-custom-error-3.3.1.tgz#8bd3c8fc6b8dc8e1cb329267c45200f1e17a65d1"
integrity sha512-5OX1tzOjxWEgsr/YEUWSuPrQ00deKLh6D7OTWcvNHm12/7QPyRh8SYpyWvA4IZv8H/+GQWQEh/kwo95Q9OVW1A==

ts-node@^9.0.0:
version "9.0.0"
Expand Down

0 comments on commit 72a7cfb

Please sign in to comment.