2022-02-22 22:13:16 -05:00
|
|
|
var CreateAmtRemoteDesktop=function(e,t){var S={};function g(e){return String.fromCharCode.apply(null,e)}function p(e,t,a,n,r,o,i){var s,c,h,d,l=e[t++],v={},u=0,m=0;if(0==l){if(2==S.bpp)for(d=0;d<i;d++)y(e[t++]+(e[t++]<<8),d);else for(d=0;d<i;d++)C(e[t++],d);w(S.spare,a,n)}else if(1==l){S.graymode?(c=e[t++],S.lowcolor&&(c<<=4),S.canvas.fillStyle="rgb("+c+","+c+","+c+")"):(c=e[t++]+(2==S.bpp?e[t++]<<8:0),S.canvas.fillStyle="rgb("+(1==S.bpp?(224&c)+","+((28&c)<<3)+","+T((3&c)<<6):(c>>8&248)+","+(c>>3&252)+","+((31&c)<<3))+")");var f=k(a);n=x(0,n),a=f,S.canvas.fillRect(a,n,r,o)}else if(1<l&&l<17){var g=4,p=15;if(2==S.bpp){for(d=0;d<l;d++)v[d]=e[t++]+(e[t++]<<8);for(2==l?p=g=1:l<=4&&(g=2,p=3);u<i&&t<e.byteLength;)for(c=e[t++],d=8-g;0<=d;d-=g)y(v[c>>d&p],u++)}else{for(d=0;d<l;d++)v[d]=e[t++];for(2==l?p=g=1:l<=4&&(g=2,p=3);u<i&&t<e.byteLength;)for(c=e[t++],d=8-g;0<=d;d-=g)C(v[c>>d&p],u++)}w(S.spare,a,n)}else if(128==l){if(2==S.bpp)for(;u<i&&t<e.byteLength;){for(c=e[t++]+(e[t++]<<8),m=1;m+=h=e[t++],255==h;);if(0==S.rotation)D(c,u,m),u+=m;else for(;0<=--m;)y(c,u++)}else for(;u<i&&t<e.byteLength;){for(c=e[t++],m=1;m+=h=e[t++],255==h;);if(0==S.rotation)b(c,u,m),u+=m;else for(;0<=--m;)C(c,u++)}w(S.spare,a,n)}else if(129<l){if(2==S.bpp)for(d=0;d<l-128;d++)v[d]=e[t++]+(e[t++]<<8);else for(d=0;d<l-128;d++)v[d]=e[t++];for(;u<i&&t<e.byteLength;){if(m=1,c=v[(s=e[t++])%128],127<s)for(;m+=h=e[t++],255==h;);if(0==S.rotation)(2==S.bpp?D:b)(c,u,m),u+=m;else if(2==S.bpp)for(;0<=--m;)y(c,u++);else for(;0<=--m;)C(c,u++)}w(S.spare,a,n)}}function w(e,t,a){var n,r,o;1!=S.holding&&(r=t,o=a,n=0==S.rotation?r:1==S.rotation?S.canvas.canvas.width-S.sparew2-o:2==S.rotation?S.canvas.canvas.width-S.sparew2-r:3==S.rotation?o:0,r=t,o=a,a=0==S.rotation?o:1==S.rotation?r:2==S.rotation?S.canvas.canvas.height-S.spareh2-o:3==S.rotation?S.canvas.canvas.height-S.spareh-r:0,t=n,S.canvas.putImageData(e,t,a))}function C(e,t){var a,n,r=t<<2;0<S.rotation&&(1==S.rotation?(a=t%S.sparew,n=Math.floor(t/S.sparew),r=(t=a*S.sparew2+(S.sparew2-1-n))<<2):2==S.rotation?r=S.sparew*S.spareh*4-4-r:3==S.rotation&&(a=t%S.sparew,n=Math.floor(t/S.sparew),r=(t=(S.sparew2-1-a)*S.sparew2+n)<<2)),S.graymode?(S.lowcolor&&(e<<=4),S.spare.data[r]=S.spare.data[r+1]=S.spare.data[r+2]=e):(S.spare.data[r]=224&e,S.spare.data[r+1]=(28&e)<<3,S.spare.data[r+2]=T((3&e)<<6))}function y(e,t){var a,n,r=t<<2;0<S.rotation&&(1==S.rotation?(a=t%S.sparew,n=Math.floor(t/S.sparew),r=(t=a*S.sparew2+(S.sparew2-1-n))<<2):2==S.rotation?r=S.sparew*S.spareh*4-4-r:3==S.rotation&&(a=t%S.sparew,n=Math.floor(t/S.sparew),r=(t=(S.sparew2-1-a)*S.sparew2+n)<<2)),S.spare.data[r]=e>>8&248,S.spare.data[r+1]=e>>3&252,S.spare.data[r+2]=(31&e)<<3}function b(e,t,a){if(S.graymode){var n=t<<2;for(S.lowcolor&&(e<<=4);0<=--a;)S.spare.data[n]=S.spare.data[n+1]=S.spare.data[n+2]=e,n+=4}else for(var n=t<<2,r=224&e,o=(28&e)<<3,i=T((3&e)<<6);0<=--a;)S.spare.data[n]=r,S.spare.data[n+1]=o,S.spare.data[n+2]=i,n+=4}function D(e,t,a){for(var n=t<<2,r=e>>8&248,o=e>>3&252,i=(31&e)<<3;0<=--a;)S.spare.data[n]=r,S.spare.data[n+1]=o,S.spare.data[n+2]=i,n+=4}function k(e){return 0==S.rotation||1==S.rotation?e:2==S.rotation?e-S.canvas.canvas.width:3==S.rotation?e-S.canvas.canvas.height:0}function x(e,t){return 0==S.rotation?t:1==S.rotation?t-S.canvas.canvas.width:2==S.rotation?t-S.canvas.canvas.height:3==S.rotation?t:0}function T(e){return 127<e?e+32:e}function K(){var e;1!=S.holding&&(0<S.focusmode?(e=2*S.focusmode,S.send(String.fromCharCode(3,1)+ShortToStr(Math.max(Math.min(S.ox,S.mx)-S.focusmode,0))+ShortToStr(Math.max(Math.min(S.oy,S.my)-S.focusmode,0))+ShortToStr(e+Math.abs(S.ox-S.mx))+ShortToStr(e+Math.abs(S.oy-S.my))),S.ox=S.mx,S.oy=S.my):S.send(String.fromCharCode(3,1,0,0,0,0)+ShortToStr(S.rwidth)+ShortToStr(S.rheight)))}S.canvasid=e,S.CanvasId=Q(e),S.scrolldiv=t,S.canvas=Q(e).getContext("2d"),S.protocol=2,S.state=0,S.acc=null,S.ScreenWidth=960,S.ScreenHeight=700,S.width=0,S.height=0,S.rwidth=0,S.rheight=0,S.bpp=2,S.useRLE=!0,S.showmouse=!0,S.buttonmask=0,S.localKeyMap=!0,S.spare=null,S.sparew=0,S.spareh=0,S.sparew2=0,S.spareh2=0,S.sparecache={}
|