@3846masa/bmp
Version:
Create a BMP (w/ alpha channel) binary from RGBA raw bytes like ImageData.
2 lines (1 loc) • 939 B
JavaScript
!function(){"use strict";const A=URL.createObjectURL(new Blob([`(${()=>{const A=Uint8Array.from(atob("Qk0AAAAAAAAAAHoAAABsAAAAAAAAAAAAAAABACAAAwAAAAAAAADDDgAAww4AAAAAAAAAAAAA/wAAAAD/AAAAAP8AAAAA/0JHUnM"),(A=>A.charCodeAt(0))),t=122,e="navigator"in globalThis&&/Trident|Edge/.test(navigator.userAgent);onmessage=({data:[n,a,r,s,i]})=>{try{const o=(({width:n,height:a,data:r},s)=>{const i=Object.assign({strict:!1},s),o=r.byteLength,c=t+o,g=new Uint8Array(c),w=new DataView(g.buffer),d=(A,t)=>w.setUint32(A,t,!0);if(g.set(A),d(2,c),d(18,n),d(22,-a),d(34,o),g.set(r,t),i.strict||e){d(54,16711680),d(62,255);for(let A=0;A<o;A+=4)g[t+A]=r[A+2],g[124+A]=r[A]}return g})({width:a,height:r,data:new Uint8Array(s)},i);postMessage([n,o.buffer],[o.buffer])}catch(A){postMessage([n,void 0,A])}}}})()`])),t=new Worker(A),e=new Map;t.onmessage=({data:[A,t,n]})=>{const[a,r]=e.get(A);e.delete(A),t?a(new Uint8Array(t)):r(Object.assign(new Error,n))}}();