-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcanvas2bmp.min.js
3 lines (3 loc) · 1.37 KB
/
canvas2bmp.min.js
1
2
3
(function(){function l(c,b){c.push(b&255);c.push((b&65280)>>8);c.push((b&16711680)>>16);c.push(b>>24)}var m=window.HTMLCanvasElement.prototype.toDataURL;window.HTMLCanvasElement.prototype.toDataURL=function(){if("string"==typeof arguments[0]&&"IMAGE/BMP"==arguments[0].toUpperCase()){var c=this.getContext("2d").getImageData(0,0,this.width,this.height),b=[],e=c.width,f=c.height,d=e*f*4+138,a=[],g=e,h=f,n=e*f*4,c=c.data,k=[];b.push(66);b.push(77);l(b,d);b.push(0);b.push(0);b.push(0);b.push(0);b.push(138);
b.push(0);b.push(0);b.push(0);a.push(124);a.push(0);a.push(0);a.push(0);l(a,g);l(a,h);a.push(1);a.push(0);a.push(32);a.push(0);a.push(3);a.push(0);a.push(0);a.push(0);l(a,n);a.push(19);a.push(11);a.push(0);a.push(0);a.push(19);a.push(11);a.push(0);a.push(0);a.push(0);a.push(0);a.push(0);a.push(0);a.push(0);a.push(0);a.push(0);a.push(0);a.push(0);a.push(0);a.push(0);a.push(255);a.push(0);a.push(0);a.push(255);a.push(0);a.push(0);a.push(255);a.push(0);a.push(0);a.push(255);a.push(0);a.push(0);a.push(0);
a.push(66);a.push(71);a.push(82);a.push(115);for(d=48;0<d;d--)a.push(0);a.push(2);for(d=15;0<d;d--)a.push(0);do for(d=e*(f-1)*4,h=0;h<e;h+=1)g=4*h,k.push(c[g+d+3]),k.push(c[g+d+2]),k.push(c[g+d+1]),k.push(c[g+d]);while(f--);b=b.concat(a).concat(k);a="";e=0;for(f=b.length;e<f;e+=1)a+=String.fromCharCode(b[e]);return"data:image/bmp;base64,"+btoa(a)}return m.apply(this,arguments)}})();