Home > Article > Web Front-end > How to apply anti-aliasing in HTML5 canvas's drawImage() function?
For anti-aliasing, you need to set the resampling quality.
ctx.imageSmoothingQuality = "low|medium|high"
Use off-screen canvas to reduce image by half -
var c = document.createElement('canvas'), ocx = c.getContext('2d'); c.width = img.width * 0.5; c.height = img.height * 0.5; ocxx.drawImage(img, 0, 0, c.width, c.height);
// Draw image to reduce by half again and repeat
ocx.drawImage(c, 0, 0, c.width * 0.5, cc.height * 0.5);
The above is the detailed content of How to apply anti-aliasing in HTML5 canvas's drawImage() function?. For more information, please follow other related articles on the PHP Chinese website!