对于抗锯齿,您需要设置重采样质量。
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()函数中应用抗锯齿?的详细内容。
