annotate src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java @ 21:966878ff1227

not appear NEW TightVNC Connection window if first argument equal "localhost"
author sugi
date Thu, 06 Nov 2014 19:32:15 +0900
parents 419ac2f759d5
children f1dc728ffe87
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
daa24f8a557b TightVNC original
YU
parents:
diff changeset
1 // Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC.
daa24f8a557b TightVNC original
YU
parents:
diff changeset
2 // All rights reserved.
daa24f8a557b TightVNC original
YU
parents:
diff changeset
3 //
daa24f8a557b TightVNC original
YU
parents:
diff changeset
4 //-------------------------------------------------------------------------
daa24f8a557b TightVNC original
YU
parents:
diff changeset
5 // This file is part of the TightVNC software. Please visit our Web site:
daa24f8a557b TightVNC original
YU
parents:
diff changeset
6 //
daa24f8a557b TightVNC original
YU
parents:
diff changeset
7 // http://www.tightvnc.com/
daa24f8a557b TightVNC original
YU
parents:
diff changeset
8 //
daa24f8a557b TightVNC original
YU
parents:
diff changeset
9 // This program is free software; you can redistribute it and/or modify
daa24f8a557b TightVNC original
YU
parents:
diff changeset
10 // it under the terms of the GNU General Public License as published by
daa24f8a557b TightVNC original
YU
parents:
diff changeset
11 // the Free Software Foundation; either version 2 of the License, or
daa24f8a557b TightVNC original
YU
parents:
diff changeset
12 // (at your option) any later version.
daa24f8a557b TightVNC original
YU
parents:
diff changeset
13 //
daa24f8a557b TightVNC original
YU
parents:
diff changeset
14 // This program is distributed in the hope that it will be useful,
daa24f8a557b TightVNC original
YU
parents:
diff changeset
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
daa24f8a557b TightVNC original
YU
parents:
diff changeset
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
daa24f8a557b TightVNC original
YU
parents:
diff changeset
17 // GNU General Public License for more details.
daa24f8a557b TightVNC original
YU
parents:
diff changeset
18 //
daa24f8a557b TightVNC original
YU
parents:
diff changeset
19 // You should have received a copy of the GNU General Public License along
daa24f8a557b TightVNC original
YU
parents:
diff changeset
20 // with this program; if not, write to the Free Software Foundation, Inc.,
daa24f8a557b TightVNC original
YU
parents:
diff changeset
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
daa24f8a557b TightVNC original
YU
parents:
diff changeset
22 //-------------------------------------------------------------------------
daa24f8a557b TightVNC original
YU
parents:
diff changeset
23 //
daa24f8a557b TightVNC original
YU
parents:
diff changeset
24
daa24f8a557b TightVNC original
YU
parents:
diff changeset
25 package com.glavsoft.rfb.encoding.decoder;
daa24f8a557b TightVNC original
YU
parents:
diff changeset
26
20
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
27 import java.util.zip.DataFormatException;
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
28 import java.util.zip.Inflater;
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
29
5
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
30 import alice.datasegment.DataSegment;
18
80b4d7efba08 change arguments for new PUT API
sugi
parents: 17
diff changeset
31 import alice.datasegment.ReceiveData;
5
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
32
0
daa24f8a557b TightVNC original
YU
parents:
diff changeset
33 import com.glavsoft.drawing.Renderer;
daa24f8a557b TightVNC original
YU
parents:
diff changeset
34 import com.glavsoft.exceptions.TransportException;
20
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
35 import com.glavsoft.rfb.encoding.EncodingType;
0
daa24f8a557b TightVNC original
YU
parents:
diff changeset
36 import com.glavsoft.transport.Reader;
daa24f8a557b TightVNC original
YU
parents:
diff changeset
37
daa24f8a557b TightVNC original
YU
parents:
diff changeset
38 public class ZRLEDecoder extends ZlibDecoder {
5
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
39 private static final int MAX_TILE_SIZE = 64;
0
daa24f8a557b TightVNC original
YU
parents:
diff changeset
40 private int[] decodedBitmap;
daa24f8a557b TightVNC original
YU
parents:
diff changeset
41 private int[] palette;
daa24f8a557b TightVNC original
YU
parents:
diff changeset
42
daa24f8a557b TightVNC original
YU
parents:
diff changeset
43 @Override
5
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
44 public void decode(Reader reader, Renderer renderer,
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
45 FramebufferUpdateRectangle rect) throws TransportException {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
46 int zippedLength = (int) reader.readUInt32();
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
47 if (0 == zippedLength) return;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
48 int length = rect.width * rect.height * renderer.getBytesPerPixel();
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
49 byte[] bytes = unzip(reader, zippedLength, length);
17
61d95bdc2bdb change Alice PUT API new Version
sugi
parents: 12
diff changeset
50
7
9abf7f305bac refactor
YU
parents: 5
diff changeset
51 AliceVNCMessage message = new AliceVNCMessage();
9abf7f305bac refactor
YU
parents: 5
diff changeset
52 message.setRectangle(rect);
20
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
53 message.encodingTypeId = EncodingType.ZRLEE.getId();
18
80b4d7efba08 change arguments for new PUT API
sugi
parents: 17
diff changeset
54
19
6886a2e890cc separate pixelByteArray from AliceVNCMessage
sugi
parents: 18
diff changeset
55 ReceiveData rData = new ReceiveData(bytes.clone(), false, false);
6886a2e890cc separate pixelByteArray from AliceVNCMessage
sugi
parents: 18
diff changeset
56 DataSegment.getLocal().put("pixelByteArray", rData, null);
6886a2e890cc separate pixelByteArray from AliceVNCMessage
sugi
parents: 18
diff changeset
57 rData = new ReceiveData(message, false, false);
18
80b4d7efba08 change arguments for new PUT API
sugi
parents: 17
diff changeset
58 DataSegment.getLocal().put("aliceVNCMessage", rData, null);
20
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
59 decode(renderer, rect, bytes, 0);
7
9abf7f305bac refactor
YU
parents: 5
diff changeset
60 }
9abf7f305bac refactor
YU
parents: 5
diff changeset
61
17
61d95bdc2bdb change Alice PUT API new Version
sugi
parents: 12
diff changeset
62 public void decode(Renderer renderer,
7
9abf7f305bac refactor
YU
parents: 5
diff changeset
63 FramebufferUpdateRectangle rect, byte[] bytes, int offset)
9abf7f305bac refactor
YU
parents: 5
diff changeset
64 throws TransportException {
5
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
65 int maxX = rect.x + rect.width;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
66 int maxY = rect.y + rect.height;
0
daa24f8a557b TightVNC original
YU
parents:
diff changeset
67 if (null == palette) {
daa24f8a557b TightVNC original
YU
parents:
diff changeset
68 palette = new int [128];
daa24f8a557b TightVNC original
YU
parents:
diff changeset
69 }
daa24f8a557b TightVNC original
YU
parents:
diff changeset
70 if (null == decodedBitmap) {
daa24f8a557b TightVNC original
YU
parents:
diff changeset
71 decodedBitmap = new int[MAX_TILE_SIZE * MAX_TILE_SIZE];
daa24f8a557b TightVNC original
YU
parents:
diff changeset
72 }
5
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
73 for (int tileY = rect.y; tileY < maxY; tileY += MAX_TILE_SIZE) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
74 int tileHeight = Math.min(maxY - tileY, MAX_TILE_SIZE);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
75
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
76 for (int tileX = rect.x; tileX < maxX; tileX += MAX_TILE_SIZE) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
77 int tileWidth = Math.min(maxX - tileX, MAX_TILE_SIZE);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
78 int subencoding = bytes[offset++] & 0x0ff;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
79 // 128 -plain RLE, 130-255 - Palette RLE
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
80 boolean isRle = (subencoding & 128) != 0;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
81 // 2 to 16 for raw packed palette data, 130 to 255 for Palette RLE (subencoding - 128)
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
82 int paletteSize = subencoding & 127;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
83 offset += readPalette(bytes, offset, renderer, paletteSize);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
84 if (1 == subencoding) { // A solid tile consisting of a single colour
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
85 renderer.fillRect(palette[0], tileX, tileY, tileWidth, tileHeight);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
86 continue;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
87 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
88 if (isRle) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
89 if (0 == paletteSize) { // subencoding == 128 (or paletteSize == 0) - Plain RLE
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
90 offset += decodePlainRle(bytes, offset, renderer, tileX, tileY, tileWidth, tileHeight);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
91 } else {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
92 offset += decodePaletteRle(bytes, offset, renderer, tileX, tileY, tileWidth, tileHeight);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
93 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
94 } else {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
95 if (0 == paletteSize) { // subencoding == 0 (or paletteSize == 0) - raw CPIXEL data
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
96 offset += decodeRaw(bytes, offset, renderer, tileX, tileY, tileWidth, tileHeight);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
97 } else {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
98 offset += decodePacked(bytes, offset, renderer, paletteSize, tileX, tileY, tileWidth, tileHeight);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
99 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
100 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
101 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
102 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
103 }
0
daa24f8a557b TightVNC original
YU
parents:
diff changeset
104
5
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
105 private int decodePlainRle(byte[] bytes, int offset, Renderer renderer,
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
106 int tileX, int tileY, int tileWidth, int tileHeight) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
107 int bytesPerCPixel = renderer.getBytesPerCPixel();
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
108 int decodedOffset = 0;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
109 int decodedEnd = tileWidth * tileHeight;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
110 int index = offset;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
111 while (decodedOffset < decodedEnd) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
112 int color = renderer.getCompactPixelColor(bytes, index);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
113 index += bytesPerCPixel;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
114 int rlength = 1;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
115 do {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
116 rlength += bytes[index] & 0x0ff;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
117 } while ((bytes[index++] & 0x0ff) == 255);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
118 assert rlength <= decodedEnd - decodedOffset;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
119 renderer.fillColorBitmapWithColor(decodedBitmap, decodedOffset, rlength, color);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
120 decodedOffset += rlength;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
121 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
122 renderer.drawColoredBitmap(decodedBitmap, tileX, tileY, tileWidth, tileHeight);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
123 return index - offset;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
124 }
0
daa24f8a557b TightVNC original
YU
parents:
diff changeset
125
5
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
126 private int decodePaletteRle(byte[] bytes, int offset, Renderer renderer,
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
127 int tileX, int tileY, int tileWidth, int tileHeight) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
128 int decodedOffset = 0;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
129 int decodedEnd = tileWidth * tileHeight;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
130 int index = offset;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
131 while (decodedOffset < decodedEnd) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
132 int colorIndex = bytes[index++];
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
133 int color = palette[colorIndex & 127];
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
134 int rlength = 1;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
135 if ((colorIndex & 128) != 0) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
136 do {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
137 rlength += bytes[index] & 0x0ff;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
138 } while (bytes[index++] == (byte) 255);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
139 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
140 assert rlength <= decodedEnd - decodedOffset;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
141 renderer.fillColorBitmapWithColor(decodedBitmap, decodedOffset, rlength, color);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
142 decodedOffset += rlength;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
143 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
144 renderer.drawColoredBitmap(decodedBitmap, tileX, tileY, tileWidth, tileHeight);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
145 return index - offset;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
146 }
0
daa24f8a557b TightVNC original
YU
parents:
diff changeset
147
5
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
148 private int decodePacked(byte[] bytes, int offset, Renderer renderer,
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
149 int paletteSize, int tileX, int tileY, int tileWidth, int tileHeight) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
150 int bitsPerPalletedPixel = paletteSize > 16 ? 8 : paletteSize > 4 ? 4
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
151 : paletteSize > 2 ? 2 : 1;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
152 int packedOffset = offset;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
153 int decodedOffset = 0;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
154 for (int i = 0; i < tileHeight; ++i) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
155 int decodedRowEnd = decodedOffset + tileWidth;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
156 int byteProcessed = 0;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
157 int bitsRemain = 0;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
158
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
159 while (decodedOffset < decodedRowEnd) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
160 if (bitsRemain == 0) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
161 byteProcessed = bytes[packedOffset++];
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
162 bitsRemain = 8;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
163 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
164 bitsRemain -= bitsPerPalletedPixel;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
165 int index = byteProcessed >> bitsRemain & (1 << bitsPerPalletedPixel) - 1 & 127;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
166 int color = palette[index];
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
167 renderer.fillColorBitmapWithColor(decodedBitmap, decodedOffset, 1, color);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
168 ++decodedOffset;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
169 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
170 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
171 renderer.drawColoredBitmap(decodedBitmap, tileX, tileY, tileWidth, tileHeight);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
172 return packedOffset - offset;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
173 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
174
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
175 private int decodeRaw(byte[] bytes, int offset, Renderer renderer,
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
176 int tileX, int tileY, int tileWidth, int tileHeight) throws TransportException {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
177 return renderer.drawCompactBytes(bytes, offset, tileX, tileY, tileWidth, tileHeight);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
178 }
0
daa24f8a557b TightVNC original
YU
parents:
diff changeset
179
5
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
180 private int readPalette(byte[] bytes, int offset, Renderer renderer, int paletteSize) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
181 final int bytesPerCPixel = renderer.getBytesPerCPixel();
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
182 for (int i=0; i<paletteSize; ++i) {
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
183 palette[i] = renderer.getCompactPixelColor(bytes, offset + i* bytesPerCPixel);
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
184 }
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
185 return paletteSize * bytesPerCPixel;
3a5b44b08540 add Decode Method
YU
parents: 0
diff changeset
186 }
20
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
187
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
188 @Override
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
189 protected byte[] unzip(Reader reader, int zippedLength, int length)
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
190 throws TransportException {
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
191 byte[] input = ByteBuffer.getInstance().getBuffer(zippedLength);
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
192 byte[] bytes = new byte[length];
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
193 reader.readBytes(input, 0, zippedLength);
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
194 if (null == decoder) {
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
195 decoder = new Inflater();
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
196 }
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
197 decoder.setInput(input, 0, zippedLength);
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
198 int position = 0;
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
199 try {
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
200 do {
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
201 int len = decoder.inflate(bytes, position, bytes.length - position);
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
202 if (len > 0) {
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
203 position += len;
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
204 }
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
205 } while (!decoder.needsInput());
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
206 } catch (DataFormatException e) {
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
207 throw new TransportException("cannot inflate Zlib data", e);
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
208 }
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
209 return bytes;
419ac2f759d5 copy unzip method from TreeVNC and improve
sugi
parents: 19
diff changeset
210 }
0
daa24f8a557b TightVNC original
YU
parents:
diff changeset
211 }