Since I came across this earlier post on some of my problems, there is even more understanding of blurry images to overlay on top of the 'imageSmoothingEnabled' solution.
This is more specific for the case of rendering for a specific monitor, and only some people encountered this problem if they tried to render graphics with retina quality on canvas with disappointing results.
In essence, high-density monitors mean that your canvas needs to consider this extra pixel density. If you do nothing, canvas will only display enough pixel information in its context to allow for a pixel ratio of 1.
Therefore, for many modern monitors that have coefficients> 1, you must change your canvas context to take into account this additional information, but keep your canvas normal width and height.
To do this, you simply set the width and height of the rendering context to: target width and height * window.devicePixelRatio.
canvas.width = target width * window.devicePixelRatio; canvas.height = target height * window.devicePixelRatio;
Then you set the canvas style so that the canvas size matches the normal sizes:
canvas.style.width = '${target width}px'; canvas.style.height = '${target height}px';
The last time you display an image with the maximum context size that the image allows. In some cases (for example, when rendering images in SVG format), you can still get the best image quality by visualizing an image with pixel dimensions:
ctx.drawImage( img, 0, 0, img.width * window.devicePixelRatio, img.height * window.devicePixelRatio );
So, to show this phenomenon, I made a violin. You will NOT see differences in canvas quality if you use a pixelRatio monitor close to 1.
https://jsfiddle.net/ufjm50p9/2/