Created
March 27, 2012 18:11
-
-
Save devongovett/2218587 to your computer and use it in GitHub Desktop.
get a blob from a canvas
This file contains 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
function getBlob(canvas) { | |
var data = atob(canvas.toDataURL().replace('data:image/png;base64,', '')), | |
bytes = new Uint8Array(data.length); | |
for (var i = 0, len = data.length; i < len; i++) { | |
bytes[i] = data.charCodeAt(i) & 0xff; | |
} | |
var bb = new BlobBuilder(); | |
bb.append(bytes.buffer); | |
return bb.getBlob('image/png'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment