Mercurial > hg > Applications > TreeVNC
view src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java @ 380:aef5cbdd84ab
Fix compare SerialNumber flag
author | innparusu |
---|---|
date | Wed, 02 Sep 2015 17:33:06 +0900 |
parents | 60abae693629 |
children | 47c018aed50e |
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); byte[] bytes = new byte[rect.width * rect.height * renderer.getBytesPerPixel()]; // byte[] bytes = new byte[renderer.getWidth() * renderer.getHeight() * renderer.getBytesPerPixel()]; reader.reset(); if (rfb.hasViewer()) { ZRLEDecoder decoder = new ZRLEDecoder(); if (rfb.isTreeManager()) { rfb.readSendData(dataLen, reader, bytes, rect); decoder.decode1(renderer, rect, bytes, 0); return; } else if (!rfb.getCuiVersion()) { rfb.readSendData(dataLen, reader, null, rect); reader.reset(); reader.skip(16); decoder.decode(reader, renderer, rect); return; } } 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) { zrleLength = reader.readInt32(); } return zrleLength + 20; } }