qa-prevention-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/UPNG.js

2 lines
24 KiB
JavaScript
Raw Normal View History

2024-01-02 14:12:39 +08:00
define((function(){"use strict";var e,r,t,n={};return n.toRGBA8=function(e){var r=e.width,t=e.height;if(null==e.tabs.acTL)return[n.toRGBA8.decodeImage(e.data,r,t,e).buffer];var a=[];null==e.frames[0].data&&(e.frames[0].data=e.data);for(var i=r*t*4,f=new Uint8Array(i),o=new Uint8Array(i),l=new Uint8Array(i),s=0;s<e.frames.length;s++){var c=e.frames[s],u=c.rect.x,d=c.rect.y,h=c.rect.width,v=c.rect.height,g=n.toRGBA8.decodeImage(c.data,h,v,e);if(0!=s)for(var p=0;p<i;p++)l[p]=f[p];if(0==c.blend?n._copyTile(g,h,v,f,r,t,u,d,0):1==c.blend&&n._copyTile(g,h,v,f,r,t,u,d,1),a.push(f.buffer.slice(0)),0==c.dispose);else if(1==c.dispose)n._copyTile(o,h,v,f,r,t,u,d,0);else if(2==c.dispose)for(p=0;p<i;p++)f[p]=l[p]}return a},n.toRGBA8.decodeImage=function(e,r,t,a){var i=r*t,f=n.decode._getBPP(a),o=Math.ceil(r*f/8),l=new Uint8Array(4*i),s=new Uint32Array(l.buffer),c=a.ctype,u=a.depth,d=n._bin.readUshort;if(6==c){var h=i<<2;if(8==u)for(var v=0;v<h;v+=4)l[v]=e[v],l[v+1]=e[v+1],l[v+2]=e[v+2],l[v+3]=e[v+3];if(16==u)for(v=0;v<h;v++)l[v]=e[v<<1]}else if(2==c){var g=a.tabs.tRNS;if(null==g){if(8==u)for(v=0;v<i;v++){var p=3*v;s[v]=255<<24|e[p+2]<<16|e[p+1]<<8|e[p]}if(16==u)for(v=0;v<i;v++){p=6*v;s[v]=255<<24|e[p+4]<<16|e[p+2]<<8|e[p]}}else{var b=g[0],w=g[1],y=g[2];if(8==u)for(v=0;v<i;v++){var m=v<<2;p=3*v;s[v]=255<<24|e[p+2]<<16|e[p+1]<<8|e[p],e[p]==b&&e[p+1]==w&&e[p+2]==y&&(l[m+3]=0)}if(16==u)for(v=0;v<i;v++){m=v<<2,p=6*v;s[v]=255<<24|e[p+4]<<16|e[p+2]<<8|e[p],d(e,p)==b&&d(e,p+2)==w&&d(e,p+4)==y&&(l[m+3]=0)}}}else if(3==c){var A=a.tabs.PLTE,U=a.tabs.tRNS,_=U?U.length:0;if(1==u)for(var H=0;H<t;H++){var I=H*o,M=H*r;for(v=0;v<r;v++){m=M+v<<2;var q=3*(R=e[I+(v>>3)]>>7-((7&v)<<0)&1);l[m]=A[q],l[m+1]=A[q+1],l[m+2]=A[q+2],l[m+3]=R<_?U[R]:255}}if(2==u)for(H=0;H<t;H++)for(I=H*o,M=H*r,v=0;v<r;v++){m=M+v<<2,q=3*(R=e[I+(v>>2)]>>6-((3&v)<<1)&3);l[m]=A[q],l[m+1]=A[q+1],l[m+2]=A[q+2],l[m+3]=R<_?U[R]:255}if(4==u)for(H=0;H<t;H++)for(I=H*o,M=H*r,v=0;v<r;v++){m=M+v<<2,q=3*(R=e[I+(v>>1)]>>4-((1&v)<<2)&15);l[m]=A[q],l[m+1]=A[q+1],l[m+2]=A[q+2],l[m+3]=R<_?U[R]:255}if(8==u)for(v=0;v<i;v++){var R;m=v<<2,q=3*(R=e[v]);l[m]=A[q],l[m+1]=A[q+1],l[m+2]=A[q+2],l[m+3]=R<_?U[R]:255}}else if(4==c){if(8==u)for(v=0;v<i;v++){m=v<<2;var T=e[z=v<<1];l[m]=T,l[m+1]=T,l[m+2]=T,l[m+3]=e[z+1]}if(16==u)for(v=0;v<i;v++){var z;m=v<<2,T=e[z=v<<2];l[m]=T,l[m+1]=T,l[m+2]=T,l[m+3]=e[z+2]}}else if(0==c)for(b=a.tabs.tRNS?a.tabs.tRNS:-1,H=0;H<t;H++){var x=H*o,N=H*r;if(1==u)for(var D=0;D<r;D++){var P=(T=255*(e[x+(D>>>3)]>>>7-(7&D)&1))==255*b?0:255;s[N+D]=P<<24|T<<16|T<<8|T}else if(2==u)for(D=0;D<r;D++){P=(T=85*(e[x+(D>>>2)]>>>6-((3&D)<<1)&3))==85*b?0:255;s[N+D]=P<<24|T<<16|T<<8|T}else if(4==u)for(D=0;D<r;D++){P=(T=17*(e[x+(D>>>1)]>>>4-((1&D)<<2)&15))==17*b?0:255;s[N+D]=P<<24|T<<16|T<<8|T}else if(8==u)for(D=0;D<r;D++){P=(T=e[x+D])==b?0:255;s[N+D]=P<<24|T<<16|T<<8|T}else if(16==u)for(D=0;D<r;D++){T=e[x+(D<<1)],P=d(e,x+(D<<v))==b?0:255;s[N+D]=P<<24|T<<16|T<<8|T}}return l},n.decode=function(e){for(var r,t=new Uint8Array(e),a=8,i=n._bin,f=i.readUshort,o=i.readUint,l={tabs:{},frames:[]},s=new Uint8Array(t.length),c=0,u=0,d=[137,80,78,71,13,10,26,10],h=0;h<8;h++)if(t[h]!=d[h])throw"The input is not a PNG file!";for(;a<t.length;){var v=i.readUint(t,a);a+=4;var g=i.readASCII(t,a,4);if(a+=4,"IHDR"==g)n.decode._IHDR(t,a,l);else if("CgBI"==g)l.tabs[g]=t.slice(a,a+4);else if("IDAT"==g){for(h=0;h<v;h++)s[c+h]=t[a+h];c+=v}else if("acTL"==g)l.tabs[g]={num_frames:o(t,a),num_plays:o(t,a+4)},r=new Uint8Array(t.length);else if("fcTL"==g){var p;if(0!=u)(p=l.frames[l.frames.length-1]).data=n.decode._decompress(l,r.slice(0,u),p.rect.width,p.rect.height),u=0;var b={x:o(t,a+12),y:o(t,a+16),width:o(t,a+4),height:o(t,a+8)},w=f(t,a+22);w=f(t,a+20)/(0==w?100:w);var y={rect:b,delay:Math.round(1e3*w),dispose:t[a+24],blend:t[a+25]};l.frames.push(y)}else if("fdAT"==g){for(h=0;h<v-4;h++)r[u+h]=t[a+h+4];u+=v-4}else if("pHYs"==g)l.tabs[g]=[i.readUint(t,a),i.readUint(t,a+4),t[a+8]];else if("cHRM"==g){l.tabs[g]=[];for(h=0;h<8;h++)l.tabs[g].push(i.readUint(t,a+4*h))}else if("tEXt"==g||"zTXt"==g){null==l.tabs[g]&&(l.tabs[g]={});var m=i.n