function fImageToCanvas(image){
var oCanvas = document.createElement("canvas");
oCanvas.width = image.width;
oCanvas.height = image.height;
oCanvas.getContext("2d").drawImage(image,0,0);
return oCanvas;
}
function fCanvasToImage(canvas){
var oImage = new Image();
image.src = canvas.toDataURL("image/png");
return image;
}
參考:http://blog.csdn.net/renfufei/article/details/9855519