+import{EnumImagePixelFormat as e,engineResourcePaths as t,workerAutoResources as n,mapPackageRegister as r,compareVersion as o,innerVersions as a}from"dynamsoft-core";const s="undefined"==typeof self,i=(()=>{if(!s&&document.currentScript){let e=document.currentScript.src,t=e.indexOf("?");if(-1!=t)e=e.substring(0,t);else{let t=e.indexOf("#");-1!=t&&(e=e.substring(0,t))}return e.substring(0,e.lastIndexOf("/")+1)}return"./"})(),l=e=>{if(null==e&&(e="./"),s);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e},d=e=>{const t=document.createElement("canvas");return t.width=e.width,t.height=e.height,t.getContext("2d",{willReadFrequently:!0}).putImageData(e,0,0),t},c=async(e,t)=>{const n=d(t);return new Promise(((t,r)=>{n.toBlob((e=>t(e)),e)}))};null==t.ddn&&(t.ddn=i),n.ddn={js:!0,wasm:!0,deps:["license","dip"]},r.ddn={handleNormalizedImageResultItem:function(t){let n=t,r=(t=>{let n,r=t.bytes;if(!(r&&r instanceof Uint8Array))throw Error("Parameter type error");if(Number(t.format)===e.IPF_BGR_888){const e=r.length/3;n=new Uint8ClampedArray(4*e);for(let t=0;t<e;++t)n[4*t]=r[3*t],n[4*t+1]=r[3*t+1],n[4*t+2]=r[3*t+2],n[4*t+3]=255}else if(Number(t.format)===e.IPF_RGB_888){const e=r.length/3;n=new Uint8ClampedArray(4*e);for(let t=0;t<e;++t)n[4*t]=r[3*t+2],n[4*t+1]=r[3*t+1],n[4*t+2]=r[3*t],n[4*t+3]=255}else if(Number(t.format)===e.IPF_GRAYSCALED){const e=r.length;n=new Uint8ClampedArray(4*e);for(let t=0;t<e;t++)n[4*t]=n[4*t+1]=n[4*t+2]=r[t],n[4*t+3]=255}else if(Number(t.format)===e.IPF_BINARY_8){const e=r.length,o=t.width,a=t.height,s=t.stride;n=new Uint8ClampedArray(o*a*4);for(let t=0;t<e;t++){let e=r[t],a=t%s,i=Math.floor(t/s);for(let t=0;t<8;t++){let r=a+t,s=4*(i*o+r);if(r>=o)break;n[s]=n[s+1]=n[s+2]=(128&e)/128*255,n[s+3]=255,e<<=1}}}else if(Number(t.format)===e.IPF_ABGR_8888){const e=r.length/4;n=new Uint8ClampedArray(r.length);for(let t=0;t<e;++t)n[4*t]=r[4*t],n[4*t+1]=r[4*t+1],n[4*t+2]=r[4*t+2],n[4*t+3]=r[4*t+3]}else if(Number(t.format)===e.IPF_ARGB_8888){const e=r.length/4;n=new Uint8ClampedArray(r.length);for(let t=0;t<e;++t)n[4*t]=r[4*t],n[4*t+1]=r[4*t+1],n[4*t+2]=r[4*t+2],n[4*t+3]=r[4*t+3]}return new ImageData(n,t.width,t.height)})(n.imageData);n.toCanvas=()=>d(r),n.toImage=e=>((e,t)=>{const n=d(t);let r=new Image,o=n.toDataURL(e);return r.src=o,r})(e,r),n.toBlob=e=>c(e,r),n.saveToFile=async(e,t)=>{if(!e)return null;if("string"!=typeof e)throw new TypeError("FileName must be of type string.");return(async(e,t,n)=>await new Promise((async(r,o)=>{try{const o=t.split(".");let a=o[o.length-1];const s=await c(`image/${a}`,e);o.length<=1&&(a="png");const i=new File([s],t,{type:`image/${a}`});if(n){const e=URL.createObjectURL(i),n=document.createElement("a");n.href=e,n.download=t,n.click()}return r(i)}catch(e){return o()}})))(r,e,t)}}};const m="1.2.0";"string"!=typeof t.std&&o(t.std.version,m)<0&&(t.std={version:m,path:l(i+`../../dynamsoft-capture-vision-std@${m}/dist/`)});const f="2.2.10";(!t.dip||"string"!=typeof t.dip&&o(t.dip.version,f)<0)&&(t.dip={version:f,path:l(i+`../../dynamsoft-image-processing@${f}/dist/`)});class u{static getVersion(){const e=a.ddn&&a.ddn.wasm,t=a.ddn&&a.ddn.worker;return`2.2.10(Worker: ${t||"Not Loaded"}, Wasm: ${e||"Not Loaded"})`}}var g;!function(e){e[e.ICM_COLOUR=0]="ICM_COLOUR",e[e.ICM_GRAYSCALE=1]="ICM_GRAYSCALE",e[e.ICM_BINARY=2]="ICM_BINARY"}(g||(g={}));export{u as DocumentNormalizerModule,g as EnumImageColourMode};
0 commit comments