Created
June 18, 2012 13:55
-
-
Save zipus/2948483 to your computer and use it in GitHub Desktop.
Canvas to Image | Image to Canvas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//extracted of http://davidwalsh.name/convert-canvas-image | |
function convertImageToCanvas(image) { | |
var canvas = document.createElement("canvas"); | |
canvas.width = image.width; | |
canvas.height = image.height; | |
canvas.getContext("2d").drawImage(image, 0, 0); | |
return canvas; | |
} | |
function convertCanvasToImage(canvas) { | |
var image = new Image(); | |
image.src = canvas.toDataURL("image/png"); | |
return image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment