From 4fde89e5af78cbfe65192bb59530377593101903 Mon Sep 17 00:00:00 2001 From: aihe <961836564@qq.com> Date: Sat, 11 May 2024 10:26:02 +0800 Subject: [PATCH] uu --- components/tpx-bluetooth-print/tpx-bluetooth-print.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/tpx-bluetooth-print/tpx-bluetooth-print.vue b/components/tpx-bluetooth-print/tpx-bluetooth-print.vue index 07700b5..35106a7 100644 --- a/components/tpx-bluetooth-print/tpx-bluetooth-print.vue +++ b/components/tpx-bluetooth-print/tpx-bluetooth-print.vue @@ -100,7 +100,7 @@ export default { resolve() }) }, - getImageInfo(params = {}) { + getImageZip(params = {}) { return new Promise((resolve, reject)=> { uni.canvasGetImageData({ x: 0, @@ -113,8 +113,8 @@ export default { console.log("zip====", data); resolve(data); } else { - showToast('获取图片信息异常:getImageInfo') - reject('获取图片信息异常:getImageInfo') + showToast('获取图片信息异常:getImageZip') + reject('获取图片信息异常:getImageZip') } } }) @@ -130,10 +130,12 @@ export default { uni.getImageInfo({ src: filePath, success(res) { + // 按原图比例算出 新的画图高度 + that.canvas_height = parseInt(that.canvas_width * (res.height / res.width)) cxt.drawImage(filePath, 0, 0, that.canvas_width, that.canvas_height); cxt.draw(true, ()=> { setTimeout( async ()=> { - let data = await that.getImageInfo({ canvasId: that.canvasId, width: that.canvas_width, height: that.canvas_height, }) + let data = await that.getImageZip({ canvasId: that.canvasId, width: that.canvas_width, height: that.canvas_height, }) resolve(data) }, 1000) });