如何在HTML5 canvas的drawImage()函数中应用抗锯齿?

原创
ithorizon 5个月前 (10-19) 阅读数 34 #HTML

对于抗锯齿,您需要设置重采样质量。

ctx.imageSmoothingQuality = "low|medium|high"

使用离屏画布将图像缩小一半 -

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);

// 绘制图像再次缩小一半并重复

ocx.drawImage(c, 0, 0, c.width * 0.5, cc.height * 0.5);

以上就是如何在HTML5 canvas的drawImage()函数中应用抗锯齿?的详细内容,更多请关注IT视界其它相关文章!



热门