stuppid_bot

Canvas dataURL to Blob

Apr 24th, 2013
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. HTMLCanvasElement.prototype.toBlob = function(type) {
  2.     var dataURL = this.toDataURL(type),
  3.         binary = atob( dataURL.substr( dataURL.indexOf(',') + 1 ) ),
  4.         i = binary.length,
  5.         view = new Uint8Array(i);
  6.  
  7.     while (i--) {
  8.         view[i] = binary.charCodeAt(i);
  9.     }
  10.    
  11.     return new Blob([view]);
  12. };
Advertisement
Add Comment
Please, Sign In to add comment