#ca { border:1px solid black; } #cb { border:1px solid red; }
1. 准备两个canvas
2. 获取第一个canvas中的图片数据并拿到像素值
var imagedata = context_a.getimagedata(0, 0, canvas_a.width, canvas_a.height) var pixeldata = imagedata.data
3. 修改该像素值
4. 把修改掉的像素值放到第二个canvas画布中
context_b.putimagedata(imagedata, 0, 0, 0, 0, canvas_b.width, canvas_b.height)