标签:
function drawInBlackAndWhite() { var imagedata = context.getImageData(0, 0, canvas.width, canvas.height) var data = imagedata.data for (var i = 0, l = data.length - 4; i < l; i+=4) { var average = (data[i] + data[i+1] + data[i+2]) / 3 data[i] = data[i+1] = data[i+2] = average } context.putImageData(imagedata, 0, 0) }
标签:
原文地址:http://www.cnblogs.com/jzm17173/p/4185275.html