Mercurial > hg > Applications > TreeVNC
view src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java @ 190:6aa1c0f4ab2e
fix readSendData.
author | oc |
---|---|
date | Wed, 25 Jun 2014 19:19:17 +0900 |
parents | f381159e38f3 |
children | d9d234715853 |
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.isRoot()) { 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(); } } }