@3846masa/bmp
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";const t=URL.createObjectURL(new Blob([`(${()=>{const t=Uint8Array.from(atob("Qk0AAAAAAAAAAHoAAABsAAAAAAAAAAAAAAABACAAAwAAAAAAAADDDgAAww4AAAAAAAAAAAAA/wAAAAD/AAAAAP8AAAAA/0JHUnM"),(t=>t.charCodeAt(0))),e=122,A=/Trident|Edge/.test(navigator.userAgent);onmessage=({data:[n,a,o,s]})=>{try{const r=(({width:n,height:a,data:o})=>{const s=o.byteLength,r=e+s,i=new Uint8Array(r),g=new DataView(i.buffer),h=(t,e)=>g.setUint32(t,e,!0);if(i.set(t),h(2,r),h(18,n),h(22,-a),h(34,s),i.set(o,e),A){h(54,16711680),h(62,255);for(let t=0;t<s;t+=4)i[e+t]=o[t+2],i[124+t]=o[t]}return i})({width:a,height:o,data:new Uint8Array(s)});postMessage([n,r.buffer],[r.buffer])}catch(t){postMessage([n,void 0,t])}}}})()`])),e=new Worker(t),A=new Map;e.onmessage=({data:[t,e,n]})=>{const[a,o]=A.get(t);A.delete(t),e?a(new Uint8Array(e)):o(Object.assign(new Error,n))};const n=HTMLCanvasElement.prototype,a=n.toBlob;n.toBlob=function(t,n,o){if("image/bmp"!==n.toLowerCase())return a.call(this,t,n,o);const{width:s,height:r}=this;let i=this.getContext("2d");if(!i){i=this.cloneNode(!1).getContext("2d"),i.drawImage(this,0,0)}(({width:t,height:n,data:a})=>new Promise(((o,s)=>{const r=""+Date.now()+Math.random();A.set(r,[o,s]),e.postMessage([r,t,n,a.buffer],[a.buffer])})))(i.getImageData(0,0,s,r)).then((e=>t(new Blob([e],{type:"image/bmp"}))))}}(); | ||
!function(){"use strict";const t=URL.createObjectURL(new Blob([`(${()=>{const t=Uint8Array.from(atob("Qk0AAAAAAAAAAHoAAABsAAAAAAAAAAAAAAABACAAAwAAAAAAAADDDgAAww4AAAAAAAAAAAAA/wAAAAD/AAAAAP8AAAAA/0JHUnM"),(t=>t.charCodeAt(0))),e=122,A="navigator"in globalThis&&/Trident|Edge/.test(navigator.userAgent);onmessage=({data:[n,a,s,o,r]})=>{try{const i=(({width:n,height:a,data:s},o)=>{const r=Object.assign({strict:!1},o),i=s.byteLength,g=e+i,h=new Uint8Array(g),c=new DataView(h.buffer),w=(t,e)=>c.setUint32(t,e,!0);if(h.set(t),w(2,g),w(18,n),w(22,-a),w(34,i),h.set(s,e),r.strict||A){w(54,16711680),w(62,255);for(let t=0;t<i;t+=4)h[e+t]=s[t+2],h[124+t]=s[t]}return h})({width:a,height:s,data:new Uint8Array(o)},r);postMessage([n,i.buffer],[i.buffer])}catch(t){postMessage([n,void 0,t])}}}})()`])),e=new Worker(t),A=new Map;e.onmessage=({data:[t,e,n]})=>{const[a,s]=A.get(t);A.delete(t),e?a(new Uint8Array(e)):s(Object.assign(new Error,n))};const n=HTMLCanvasElement.prototype,a=n.toBlob;n.toBlob=function(t,n,s){if("image/bmp"!==n.toLowerCase())return a.call(this,t,n,s);const{width:o,height:r}=this;let i=this.getContext("2d");if(!i){i=this.cloneNode(!1).getContext("2d"),i.drawImage(this,0,0)}(({width:t,height:n,data:a},s)=>new Promise(((o,r)=>{const i=""+Date.now()+Math.random();A.set(i,[o,r]),e.postMessage([i,t,n,a.buffer,s],[a.buffer])})))(i.getImageData(0,0,o,r)).then((e=>t(new Blob([e],{type:"image/bmp"}))))}}(); |
{ | ||
"name": "@3846masa/bmp", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Create a BMP (w/ alpha channel) binary from RGBA raw bytes like ImageData.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -124,3 +124,3 @@ # @3846masa/bmp | ||
### `convert({ width, height, data })` | ||
### `convert({ width, height, data }, options?)` | ||
@@ -131,8 +131,9 @@ Convert RGBA raw bytes like ImageData to a BMP binary. | ||
| | | | ||
| :------- | :------------------------------------ | | ||
| `width` | `number` | | ||
| `height` | `number` | | ||
| `data` | `Uint8Array` \| `Uint8ClampedArray` | | ||
| Returns | `Uint8Array` \| `Promise<Uint8Array>` | | ||
| | | | ||
| :--------------- | :------------------------------------ | | ||
| `width` | `number` | | ||
| `height` | `number` | | ||
| `data` | `Uint8Array` \| `Uint8ClampedArray` | | ||
| `options.strict` | `boolean` | | ||
| Returns | `Uint8Array` \| `Promise<Uint8Array>` | | ||
@@ -139,0 +140,0 @@ ### `HTMLCanvasElement.prototype.toBlob(callback, type)` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
16221
175
158