fabric.Image.fromURL(hc.toDataURL(), function(img) {
// add image onto canvas
Canvas.add(img);
img.hasControls = false;
img.hasBorders = false;
img.hasControls = false;
img.hasRotatingPoint = false;
img.selectable = false;
});
Above code helps in rendering a image to canvas but I want to use something like putImageData/drawImage because I have to draw the image from another canvas . And as per real time operation using toDataURL for more than 5 MB images is very bad when performance comes to picture.
I also want to render the image on the middle of the canvas . Fabricjs just takes the image toDataURL and renders it as it is.
Any help will be appreciated.
fabric.Image()
just like the rowctx.drawImage
accepts acanvasElement
as imageSource.So you can just call it like
And if you want it centered in the canvas :
Note that
ctx.getImageData
+ctx.putImageData
is at least as slow asctx.toDataURL
which both are incredibly slower thanctx.drawImage