UNPKG

@3846masa/bmp

Version:

Create a BMP (w/ alpha channel) binary from RGBA raw bytes like ImageData.

2 lines (1 loc) 569 B
const A=Uint8Array.from(atob("Qk0AAAAAAAAAAHoAAABsAAAAAAAAAAAAAAABACAAAwAAAAAAAADDDgAAww4AAAAAAAAAAAAA/wAAAAD/AAAAAP8AAAAA/0JHUnM"),(A=>A.charCodeAt(0))),t="navigator"in globalThis&&/Trident|Edge/.test(navigator.userAgent),e=({width:e,height:r,data:n},i)=>{const a=Object.assign({strict:!1},i),s=n.byteLength,o=122+s,g=new Uint8Array(o),w=new DataView(g.buffer),c=(A,t)=>w.setUint32(A,t,!0);if(g.set(A),c(2,o),c(18,e),c(22,-r),c(34,s),g.set(n,122),a.strict||t){c(54,16711680),c(62,255);for(let A=0;A<s;A+=4)g[122+A]=n[A+2],g[124+A]=n[A]}return g};export{e as convert};