diff --git a/src/fonteditor/dialog/setting-import-pic.js b/src/fonteditor/dialog/setting-import-pic.js index 0fd36e2..fb3aa93 100644 --- a/src/fonteditor/dialog/setting-import-pic.js +++ b/src/fonteditor/dialog/setting-import-pic.js @@ -36,8 +36,12 @@ define( canvas.width = width; canvas.height = height; - canvas.style.width = (width / pixelRatio) + 'px'; - canvas.style.height = (height / pixelRatio) + 'px'; + + if (pixelRatio !== 1) { + canvas.style.width = (width / pixelRatio) + 'px'; + canvas.style.height = (height / pixelRatio) + 'px'; + } + canvas.ctx.drawImage(image, 0, 0, width, height); var imgData = canvas.ctx.getImageData(0, 0, width, height); @@ -121,8 +125,10 @@ define( canvas.width = pixelRatio * width; canvas.height = pixelRatio * height; - canvas.style.width = (width / pixelRatio) + 'px'; - canvas.style.height = (height / pixelRatio) + 'px'; + if (pixelRatio !== 1) { + canvas.style.width = (width / pixelRatio) + 'px'; + canvas.style.height = (height / pixelRatio) + 'px'; + } // 绘制拟合曲线 canvas.ctx.fillStyle = 'green'; @@ -160,16 +166,18 @@ define( } function bindEvent() { - // 这里由于对hidpi进行修正,需要修复下设置 var canvasOrigin = $('#import-pic-canvas-origin').get(0); canvasOrigin.ctx = canvasOrigin.getContext('2d'); - canvasOrigin.width = canvasOrigin.height = 0; - canvasOrigin.style.width = canvasOrigin.style.height = 'auto'; var canvasFit = $('#import-pic-canvas-fit').get(0); canvasFit.ctx = canvasFit.getContext('2d'); - canvasFit.width = canvasFit.height = 0; - canvasFit.style.width = canvasFit.style.height = 'auto'; + // 这里由于对retina屏幕进行修正,需要修复下设置 + if (pixelRatio !== 1) { + canvasOrigin.width = canvasOrigin.height = 0; + canvasOrigin.style.width = canvasOrigin.style.height = 'auto'; + canvasFit.width = canvasFit.height = 0; + canvasFit.style.width = canvasFit.style.height = 'auto'; + } $('#import-pic-file').get(0).onchange = function (e) { var file = e.target.files[0]; diff --git a/test/ngzy.jpg b/test/ngzy.jpg new file mode 100644 index 0000000..c01b5b9 Binary files /dev/null and b/test/ngzy.jpg differ diff --git a/test/rw1.jpg b/test/rw1.jpg index a20ff90..c174330 100644 Binary files a/test/rw1.jpg and b/test/rw1.jpg differ diff --git a/test/sfs.jpg b/test/sfs.jpg deleted file mode 100644 index 683687b..0000000 Binary files a/test/sfs.jpg and /dev/null differ diff --git a/test/tiger.png b/test/tiger.png deleted file mode 100644 index ccd453e..0000000 Binary files a/test/tiger.png and /dev/null differ