I have a web page that displays an image excerpt from a document using drawimage(x,z,width,height)
. The user has the ability to draw a rectangle around any given line on the image by clicking the line. The image then has a rectangle drawn on it using rect(x,y,w,h)
.
Using the JavaScript magnifier, the user can hover over the image to see a zoomed in version. However, it does not show the rectangle drawn on to the image on the canvas.
Is it possible to draw both the rectangle and the image? Currently this is the setup for the magnifier:
// - Setup the magnifier component
var glass, w, h, bw;
glass = document.getElementById("magnifier"); // Get pre-existing div for the magnifier
glass.setAttribute("class", "img-magnifier-glass");
// Set background properties for the magnifier glass:
glass.style.backgroundImage = 'url("' + pRow.getValue("imgPath") + '")'; // pRow here refers to a parameter array that is passed in containing data about the image and rectangle
glass.style.backgroundRepeat = "no-repeat";
glass.style.backgroundSize = imgwidth + "px " + imgheight + "px";
bw = 3; // Border width of the magnifier glass.
w = glass.offsetWidth / 2;
h = glass.offsetHeight / 2;
Later on there is code to actually move the background position. But I don't see a way to show the rectangle that is drawn on top of the image, in the canvas, on the magnifier.