@scandit/web-datacapture-core
Version:
Scandit Data Capture SDK for the Web
1 lines • 907 B
JavaScript
async function u(e,l){let t=document.createElement("canvas");t.width=this.width,t.height=this.height;let o=t.getContext("2d");if(!o)throw new Error("Could not get 2d context from an HTMLCanvasElement");let s=await this.getData();if(s==null)return null;let m;if(this.colorType==="GRAYSCALE"){let n=this.width*this.height,a=new Uint8ClampedArray(n*4);for(let r=0;r<n;r++){let h=s[r],i=r*4;a[i]=h,a[i+1]=h,a[i+2]=h,a[i+3]=255;}m=new ImageData(a,this.width,this.height);}else m=new ImageData(s,this.width,this.height);return o.putImageData(m,0,0),new Promise((n,a)=>{t.toBlob(r=>{if(t=null,o=null,r===null){a(new Error("Could not create Blob object from canvas"));return}n(r);},e,l);})}function c(e,l){let t={width:e.width,height:e.height,isFrameSourceMirrored:e.isFrameSourceMirrored,colorType:e.colorType,getData:async()=>(await l.requestFrameData(e.frameId)).data};return t.toBlob=u.bind(t),t}export{c as a};