+ [task127424] adjust the width and height of canvas of think3c widget.

This commit is contained in:
wangzemei
2024-09-04 03:27:22 +00:00
committed by qixinzhi
parent bf964f9e1e
commit 4866d1dccf
+16 -2
View File
@@ -11,12 +11,26 @@ $(document).ready(function()
let width = image.width;
let height = image.height;
canvas.width = width;
if(width > maxWidth || height > maxHeight)
{
if(width > height)
{
height *= maxWidth / width;
width = maxWidth;
}
else
{
width *= maxHeight / height;
height = maxHeight;
}
}
canvas.width = width;
canvas.height = height;
ctx.drawImage(image, 0, 0, width, height);
const imageData = ctx.getImageData(0, 0, width, height);
const pixels = binarizeImage(imageData);
const pixels = binarizeImage(imageData);
ctx.putImageData(pixels, 0, 0);
};
image.src = modelImg;