我们如何放大图像并在其上绘制矩形作为画布?

时间:2019-07-19 09:41:36

标签: javascript html html5-canvas

我正在尝试在图像上绘制矩形,然后在其余api上发送这些矩形的顶部和左侧坐标。我有一个问题,是否可以放大图像并获得相同的图像像素?

   /* Drawing Image on canvas */
            function drawImageActualSize() {
                scope.canvasForImage.width = scope.image.naturalWidth;
                scope.canvas.width = scope.image.naturalWidth;
                scope.canvasForImage.height = scope.image.naturalHeight;
                scope.canvas.height = scope.image.naturalHeight + (scope.heightOfHeader.height);
                $('#canvas').css("top", `-${(scope.heightOfHeader.height)}`);
                scope.canvasForImageCtx.drawImage(scope.image, 0, 0);
            }

            /* Variables for free hand drawing rectangular boxes */
            scope.canvasx = $('#canvas').offset().left;
            scope.canvasy = $('#canvas').offset().top;
            scope.last_mousex, scope.last_mousey = 0;
            scope.mousex, scope.mousey = 0;
            scope.mousedown = false;
            scope.width, scope.height;
            scope.boundingBoxArray = [];
            scope.boundingBoxObject = {
                a: '',
                b: '',
                c: '',
                d: ''
            };

0 个答案:

没有答案