@@ -16,14 +16,18 @@ function getQrDebug(
16
16
const qr = new Image ( ) ;
17
17
qr . src = dataUrl ;
18
18
qr . onload = ( ) => {
19
+ const devicePixelRatio = qr . width / windowWidth ;
19
20
const captureCanvas = document . createElement ( 'canvas' ) ;
20
- captureCanvas . width = width ;
21
- captureCanvas . height = height ;
21
+ captureCanvas . width = width * devicePixelRatio ;
22
+ captureCanvas . height = height * devicePixelRatio ;
22
23
const ctx = captureCanvas . getContext ( '2d' ) ;
23
24
if ( ! ctx ) {
24
25
return ;
25
26
}
26
- ctx . drawImage ( qr , left , top , width , height , 0 , 0 , width , height ) ;
27
+ ctx . drawImage (
28
+ qr , left * devicePixelRatio , top * devicePixelRatio ,
29
+ width * devicePixelRatio , height * devicePixelRatio , 0 , 0 ,
30
+ width * devicePixelRatio , height * devicePixelRatio ) ;
27
31
const url = captureCanvas . toDataURL ( ) ;
28
32
const infoDom = document . getElementById ( 'info' ) ;
29
33
if ( infoDom ) {
@@ -38,7 +42,8 @@ function getQrDebug(
38
42
`Screen Height: ${ window . screen . height } <br>` +
39
43
`Capture Width: ${ qr . width } <br>` +
40
44
`Capture Height: ${ qr . height } <br>` +
41
- `Device Pixel Ratio:${ window . devicePixelRatio } <br>` +
45
+ `Device Pixel Ratio: ${ devicePixelRatio } / ${
46
+ window . devicePixelRatio } <br>` +
42
47
`Tab ID: ${ tab . id } <br>` +
43
48
'<br>' +
44
49
'<b>Captured Screenshot:</b>' ;
0 commit comments