Mercurial > hg > Applications > TreeVNC
view src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java @ 500:6609174beafe
fix subencoding
author | oshiro |
---|---|
date | Sun, 17 Feb 2019 17:55:25 +0900 |
parents | 8d95d64c33bf |
children | 1646be890954 |
line wrap: on
line source
package com.glavsoft.rfb.encoding.decoder; import java.io.UnsupportedEncodingException; import jp.ac.u_ryukyu.treevnc.TreeRFBProto; import com.glavsoft.drawing.Renderer; import com.glavsoft.exceptions.TransportException; import com.glavsoft.rfb.encoding.EncodingType; import com.glavsoft.transport.Reader; public class ZRLEESender extends Decoder { private TreeRFBProto rfb; public ZRLEESender(TreeRFBProto rfb) { this.rfb = rfb; } public ZRLEESender() { } @Override public void decode(Reader reader, Renderer renderer, FramebufferUpdateRectangle rect) throws TransportException, UnsupportedEncodingException { // TreeVNC handling int dataLen = getZrleLength(rect, reader); reader.reset(); if (rfb.hasViewer()) { ZRLEDecoder decoder = new ZRLEDecoder(); if (rect.getEncodingType() == EncodingType.ZRLE) { // ReadSendData convert ZRLE to ZRLEE // unzipped data in the bytes byte[] bytes = new byte[rect.width * rect.height * renderer.getBytesPerPixel()]; rfb.readSendData(dataLen, reader, bytes, rect); decoder.decode1(renderer, rect, bytes, 0, rfb); return; } else { // no reencoding is required // readSend does not peform unzip, do the fullrecoding rfb.readSendData(dataLen, reader, null, rect); reader.reset(); if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { reader.skip(24); } else { reader.skip(16); } decoder.decode(reader, renderer, rect); return; } } byte[] bytes = new byte[dataLen]; rfb.readSendData(dataLen, reader, bytes, rect); } private int getZrleLength(FramebufferUpdateRectangle rect, Reader reader) throws TransportException { int zrleLength = 0; if (rect.getEncodingType() == EncodingType.ZRLE || rect.getEncodingType() == EncodingType.ZRLEE || rect.getEncodingType() == EncodingType.ZLIB || rect.getEncodingType() == EncodingType.CHECK_DELAY) { zrleLength = reader.readInt32(); } if (rect.getEncodingType() == EncodingType.CHECK_DELAY) { // plus time byte return zrleLength + 20 + 8; } return zrleLength + 20; } }