From 5d298ff3cc493021e9682ce8765ac4c99c9dcef2 Mon Sep 17 00:00:00 2001 From: Sneezry Date: Sat, 2 May 2015 02:47:36 +0800 Subject: [PATCH] scan qr code with devicePixelRatio for retina displays --- javascript/background.js | 7 ------- javascript/content.js | 4 ++++ manifest.json | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/javascript/background.js b/javascript/background.js index 4dae636..5a4d23c 100644 --- a/javascript/background.js +++ b/javascript/background.js @@ -20,13 +20,6 @@ function getQr(tab, left, top, width, height, windowWidth) { var qr = new Image(); qr.src = dataUrl; qr.onload = function () { - if (windowWidth * 2 === qr.width) { - //Retina Display - left *= 2; - top *= 2; - width *= 2; - height *= 2; - } this.tab = tab; var captureCanvas = document.getElementById('__ga_captureCanvas__'); if (!captureCanvas) { diff --git a/javascript/content.js b/javascript/content.js index 23a75bd..7407931 100644 --- a/javascript/content.js +++ b/javascript/content.js @@ -64,6 +64,10 @@ function grayLayoutUp(event) { var captureBoxTop = Math.min(this.captureBoxTop, e.clientY) + 1; var captureBoxWidth = Math.abs(this.captureBoxLeft - e.clientX) - 1; var captureBoxHeight = Math.abs(this.captureBoxTop - e.clientY) - 1; + captureBoxLeft *= window.devicePixelRatio; + captureBoxTop *= window.devicePixelRatio; + captureBoxWidth *= window.devicePixelRatio; + captureBoxHeight *= window.devicePixelRatio; setTimeout(function () { captureBox.style.display = 'none'; grayLayout.style.display = 'none'; diff --git a/manifest.json b/manifest.json index c1b6f6e..461ac67 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_extName__", "short_name": "__MSG_extShortName__", - "version": "4.13", + "version": "4.14", "default_locale": "en", "description": "__MSG_extDesc__", "icons": {