src/simg.js
function(cb){
      this.toCanvas(function(canvas){
        var dataUrl = canvas.toDataURL().replace(/^data:image\/(png|jpg);base64,/, "");
        var byteString = atob(escape(dataUrl));
        // write the bytes of the string to an ArrayBuffer
        var ab = new ArrayBuffer(byteString.length);
        var ia = new Uint8Array(ab);
        for (var i = 0; i < byteString.length; i++) {
          ia[i] = byteString.charCodeAt(i);
        }
        var dataView = new DataView(ab);
        var blob = new Blob([dataView], {type: "image/png"});
        cb(blob);
      });
    }
function(cb){
      this.toCanvas(function(canvas){
        var dataUrl = canvas.toDataURL().replace(/^data:image\/(png|jpg);base64,/, "");
        var byteString = atob(escape(dataUrl));
        // write the bytes of the string to an ArrayBuffer
        var ab = new ArrayBuffer(byteString.length);
        var ia = new Uint8Array(ab);
        for (var i = 0; i < byteString.length; i++) {
          ia[i] = byteString.charCodeAt(i);
        }
        var dataView = new DataView(ab);
        var blob = new Blob([dataView], {type: "image/png"});
        cb(blob);
      });
    }
function ( cb ) { this . toCanvas ( function ( canvas ) { var dataUrl = canvas . toDataURL ( ) . replace ( / ^data:image\/(png|jpg);base64, / , "" ) ; var byteString = atob ( escape ( dataUrl ) ) ; // write the bytes of the string to an ArrayBuffer var ab = new ArrayBuffer ( byteString . length ) ; var ia = new Uint8Array ( ab ) ; for ( var i = 0 ; i < byteString . length ; i ++ ) { ia [ i ] = byteString . charCodeAt ( i ) ; } var dataView = new DataView ( ab ) ; var blob = new Blob ( [ dataView ] , { type : "image/png" } ) ; cb ( blob ) ; } ) ; }
Converts canvas to binary blob.
Converts canvas to binary blob .