From ae4f8910c2980df6af326378bf67a018daf14343 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 23 Sep 2021 17:39:54 +0800 Subject: [PATCH] fix the image size over the canvas --- public/self/js/Director/detection.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/public/self/js/Director/detection.js b/public/self/js/Director/detection.js index c822d7515..361c9b60a 100644 --- a/public/self/js/Director/detection.js +++ b/public/self/js/Director/detection.js @@ -2856,11 +2856,17 @@ function isJSON(str) { canvas.width = img.width;// maxWidth document.getElementById("tool0").offsetWidth; canvas.height =img.height;//maxHeight document.getElementById("tool0").offsetWidth/1280*720; //调整画布大小 - if ((img.width/img.height)<(canvas.width/canvas.height)){ - canvas.width=canvas.height * img.width / img.height; + // if ((img.width/img.height)>(maxWidth/maxWidth)){ + // canvas.width=canvas.height * img.width / img.height; + // } + // else{ + // canvas.height=canvas.width * img.height / img.width; + // } + if(canvas.width>maxWidth){ + canvas.width = maxWidth } - else{ - canvas.height=canvas.width * img.height / img.width; + if(canvas.height>maxHeight){ + canvas.height=maxHeight } maxIdNum=0;