I am currently working on a pixel art application where I am facing an issue with saving images from the canvas. The saved image appears small and pixelated when I try to resize it.
I would like to resize the image to larger dimensions, but I am unsure of how to achieve this.
Below is an example code snippet:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.rect(0, 0, 50, 50);
ctx.fillStyle = 'red';
ctx.fill();
document.write('<img style="width:300px;" src="'+c.toDataURL("image/png")+'"/>');
// The current image has dimensions of 108x108px and does not look good when resized to 300x300px
// I wish to download the canvas image with higher resolution
<canvas id="myCanvas" width="108" height="108" style="width: 300px; height:300px;">
</canvas>