Skip to content

Instantly share code, notes, and snippets.

@jasonmoo
Created September 9, 2013 19:21
Show Gist options
  • Save jasonmoo/6500226 to your computer and use it in GitHub Desktop.
Save jasonmoo/6500226 to your computer and use it in GitHub Desktop.
function ctx_to_object_url(ctx) {
var img_bytes = atob(ctx.canvas.toDataURL().substring('data:image/png;base64,'.length)),
ua = new Uint8Array(new ArrayBuffer(img_bytes.length));
for (var i = 0; i <= ua.length; i++) {
ua[i] = img_bytes.charCodeAt(i);
}
return (window.URL || window.webkitURL).createObjectURL(new Blob([ua], { type: 'image/png' }));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment