+ [task127424] adjust the width and height of canvas of think3c widget.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user