I'm making a website for makecode arcade here and I'm making a string to PNG function called ConvertAndDownload
but when I download the image, its all blurry
for example
lets say that i have the string
img1 2 3 4 5 6 7 8 9 a b c d e f 1 3 7 a f
it returns this but its suppose to me pixelated and not all blended together (image is 5x4 pixels)
Converted Image (idk how to resize the image so this is what you get sry)
i tried to add ctx.imageSmoothingEnabled = false; but that didnt work,
heres the download image function
function convertAndDownload() {
var makeCodeString = document.getElementById('makeCodeInput').value;
var canvasData = convertImgStringToCanvas(makeCodeString, colors)
var canvas = canvasData;
var ctx = canvas.getContext('2d');
var dataURL = canvas.toDataURL('image/png');
var downloadLink = document.createElement('a');
downloadLink.href = dataURL;
downloadLink.download = document.getElementById('varName').value + '.png';
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}

To prevent the blurriness in your downloaded image, you need to ensure that your canvas size matches the size of your image. Additionally, you can disable image smoothing to prevent any interpolation that might cause blurriness. Here's how you can modify your convertAndDownload function: