diff --git a/include/jsunzip.js b/include/jsunzip.js index e83d9bac..1d2957bd 100755 --- a/include/jsunzip.js +++ b/include/jsunzip.js @@ -355,7 +355,7 @@ this.read_bits = function(d, num, base) return base; var val = 0; - while (d.bitcount < num) { + while (d.bitcount < 24) { d.tag = d.tag | (d.source[d.sourceIndex++] & 0xff) << d.bitcount; d.bitcount += 8; } @@ -368,7 +368,7 @@ this.read_bits = function(d, num, base) /* given a data stream and a tree, decode a symbol */ this.decode_symbol = function(d, t) { - while (d.bitcount < 10) { + while (d.bitcount < 16) { d.tag = d.tag | (d.source[d.sourceIndex++] & 0xff) << d.bitcount; d.bitcount += 8; } diff --git a/include/rfb.js b/include/rfb.js index 0f96a9a0..3ccd73a4 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -1307,16 +1307,6 @@ encHandlers.TIGHT = function display_tight() { throw("Invalid data in zlib stream"); Util.Warn("Decompressed " + data.length + " to " + uncompressed.data.length + " checksums " + checksum(data) + ":" + checksum(uncompressed.data)); - - /* - var i; - var uncompressed2 = zip_inflate(data); - for (i=0;i= 0; b--) { + var dp = (y*FBU.width + x*8 + 7-b) * 3; + var sp = (data[y*w + x] >> b & 1) * 3; + dest[dp ] = FBU.palette[sp ]; + dest[dp+1] = FBU.palette[sp+1]; + dest[dp+2] = FBU.palette[sp+2]; + } + for (b = 7; b >= 8 - FBU.width % 8; b--) { + var dp = (y*FBU.width + x*8 + 7-b) * 3; + var sp = (data[y*w + x] >> b & 1) * 3; + dest[dp ] = FBU.palette[sp ]; + dest[dp+1] = FBU.palette[sp+1]; + dest[dp+2] = FBU.palette[sp+2]; + } + } + } + } else { + for (y = 0; y < FBU.height; y++) { + for (x = 0; x < FBU.width; x++) { + var dp = (y*FBU.width + x) * 3; + var sp = data[y*FBU.width + x] * 3; + dest[dp ] = FBU.palette[sp ]; + dest[dp+1] = FBU.palette[sp+1]; + dest[dp+2] = FBU.palette[sp+2]; + } + } + } + + FBU.imgQ.push({ + 'type': 'rgb', + 'img': {'complete': true, 'data': dest}, + 'x': FBU.x, + 'y': FBU.y, + 'width': FBU.width, + 'height': FBU.height}); return true; } @@ -1368,8 +1398,6 @@ encHandlers.TIGHT = function display_tight() { FBU.bytes = 1 + clength[0] + clength[1]; // ctl + clength size + zlib-data if (ws.rQwait("TIGHT " + cmode, FBU.bytes)) { return false; } - if (streamId != 0) throw ("Wrong stream"); - ws.rQshiftBytes(1 + clength[0]); // ctl + clength if (raw) data = ws.rQshiftBytes(clength[1]);