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) });