From 79fbb289f03b76ed81a278e082a6108981c38198 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 9 Jul 2020 15:20:34 +0200 Subject: [PATCH] Merge of PR cozmo#148: Fix "onlyInvert" inversionAttempts option Squashed commit of the following: commit e7f282af2c04a7ff237773ae3c26540f15b2b6f0 Author: LakeGH Date: Thu Nov 14 13:29:15 2019 -0500 Removing unneeded whitespace. commit 13843e5ac62a813afaf4b8565742e2d71410f280 Author: LakeGH Date: Thu Nov 14 13:14:50 2019 -0500 Remove trailing whitespace for tslint commit 4f3fef8c6e180a5534b9df4e730b7a9059f9e378 Author: LakeGH Date: Thu Nov 14 13:12:12 2019 -0500 Change order of inversionAttempts check for tslint commit 0dfc578d15843957905f41d764101927f556251a Author: LakeGH Date: Thu Nov 14 12:55:55 2019 -0500 Fix "onlyInvert" inversionAttempts option. `shouldInvert` should also be true if `options.inversionAttempts` equals "onlyInvert". --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 58e65c96..aad3e808 100644 --- a/src/index.ts +++ b/src/index.ts @@ -90,8 +90,8 @@ function jsQR(data: Uint8ClampedArray, width: number, height: number, providedOp mergeObject(options, defaultOptions); mergeObject(options, providedOptions); - const shouldInvert = options.inversionAttempts === "attemptBoth" || options.inversionAttempts === "invertFirst"; const tryInvertedFirst = options.inversionAttempts === "onlyInvert" || options.inversionAttempts === "invertFirst"; + const shouldInvert = options.inversionAttempts === "attemptBoth" || tryInvertedFirst; const {binarized, inverted} = binarize(data, width, height, shouldInvert, options.greyScaleWeights, options.canOverwriteImage); let result = scan(tryInvertedFirst ? inverted : binarized);