// COPYRIGHT © 2022 Esri // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // This material is licensed for use under the Esri Master License // Agreement (MLA), and is bound by the terms of that agreement. // You may redistribute and use this code without modification, // provided you adhere to the terms of the MLA and include this // copyright notice. // // See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english // // For additional information, contact: // Environmental Systems Research Institute, Inc. // Attn: Contracts and Legal Services Department // 380 New York Street // Redlands, California, USA 92373 // USA // // email: contracts@esri.com // // See http://js.arcgis.com/3.43/esri/copyright.txt for details. define(["./Jpg","./Zlib"],(function(e,t){"use strict";var n,a=function(){var e=new ArrayBuffer(4),t=new Uint8Array(e),n=new Uint32Array(e);return t[0]=1,t[1]=2,t[2]=3,t[3]=4,67305985===n[0]},r=((n=[])[254]="NEWSUBFILETYPE",n[255]="SUBFILETYPE",n[256]="IMAGEWIDTH",n[257]="IMAGELENGTH",n[258]="BITSPERSAMPLE",n[259]="COMPRESSION",n[262]="PHOTOMETRICINTERPRETATION",n[263]="THRESHHOLDING",n[264]="CELLWIDTH",n[265]="CELLLENGTH",n[266]="FILLORDER",n[269]="DOCUMENTNAME",n[270]="IMAGEDESCRIPTION",n[271]="MAKE",n[272]="MODEL",n[273]="STRIPOFFSETS",n[274]="ORIENTATION",n[277]="SAMPLESPERPIXEL",n[278]="ROWSPERSTRIP",n[279]="STRIPBYTECOUNTS",n[280]="MINSAMPLEVALUE",n[281]="MAXSAMPLEVALUE",n[282]="XRESOLUTION",n[283]="YRESOLUTION",n[284]="PLANARCONFIGURATION",n[285]="PAGENAME",n[286]="XPOSITION",n[287]="YPOSITION",n[288]="FREEOFFSETS",n[289]="FREEBYTECOUNTS",n[290]="GRAYRESPONSEUNIT",n[291]="GRAYRESPONSECURVE",n[292]="T4OPTIONS",n[293]="T6OPTIONS",n[296]="RESOLUTIONUNIT",n[297]="PAGENUMBER",n[300]="COLORRESPONSEUNIT",n[301]="TRANSFERFUNCTION",n[305]="SOFTWARE",n[306]="DATETIME",n[315]="ARTIST",n[316]="HOSTCOMPUTER",n[317]="PREDICTOR",n[318]="WHITEPOINT",n[319]="PRIMARYCHROMATICITIES",n[320]="COLORMAP",n[321]="HALFTONEHINTS",n[322]="TILEWIDTH",n[323]="TILELENGTH",n[324]="TILEOFFSETS",n[325]="TILEBYTECOUNTS",n[326]="BADFAXLINES",n[327]="CLEANFAXDATA",n[328]="CONSECUTIVEBADFAXLINES",n[330]="SUBIFD",n[332]="INKSET",n[333]="INKNAMES",n[334]="NUMBEROFINKS",n[336]="DOTRANGE",n[337]="TARGETPRINTER",n[338]="EXTRASAMPLES",n[339]="SAMPLEFORMAT",n[340]="SMINSAMPLEVALUE",n[341]="SMAXSAMPLEVALUE",n[342]="TRANSFERRANGE",n[347]="JPEGTABLES",n[512]="JPEGPROC",n[513]="JPEGIFOFFSET",n[514]="JPEGIFBYTECOUNT",n[515]="JPEGRESTARTINTERVAL",n[517]="JPEGLOSSLESSPREDICTORS",n[518]="JPEGPOINTTRANSFORM",n[519]="JPEGQTABLES",n[520]="JPEGDCTABLES",n[521]="JPEGACTABLES",n[529]="YCBCRCOEFFICIENTS",n[530]="YCBCRSUBSAMPLING",n[531]="YCBCRPOSITIONING",n[532]="REFERENCEBLACKWHITE",n[33550]="GEOPIXELSCALE",n[33922]="GEOTIEPOINTS",n[33432]="COPYRIGHT",n[42112]="GDAL_METADATA",n[42113]="GDAL_NODATA",n[50844]="RPCCOEFFICIENT",n[34735]="GEOKEYDIRECTORY",n[34736]="GEODOUBLEPARAMS",n[34737]="GEOASCIIPARAMS",n),i=[0,1,1,2,4,8,1,1,2,4,8,4,8],A=function(e,t){var n="UNKNOWN";return 3===e?n="F32":1===e?t<=8?n="U8":t<=16?n="U16":t<=32&&(n="U32"):2===e&&(t<=8?n="S8":t<=16?n="S16":t<=32&&(n="S32")),n},E=function(e,t,n){var a,r,A=[],E=n.fieldType,s=n.fieldValueCount,l=n.fieldValueOffset,T=l,I=i[E],S=8*I,o=s*I,O=s*i[E]*8;if(O<=32)if(t||(l>>>=32-O),1===s)A=[l];else for(r=0;r>>32-S);else for(T=l;T12||((f={fieldTag:T,fieldType:I,fieldValueCount:S,fieldValueOffset:o}).fieldValues=E(e,n,f),O[(N=T,R=void 0,R=r[N],void 0===R&&(R="unknown"+N),R)]={type:I,values:f.fieldValues});w.push(O)}return w}(n,l);if(0===T.length)throw"no valid image file directory";var I=T[0],S=void 0===I.GDAL_NODATA||null===I.GDAL_NODATA?null:parseFloat(I.GDAL_NODATA.values[0]);if(I.TILEOFFSETS?s=function(n,r,i){var E,s,l,T=a()===r.littleEndian,I=i.TILEOFFSETS?i.TILEOFFSETS.values:void 0;if(void 0!==I){var S=i.TILEBYTECOUNTS.values,o=i.TILEWIDTH.values[0],O=i.TILELENGTH.values[0],f=i.IMAGEWIDTH.values[0],N=i.IMAGELENGTH.values[0],R=f*N,w=i.BITSPERSAMPLE.values[0],U=i.SAMPLESPERPIXEL.values[0],P=i.SAMPLEFORMAT?i.SAMPLEFORMAT.values[0]:1,u=A(P,w);if(1!==(i.PLANARCONFIGURATION?i.PLANARCONFIGURATION.values[0]:1))throw console.log("can only handle PLANARCONFIGURATION=1"),"can only handle PLANARCONFIGURATION=1";var L=i.COMPRESSION?i.COMPRESSION.values[0]:1;if(1!==L&&6!==L&&8!==L&&32946!==L)throw console.log("this compression is not supported at this moment"),"this compression is not supported at this moment";if(!(P>3)){var h,y,c,g,F,d,M,C,D,v,G,p,B,V,b,H,m;3===P?(s=new Float32Array(R*U),l=Float32Array):1===P?w<=8?(s=new Uint8Array(R*U),l=Uint8Array):w<=16?(s=new Uint16Array(R*U),l=Uint16Array):w<=32&&(s=new Uint32Array(R*U),l=Uint32Array):2===P&&(w<=8?(s=new Int8Array(R*U),l=Int8Array):w<=16?(s=new Int16Array(R*U),l=Int16Array):w<=32&&(s=new Int32Array(R*U),l=Int32Array));var x=Math.ceil(f/o);if(w%8==0)for(h=0;h3)){var L,h,y,c,g,F,d,M,C;3===U?(s=new Float32Array(N*w),l=Float32Array):1===U?R<=8?(s=new Uint8Array(N*w),l=Uint8Array):R<=16?(s=new Uint16Array(N*w),l=Uint16Array):R<=32&&(s=new Uint32Array(N*w),l=Uint32Array):2===U&&(R<=8?(s=new Int8Array(N*w),l=Int8Array):R<=16?(s=new Int16Array(N*w),l=Int16Array):R<=32&&(s=new Int32Array(O*f*w),l=Int32Array));var D=o;if(R%8==0)for(L=0;Lf?f-L*o:o,"U8"===P||"S8"===P||T){if(8===u||32946===u)F=new Uint8Array(n,I[L],S[L]),C=new t(F).getBytes(),g=new ArrayBuffer(C.length),(F=new Uint8Array(g)).set(C),F.length!==D*O*w*R/8&&console.log("strip byte counts is different than expected");else if(6===u){F=new Uint8Array(n,I[L],S[L]);var v=new e;v.parse(F);var G=v.getData(v.width,v.height);g=new ArrayBuffer(G.length),(F=new Uint8Array(g)).set(G)}else 1===u&&(S[L]!==D*O*w*R/8&&console.log("strip byte counts is different than expected"),g=n.slice(I[L],I[L]+S[L]));E=new l(g)}else{switch(6===u||8===u||32946===u?(F=new Uint8Array(n,I[L],S[L]),F=new t(F).getBytes(),g=new ArrayBuffer(F.length),d=new Uint8Array(g),F.length!==D*O*w*R/8&&console.log("strip byte counts is different than expected")):1===u&&(S[L]!==D*O*w*R/8&&console.log("strip byte counts is different than expected"),g=new ArrayBuffer(S[L]),F=new Uint8Array(n,I[L],S[L]),d=new Uint8Array(g)),P){case"U16":case"S16":for(y=0;y1e24)for(i=0;i