Mercurial > hg > Applications > TreeVNC
view src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java @ 204:d9d234715853
TreeManager for each interface
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 27 Jun 2014 21:37:20 +0900 |
parents | 6aa1c0f4ab2e |
children | b31903e5b02d |
line wrap: on
line source
package com.glavsoft.rfb.encoding.decoder; import jp.ac.u_ryukyu.treevnc.MyRfbProto; 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 MyRfbProto rfb; public ZRLEESender(MyRfbProto rfb) { this.rfb = rfb; } public ZRLEESender() { } @Override public void decode(Reader reader, Renderer renderer, FramebufferUpdateRectangle rect) throws TransportException { // TreeVNC handling int dataLen = getZrleLength(rect, reader); byte[] bytes = new byte[rect.width * rect.height * renderer.getBytesPerPixel()]; reader.reset(); if (rfb.hasViewer()) { ZRLEDecoder decoder = new ZRLEDecoder(); if (rfb.isTreeManager()) { rfb.readSendData(dataLen, reader, bytes); decoder.decode1(renderer, rect, bytes, 0); return; } else if (!rfb.getCuiVersion()) { rfb.readSendData(dataLen, reader, null); reader.reset(); reader.skip(16); decoder.decode(reader, renderer, rect); return; } } rfb.readSendData(dataLen, reader, bytes); } 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) { zrleLength = reader.readInt32(); } return zrleLength + 20; } public void readCheckDelay(Reader reader) { try { reader.reset(); rfb.readCheckDelay(reader); } catch (TransportException e) { e.printStackTrace(); } } }