;(function(){ var UTIF = {}; // Make available for import by `require()` if (typeof module == "object") {module.exports = UTIF;} else {self.UTIF = UTIF;} var pako; if (typeof require == "function") {pako = require("pako");} else {pako = self.pako;} function log() { if (typeof process=="undefined" || process.env.NODE_ENV=="development") console.log.apply(console, arguments); } (function(UTIF, pako){ // Following lines add a JPEG decoder to UTIF.JpegDecoder (function(){var V="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(g){return typeof g}:function(g){return g&&"function"===typeof Symbol&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g},D=function(){function g(g){this.message="JPEG error: "+g}g.prototype=Error();g.prototype.name="JpegError";return g.constructor=g}(),P=function(){function g(g,D){this.message=g;this.g=D}g.prototype=Error();g.prototype.name="DNLMarkerError";return g.constructor=g}();(function(){function g(){this.M= null;this.B=-1}function W(a,d){for(var f=0,e=[],b,B,k=16;0>x&1;z=a[d++];if(255=== z){var c=a[d++];if(c){if(220===c&&g){d+=2;var b=a[d++]<<8|a[d++];if(0>>7}function q(a){for(;;){a=a[n()];if("number"===typeof a)return a;if("object"!==("undefined"===typeof a?"undefined":V(a)))throw new D("invalid huffman sequence");}}function h(a){for(var c=0;0= 1<d;){var h=q(a.o),k=h&15;h>>=4;if(0===k){if(15>h)break;d+=16}else d+=h,a.a[b+J[d]]=c(k),d++}}function w(a,d){var b=q(a.D);b=0===b?0:c(b)<>=4;if(0===f){if(15>e){A=h(e)+(1<a.a[f]? -1:1;switch(E){case 0:e=q(a.o);f=e&15;e>>=4;if(0===f)15>e?(A=h(e)+(1<=y)throw new D("marker was not found"); if(65488<=y&&65495>=y)d+=2;else break}(y=N(a,d))&&y.f&&((0,_util.warn)("decodeScan - unexpected Scan data, current marker is: "+y.f),d=y.offset);return d-v}function Y(a,d){for(var f=d.c,e=d.l,b=new Int16Array(64),B=0;Bh;h+=8){var c=q[l+h];var C=q[l+h+1];var w=q[l+h+2];var p=q[l+h+3];var m=q[l+h+4];var t=q[l+h+5];var g=q[l+h+6];var u=q[l+h+7];c*=n[h];if(0===(C| w|p|m|t|g|u))c=5793*c+512>>10,r[h]=c,r[h+1]=c,r[h+2]=c,r[h+3]=c,r[h+4]=c,r[h+5]=c,r[h+6]=c,r[h+7]=c;else{C*=n[h+1];w*=n[h+2];p*=n[h+3];m*=n[h+4];t*=n[h+5];g*=n[h+6];u*=n[h+7];var v=5793*c+128>>8;var z=5793*m+128>>8;var x=w;var A=g;m=2896*(C-u)+128>>8;u=2896*(C+u)+128>>8;p<<=4;t<<=4;v=v+z+1>>1;z=v-z;c=3784*x+1567*A+128>>8;x=1567*x-3784*A+128>>8;A=c;m=m+t+1>>1;t=m-t;u=u+p+1>>1;p=u-p;v=v+A+1>>1;A=v-A;z=z+x+1>>1;x=z-x;c=2276*m+3406*u+2048>>12;m=3406*m-2276*u+2048>>12;u=c;c=799*p+4017*t+2048>>12;p=4017* p-799*t+2048>>12;t=c;r[h]=v+u;r[h+7]=v-u;r[h+1]=z+t;r[h+6]=z-t;r[h+2]=x+p;r[h+5]=x-p;r[h+3]=A+m;r[h+4]=A-m}}for(n=0;8>n;++n)c=r[n],C=r[n+8],w=r[n+16],p=r[n+24],m=r[n+32],t=r[n+40],g=r[n+48],u=r[n+56],0===(C|w|p|m|t|g|u)?(c=5793*c+8192>>14,c=-2040>c?0:2024<=c?255:c+2056>>4,q[l+n]=c,q[l+n+8]=c,q[l+n+16]=c,q[l+n+24]=c,q[l+n+32]=c,q[l+n+40]=c,q[l+n+48]=c,q[l+n+56]=c):(v=5793*c+2048>>12,z=5793*m+2048>>12,x=w,A=g,m=2896*(C-u)+2048>>12,u=2896*(C+u)+2048>>12,v=(v+z+1>>1)+4112,z=v-z,c=3784*x+1567*A+2048>> 12,x=1567*x-3784*A+2048>>12,A=c,m=m+t+1>>1,t=m-t,u=u+p+1>>1,p=u-p,v=v+A+1>>1,A=v-A,z=z+x+1>>1,x=z-x,c=2276*m+3406*u+2048>>12,m=3406*m-2276*u+2048>>12,u=c,c=799*p+4017*t+2048>>12,p=4017*p-799*t+2048>>12,t=c,c=v+u,u=v-u,C=z+t,g=z-t,w=x+p,t=x-p,p=A+m,m=A-m,c=16>c?0:4080<=c?255:c>>4,C=16>C?0:4080<=C?255:C>>4,w=16>w?0:4080<=w?255:w>>4,p=16>p?0:4080<=p?255:p>>4,m=16>m?0:4080<=m?255:m>>4,t=16>t?0:4080<=t?255:t>>4,g=16>g?0:4080<=g?255:g>>4,u=16>u?0:4080<=u?255:u>>4,q[l+n]=c,q[l+n+8]=C,q[l+n+16]=w,q[l+n+24]= p,q[l+n+32]=m,q[l+n+40]=t,q[l+n+48]=g,q[l+n+56]=u)}return d.a}function N(a,d){var f=2=e)return null;var b=a[d]<<8|a[d+1];if(65472<=b&&65534>=b)return{f:null,F:b,offset:d};for(var B=a[f]<<8|a[f+1];!(65472<=B&&65534>=B);){if(++f>=e)return null;B=a[f]<<8|a[f+1]}return{f:b.toString(16),F:B,offset:f}}var J=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56, 57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);g.prototype={parse:function(a){function d(){var d=a[k]<<8|a[k+1];k+=2;return d}function f(){var b=d();b=k+b-2;var c=N(a,b,k);c&&c.f&&((0,_util.warn)("readDataBlock - incorrect length, current marker is: "+c.f),b=c.offset);b=a.subarray(k,b);k+=b.length;return b}function e(a){for(var b=Math.ceil(a.v/8/a.s),c=Math.ceil(a.g/8/a.u),d=0;d>4)for(c=0;64>c;c++)g=J[c],p[g]=a[k++];else if(1===w>>4)for(c=0;64>c;c++)g=J[c],p[g]=d();else throw new D("DQT - invalid table spec");b[w&15]=p}break;case 65472:case 65473:case 65474:if(m)throw new D("Only single frame JPEGs supported");d();var m={};m.X=65473===h;m.S=65474===h;m.precision=a[k++];h=d();m.g= B||h;m.v=d();m.b=[];m.C={};c=a[k++];for(h=p=w=0;h>4;var H=a[k+1]&15;wc;c++,k++)t+=p[c]=a[k];H=new Uint8Array(t);for(c=0;c>4?q:n)[w&15]=W(p,H)}break;case 65501:d();var u=d();break;case 65498:c=1===++r&&!B;d();w=a[k++];g=[];for(h=0;h>4];v.o=n[p&15];g.push(v)}h=a[k++];w=a[k++];p=a[k++];try{var z=X(a,k,m,g,u,h,w,p>>4,p&15,c);k+=z}catch(x){if(x instanceof P)return(0,_util.warn)('Attempting to re-parse JPEG image using "scanLines" parameter found in DNL marker (0xFFDC) segment.'),this.parse(a,{N:x.g});throw x;}break;case 65500:k+=4;break;case 65535:255!==a[k]&&k--;break;default:if(255===a[k-3]&&192<=a[k-2]&&254>=a[k-2])k-=3;else if((c=N(a,k-2))&&c.f)(0,_util.warn)("JpegImage.parse - unexpected data, current marker is: "+ c.f),k=c.offset;else throw new D("unknown marker "+h.toString(16));}h=d()}this.width=m.v;this.height=m.g;this.A=l;this.b=[];for(h=0;h>8)+e[f+1];return r},w:function(){return this.A?!!this.A.W:3===this.i?0===this.B?!1:!0:1===this.B?!0:!1},I:function(a){for(var d,f,e,b=0,g=a.length;b>>3)]; if(bcnt==null) bcnt = img["t325"]; var bytes = new Uint8Array(img.height*(bipl>>>3)), bilen = 0; if(img["t322"]!=null) // tiled { var tw = img["t322"][0], th = img["t323"][0]; var tx = Math.floor((img.width + tw - 1) / tw); var ty = Math.floor((img.height + th - 1) / th); var tbuff = new Uint8Array(Math.ceil(tw*th*bipp/8)|0); for(var y=0; y>>8); } else if(bps==12) for(var i=0; i>>4); tgt[toff++] = ((out[i]<<4)|(out[i+1]>>>8))&255; tgt[toff++] = out[i+1]&255; } else throw new Error("unsupported bit depth "+bps); } else { var parser = new UTIF.JpegDecoder(); parser.parse(buff); var decoded = parser.getData(parser.width, parser.height); for (var i=0; i 1); } if(!isTiled) { if(data[off]==255 && data[off+1]==SOI) return { jpegOffset: off }; if(jpgIchgFmt!=null) { if(data[off+jifoff]==255 && data[off+jifoff+1]==SOI) joff = off+jifoff; else log("JPEGInterchangeFormat does not point to SOI"); if(jpgIchgFmtLen==null) log("JPEGInterchangeFormatLength field is missing"); else if(jifoff >= soff || (jifoff+jiflen) <= soff) log("JPEGInterchangeFormatLength field value is invalid"); if(joff != null) return { jpegOffset: joff }; } } if(ycbcrss!=null) { ssx = ycbcrss[0]; ssy = ycbcrss[1]; } if(jpgIchgFmt!=null) if(jpgIchgFmtLen!=null) if(jiflen >= 2 && (jifoff+jiflen) <= soff) { if(data[off+jifoff+jiflen-2]==255 && data[off+jifoff+jiflen-1]==SOI) tables = new Uint8Array(jiflen-2); else tables = new Uint8Array(jiflen); for(i=0; i offset to first strip or tile"); if(tables == null) { var ooff = 0, out = []; out[ooff++] = 255; out[ooff++] = SOI; var qtables = img["t519"]; if(qtables==null) throw new Error("JPEGQTables tag is missing"); for(i=0; i>> 8); out[ooff++] = nc & 255; out[ooff++] = (i | (k << 4)); for(j=0; j<16; j++) out[ooff++] = data[off+htables[i]+j]; for(j=0; j>> 8) & 255; out[ooff++] = img.height & 255; out[ooff++] = (img.width >>> 8) & 255; out[ooff++] = img.width & 255; out[ooff++] = spp; if(spp==1) { out[ooff++] = 1; out[ooff++] = 17; out[ooff++] = 0; } else for(i=0; i<3; i++) { out[ooff++] = i + 1; out[ooff++] = (i != 0) ? 17 : (((ssx & 15) << 4) | (ssy & 15)); out[ooff++] = i; } if(jpgresint!=null && jpgresint[0]!=0) { out[ooff++] = 255; out[ooff++] = DRI; out[ooff++] = 0; out[ooff++] = 4; out[ooff++] = (jpgresint[0] >>> 8) & 255; out[ooff++] = jpgresint[0] & 255; } tables = new Uint8Array(out); } var sofpos = -1; i = 0; while(i < (tables.length - 1)) { if(tables[i]==255 && tables[i+1]==SOF0) { sofpos = i; break; } i++; } if(sofpos == -1) { var tmptab = new Uint8Array(tables.length + 10 + 3*spp); tmptab.set(tables); var tmpoff = tables.length; sofpos = tables.length; tables = tmptab; tables[tmpoff++] = 255; tables[tmpoff++] = SOF0; tables[tmpoff++] = 0; tables[tmpoff++] = 8 + 3*spp; tables[tmpoff++] = 8; tables[tmpoff++] = (img.height >>> 8) & 255; tables[tmpoff++] = img.height & 255; tables[tmpoff++] = (img.width >>> 8) & 255; tables[tmpoff++] = img.width & 255; tables[tmpoff++] = spp; if(spp==1) { tables[tmpoff++] = 1; tables[tmpoff++] = 17; tables[tmpoff++] = 0; } else for(i=0; i<3; i++) { tables[tmpoff++] = i + 1; tables[tmpoff++] = (i != 0) ? 17 : (((ssx & 15) << 4) | (ssy & 15)); tables[tmpoff++] = i; } } if(data[soff]==255 && data[soff+1]==SOS) { var soslen = (data[soff+2]<<8) | data[soff+3]; sosMarker = new Uint8Array(soslen+2); sosMarker[0] = data[soff]; sosMarker[1] = data[soff+1]; sosMarker[2] = data[soff+2]; sosMarker[3] = data[soff+3]; for(i=0; i<(soslen-2); i++) sosMarker[i+4] = data[soff+i+4]; } else { sosMarker = new Uint8Array(2 + 6 + 2*spp); var sosoff = 0; sosMarker[sosoff++] = 255; sosMarker[sosoff++] = SOS; sosMarker[sosoff++] = 0; sosMarker[sosoff++] = 6 + 2*spp; sosMarker[sosoff++] = spp; if(spp==1) { sosMarker[sosoff++] = 1; sosMarker[sosoff++] = 0; } else for(i=0; i<3; i++) { sosMarker[sosoff++] = i+1; sosMarker[sosoff++] = (i << 4) | i; } sosMarker[sosoff++] = 0; sosMarker[sosoff++] = 63; sosMarker[sosoff++] = 0; } return { jpegOffset: off, tables: tables, sosMarker: sosMarker, sofPosition: sofpos }; } UTIF.decode._decodeOldJPEG = function(img, data, off, len, tgt, toff) { var i, dlen, tlen, buff, buffoff; var jpegData = UTIF.decode._decodeOldJPEGInit(img, data, off, len); if(jpegData.jpegOffset!=null) { dlen = off+len-jpegData.jpegOffset; buff = new Uint8Array(dlen); for(i=0; i>> 8) & 255; buff[jpegData.sofPosition+6] = img.height & 255; buff[jpegData.sofPosition+7] = (img.width >>> 8) & 255; buff[jpegData.sofPosition+8] = img.width & 255; if(data[off]!=255 || data[off+1]!=SOS) { buff.set(jpegData.sosMarker, bufoff); bufoff += sosMarker.length; } for(i=0; i=0 && n<128) for(var i=0; i< n+1; i++) { ta[toff]=sa[off]; toff++; off++; } if(n>=-127 && n<0) { for(var i=0; i<-n+1; i++) { ta[toff]=sa[off]; toff++; } off++; } } } UTIF.decode._decodeThunder = function(data, off, len, tgt, toff) { var d2 = [ 0, 1, 0, -1 ], d3 = [ 0, 1, 2, 3, 0, -3, -2, -1 ]; var lim = off+len, qoff = toff*2, px = 0; while(off>>6), n = (b&63); off++; if(msk==3) { px=(n&15); tgt[qoff>>>1] |= (px<<(4*(1-qoff&1))); qoff++; } if(msk==0) for(var i=0; i>>1] |= (px<<(4*(1-qoff&1))); qoff++; } if(msk==2) for(var i=0; i<2; i++) { var d=(n>>>(3*(1-i)))&7; if(d!=4) { px+=d3[d]; tgt[qoff>>>1] |= (px<<(4*(1-qoff&1))); qoff++; } } if(msk==1) for(var i=0; i<3; i++) { var d=(n>>>(2*(2-i)))&3; if(d!=2) { px+=d2[d]; tgt[qoff>>>1] |= (px<<(4*(1-qoff&1))); qoff++; } } } } UTIF.decode._dmap = { "1":0,"011":1,"000011":2,"0000011":3, "010":-1,"000010":-2,"0000010":-3 }; UTIF.decode._lens = ( function() { var addKeys = function(lens, arr, i0, inc) { for(var i=0; i>>3)>>3]>>>(7-(boff&7)))&1; if(fo==2) bit = (data[boff>>>3]>>>( (boff&7)))&1; boff++; wrd+=bit; if(mode=="H") { if(U._lens[clr][wrd]!=null) { var dl=U._lens[clr][wrd]; wrd=""; len+=dl; if(dl<64) { U._addNtimes(line,len,clr); a0+=len; clr=1-clr; len=0; toRead--; if(toRead==0) mode=""; } } } else { if(wrd=="0001") { wrd=""; U._addNtimes(line,b2-a0,clr); a0=b2; } if(wrd=="001" ) { wrd=""; mode="H"; toRead=2; } if(U._dmap[wrd]!=null) { a1 = b1+U._dmap[wrd]; U._addNtimes(line, a1-a0, clr); a0=a1; wrd=""; clr=1-clr; } } if(line.length==w && mode=="") { U._writeBits(line, tgt, toff*8+y*bipl); clr=0; y++; a0=0; pline=U._makeDiff(line); line=[]; } //if(wrd.length>150) { log(wrd); break; throw "e"; } } } UTIF.decode._findDiff = function(line, x, clr) { for(var i=0; i=x && line[i+1]==clr) return line[i]; } UTIF.decode._makeDiff = function(line) { var out = []; if(line[0]==1) out.push(0,1); for(var i=1; i>>3)>>3]>>>(7-(boff&7)))&1; if(fo==2) bit = (data[boff>>>3]>>>( (boff&7)))&1; boff++; wrd+=bit; if(is1D) { if(U._lens[clr][wrd]!=null) { var dl=U._lens[clr][wrd]; wrd=""; len+=dl; if(dl<64) { U._addNtimes(line,len,clr); clr=1-clr; len=0; } } } else { if(mode=="H") { if(U._lens[clr][wrd]!=null) { var dl=U._lens[clr][wrd]; wrd=""; len+=dl; if(dl<64) { U._addNtimes(line,len,clr); a0+=len; clr=1-clr; len=0; toRead--; if(toRead==0) mode=""; } } } else { if(wrd=="0001") { wrd=""; U._addNtimes(line,b2-a0,clr); a0=b2; } if(wrd=="001" ) { wrd=""; mode="H"; toRead=2; } if(U._dmap[wrd]!=null) { a1 = b1+U._dmap[wrd]; U._addNtimes(line, a1-a0, clr); a0=a1; wrd=""; clr=1-clr; } } } if(wrd.endsWith("000000000001")) // needed for some files { if(y>=0) U._writeBits(line, tgt, toff*8+y*bipl); if(fo==1) is1D = ((data[boff>>>3]>>>(7-(boff&7)))&1)==1; if(fo==2) is1D = ((data[boff>>>3]>>>( (boff&7)))&1)==1; boff++; if(U._decodeG3.allow2D==null) U._decodeG3.allow2D=is1D; if(!U._decodeG3.allow2D) { is1D = true; boff--; } //log("EOL",y, "next 1D:", is1D); wrd=""; clr=0; y++; a0=0; pline=U._makeDiff(line); line=[]; } } if(line.length==w) U._writeBits(line, tgt, toff*8+y*bipl); } UTIF.decode._addNtimes = function(arr, n, val) { for(var i=0; i>>3] |= (bits[i]<<(7-((boff+i)&7))); } UTIF.decode._decodeLZW = function(data, off, tgt, toff) { if(UTIF.decode._lzwTab==null) { var tb=new Uint32Array(0xffff), tn=new Uint16Array(0xffff), chr=new Uint8Array(2e6); for(var i=0; i<256; i++) { chr[i<<2]=i; tb[i]=i<<2; tn[i]=1; } UTIF.decode._lzwTab = [tb,tn,chr]; } var copy = UTIF.decode._copyData; var tab = UTIF.decode._lzwTab[0], tln=UTIF.decode._lzwTab[1], chr=UTIF.decode._lzwTab[2], totl = 258, chrl = 258<<2; var bits = 9, boff = off<<3; // offset in bits var ClearCode = 256, EoiCode = 257; var v = 0, Code = 0, OldCode = 0; while(true) { v = (data[boff>>>3]<<16) | (data[(boff+8)>>>3]<<8) | data[(boff+16)>>>3]; Code = ( v>>(24-(boff&7)-bits) ) & ((1<>>3]<<16) | (data[(boff+8)>>>3]<<8) | data[(boff+16)>>>3]; Code = ( v>>(24-(boff&7)-bits) ) & ((1<=totl) { tab[totl] = chrl; chr[tab[totl]] = cd[0]; tln[totl]=1; chrl=(chrl+1+3)&~0x03; totl++; } else { tab[totl] = chrl; var nit = tab[OldCode], nil = tln[OldCode]; copy(chr,nit,chr,chrl,nil); chr[chrl+nil]=chr[cd]; nil++; tln[totl]=nil; totl++; chrl=(chrl+nil+3)&~0x03; } if(totl+1==(1<=totl) { tab[totl] = chrl; tln[totl]=0; totl++; } else { tab[totl] = chrl; var nit = tab[OldCode], nil = tln[OldCode]; copy(chr,nit,chr,chrl,nil); chr[chrl+nil]=chr[chrl]; nil++; tln[totl]=nil; totl++; copy(chr,chrl,tgt,toff,nil); toff += nil; chrl=(chrl+nil+3)&~0x03; } if(totl+1==(1<>>----------------"); for(var i=0; i4) { bin.writeUint(data, offset, eoff); toff=eoff; } if(type==2) { bin.writeASCII(data, toff, val); } if(type==3) { for(var i=0; i4) { dlen += (dlen&1); eoff += dlen; } offset += 4; } return [offset, eoff]; } UTIF.toRGBA8 = function(out) { var w = out.width, h = out.height, area = w*h, qarea = area*4, data = out.data; var img = new Uint8Array(area*4); // 0: WhiteIsZero, 1: BlackIsZero, 2: RGB, 3: Palette color, 4: Transparency mask, 5: CMYK var intp = out["t262"][0], bps = (out["t258"]?Math.min(32,out["t258"][0]):1), isLE = out.isLE ? 1 : 0; //log("interpretation: ", intp, "bps", bps, out); if(false) {} else if(intp==0) { var bpl = Math.ceil(bps*w/8); for(var y=0; y>3)])>>(7- (i&7)))& 1; img[qi]=img[qi+1]=img[qi+2]=( 1-px)*255; img[qi+3]=255; } if(bps== 4) for(var i=0; i>1)])>>(4-4*(i&1)))&15; img[qi]=img[qi+1]=img[qi+2]=(15-px)* 17; img[qi+3]=255; } if(bps== 8) for(var i=0; i>3)])>>(7- (i&7)))&1; img[qi]=img[qi+1]=img[qi+2]=(px)*255; img[qi+3]=255; } if(bps== 2) for(var i=0; i>2)])>>(6-2*(i&3)))&3; img[qi]=img[qi+1]=img[qi+2]=(px)* 85; img[qi+3]=255; } if(bps== 8) for(var i=0; i0) for(var i=0; i>8); img[qi+1]=(map[256+mi]>>8); img[qi+2]=(map[512+mi]>>8); img[qi+3]=255; } } else if(intp==5) { var smpls = out["t258"]?out["t258"].length : 4; var gotAlpha = smpls>4 ? 1 : 0; for(var i=0; i> 8)&255; buff[p+1] = n&255; }, writeUint : function(buff, p, n) { buff[p] = (n>>24)&255; buff[p+1] = (n>>16)&255; buff[p+2] = (n>>8)&255; buff[p+3] = (n>>0)&255; }, writeASCII : function(buff, p, s) { for(var i = 0; i < s.length; i++) buff[p+i] = s.charCodeAt(i); }, writeDouble: function(buff, p, n) { UTIF._binBE.fl64[0] = n; for (var i = 0; i < 8; i++) buff[p + i] = UTIF._binBE.ui8[7 - i]; } } UTIF._binBE.ui8 = new Uint8Array (8); UTIF._binBE.i16 = new Int16Array (UTIF._binBE.ui8.buffer); UTIF._binBE.i32 = new Int32Array (UTIF._binBE.ui8.buffer); UTIF._binBE.ui32 = new Uint32Array (UTIF._binBE.ui8.buffer); UTIF._binBE.fl32 = new Float32Array(UTIF._binBE.ui8.buffer); UTIF._binBE.fl64 = new Float64Array(UTIF._binBE.ui8.buffer); UTIF._binLE = { nextZero : UTIF._binBE.nextZero, readUshort : function(buff, p) { return (buff[p+1]<< 8) | buff[p]; }, readShort : function(buff, p) { var a=UTIF._binBE.ui8; a[0]=buff[p+0]; a[1]=buff[p+1]; return UTIF._binBE. i16[0]; }, readInt : function(buff, p) { var a=UTIF._binBE.ui8; a[0]=buff[p+0]; a[1]=buff[p+1]; a[2]=buff[p+2]; a[3]=buff[p+3]; return UTIF._binBE. i32[0]; }, readUint : function(buff, p) { var a=UTIF._binBE.ui8; a[0]=buff[p+0]; a[1]=buff[p+1]; a[2]=buff[p+2]; a[3]=buff[p+3]; return UTIF._binBE.ui32[0]; }, readASCII : UTIF._binBE.readASCII, readFloat : function(buff, p) { var a=UTIF._binBE.ui8; for(var i=0;i<4;i++) a[i]=buff[p+ i]; return UTIF._binBE.fl32[0]; }, readDouble : function(buff, p) { var a=UTIF._binBE.ui8; for(var i=0;i<8;i++) a[i]=buff[p+ i]; return UTIF._binBE.fl64[0]; } } UTIF._copyTile = function(tb, tw, th, b, w, h, xoff, yoff) { //log("copyTile", tw, th, w, h, xoff, yoff); var xlim = Math.min(tw, w-xoff); var ylim = Math.min(th, h-yoff); for(var y=0; y