Mercurial > hg > Applications > tvnjviewer
changeset 10:ba82199e3b70
put AliceVNCMessage EncodingType.CURSOR_POS
author | YU |
---|---|
date | Tue, 23 Sep 2014 16:20:03 +0900 |
parents | 3c0f262384dc |
children | f9e319a08111 |
files | src/main/java/com/glavsoft/rfb/encoding/decoder/RichCursorDecoder.java |
diffstat | 1 files changed, 37 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/RichCursorDecoder.java Tue Sep 23 16:15:59 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/RichCursorDecoder.java Tue Sep 23 16:20:03 2014 +0900 @@ -24,6 +24,8 @@ package com.glavsoft.rfb.encoding.decoder; +import alice.datasegment.DataSegment; + import com.glavsoft.drawing.Renderer; import com.glavsoft.exceptions.TransportException; import com.glavsoft.transport.Reader; @@ -48,8 +50,8 @@ if (0 == length) return; byte[] buffer = ByteBuffer.getInstance().getBuffer(length); - reader.readBytes(buffer, 0, length); - + reader.readBytes(buffer, 0, length); + StringBuilder sb = new StringBuilder(" "); for (int i=0; i<length; ++i) { sb.append(Integer.toHexString(buffer[i]&0xff)).append(" "); @@ -58,6 +60,12 @@ byte[] bitmask = new byte[scanLine * rect.height]; reader.readBytes(bitmask, 0, bitmask.length); + AliceVNCMessage message = new AliceVNCMessage(); + message.setRectangle(rect); + message.buf = buffer; + message.bitmask = bitmask; + DataSegment.getLocal().put("aliceVNCMessage", message); + sb = new StringBuilder(" "); for (int i=0; i<bitmask.length; ++i) { sb.append(Integer.toHexString(bitmask[i]&0xff)).append(" "); @@ -78,4 +86,31 @@ return (aByte & 1 << 7 - index) > 0; } + public void decode(Renderer renderer, AliceVNCMessage message) + throws TransportException { + FramebufferUpdateRectangle rect = message.getFramebufferUpdateRectangle(); + int bytesPerPixel = renderer.getBytesPerPixel(); + int length = rect.width * rect.height * bytesPerPixel; + if (0 == length) + return; + byte[] buffer = message.buf; + byte[] bitmask = message.bitmask; + + StringBuilder sb = new StringBuilder(" "); + int scanLine = (int) Math.floor((rect.width + 7) / 8); + + for (int i=0; i<bitmask.length; ++i) { + sb.append(Integer.toHexString(bitmask[i]&0xff)).append(" "); + } + int[] cursorPixels = new int[rect.width * rect.height]; + for (int y = 0; y < rect.height; ++y) { + for (int x = 0; x < rect.width; ++x) { + int offset = y * rect.width + x; + cursorPixels[offset] = isBitSet(bitmask[y * scanLine + x / 8], x % 8) ? + 0xFF000000 | renderer.getPixelColor(buffer, offset * bytesPerPixel) : + 0; // transparent + } + } + renderer.createCursor(cursorPixels, rect); + } }