specify error correction level of QR code in photos to make it compatible with BC scanner app

This commit is contained in:
Billy Lo 2021-09-30 02:24:24 -04:00
parent 0e53240dd0
commit 9c2130ba2d
1 changed files with 3 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import {BrowserQRCodeSvgWriter} from "@zxing/browser";
import { toPng, toJpeg, toBlob, toPixelData, toSvg } from 'html-to-image';
import * as Sentry from '@sentry/react';
import {QrCode,Encoding,PackageResult,QrFormat,PassPhotoCommon} from './passphoto-common';
import { EncodeHintType } from "@zxing/library";
export class Photo {
@ -67,7 +68,8 @@ export class Photo {
}
const codeWriter = new BrowserQRCodeSvgWriter();
const svg = codeWriter.write(qrCode.message,200,200);
const hints : Map<EncodeHintType,any> = new Map().set(EncodeHintType.ERROR_CORRECTION,'M');
const svg = codeWriter.write(qrCode.message,200,200, hints);
svg.setAttribute('style','background-color: white');
document.getElementById('qrcode').appendChild(svg);