diff src/main/java/com/glavsoft/rfb/encoding/decoder/ZlibDecoder.java @ 3:e7ce2b2ffed8

add and modify files
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Tue, 24 Jul 2012 15:46:36 +0900
parents 4689cc86d6cb
children 433c79184c05
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZlibDecoder.java	Mon Jul 09 18:47:33 2012 +0900
+++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZlibDecoder.java	Tue Jul 24 15:46:36 2012 +0900
@@ -26,6 +26,7 @@
 
 import com.glavsoft.drawing.Renderer;
 import com.glavsoft.exceptions.TransportException;
+import com.glavsoft.rfb.encoding.EncodingType;
 import com.glavsoft.transport.Reader;
 
 import java.io.ByteArrayInputStream;
@@ -41,20 +42,21 @@
 		int zippedLength = (int) reader.readUInt32();
 		if (0 == zippedLength) return;
 		int length = rect.width * rect.height * renderer.getBytesPerPixel();
-		byte[] bytes = unzip(reader, zippedLength, length);
+		byte[] bytes = unzip(reader, zippedLength, length, rect.getEncodingType());
 		Reader unzippedReader =
 			new Reader(
 					new ByteArrayInputStream(bytes, zippedLength, length));
 		RawDecoder.getInstance().decode(unzippedReader, renderer, rect);
 	}
 
-	protected byte[] unzip(Reader reader, int zippedLength, int length)
+	protected byte[] unzip(Reader reader, int zippedLength, int length,EncodingType encodingType)
 			throws TransportException {
 		byte [] bytes = ByteBuffer.getInstance().getBuffer(zippedLength + length);
 		reader.readBytes(bytes, 0, zippedLength);
-		if (null == decoder) {
+		if (null == decoder || encodingType == EncodingType.ZRLEE) {
+		//if (null == decoder) {
 			decoder = new Inflater();
-		}
+		} 
 		decoder.setInput(bytes, 0, zippedLength);
 		try {
 			decoder.inflate(bytes, zippedLength, length);