summaryrefslogtreecommitdiffstats
path: root/java/src/com/tigervnc/decoder/CoRREDecoder.java
diff options
context:
space:
mode:
authorAdam Tkac <atkac@redhat.com>2009-03-13 13:11:51 +0000
committerAdam Tkac <atkac@redhat.com>2009-03-13 13:11:51 +0000
commitd0e84634e0058af86d39f1609dff2089684247d7 (patch)
treec74c060f6cc64f5318f330e70861c2d7ce4e5b6f /java/src/com/tigervnc/decoder/CoRREDecoder.java
parentb184fc81d62fab3c2f909e8a15961ec0ca491b99 (diff)
downloadtigervnc-d0e84634e0058af86d39f1609dff2089684247d7.tar.gz
tigervnc-d0e84634e0058af86d39f1609dff2089684247d7.zip
Rename java/src/com/tightvnc to java/src/com/tigervnc.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3672 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/src/com/tigervnc/decoder/CoRREDecoder.java')
-rw-r--r--java/src/com/tigervnc/decoder/CoRREDecoder.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/java/src/com/tigervnc/decoder/CoRREDecoder.java b/java/src/com/tigervnc/decoder/CoRREDecoder.java
new file mode 100644
index 00000000..bc086686
--- /dev/null
+++ b/java/src/com/tigervnc/decoder/CoRREDecoder.java
@@ -0,0 +1,85 @@
+package com.tightvnc.decoder;
+
+import com.tightvnc.vncviewer.RfbInputStream;
+import java.awt.Graphics;
+import java.awt.Color;
+import java.io.IOException;
+
+//
+// Class that used for decoding CoRRE encoded data.
+//
+
+public class CoRREDecoder extends RawDecoder {
+
+ final static int EncodingCoRRE = 4;
+
+ public CoRREDecoder(Graphics g, RfbInputStream is) {
+ super(g, is);
+ }
+
+ public CoRREDecoder(Graphics g, RfbInputStream is, int frameBufferW,
+ int frameBufferH) {
+ super(g, is, frameBufferW, frameBufferH);
+ }
+
+ //
+ // Override handleRect method to decode CoRRE encoded data insted of
+ // raw pixel data.
+ //
+
+ public void handleRect(int x, int y, int w, int h) throws IOException {
+
+ //
+ // Write encoding ID to record output stream
+ //
+
+ if (dos != null) {
+ dos.writeInt(CoRREDecoder.EncodingCoRRE);
+ }
+
+ int nSubrects = rfbis.readU32();
+
+ byte[] bg_buf = new byte[bytesPerPixel];
+ rfbis.readFully(bg_buf);
+ Color pixel;
+ if (bytesPerPixel == 1) {
+ pixel = getColor256()[bg_buf[0] & 0xFF];
+ } else {
+ pixel = new Color(bg_buf[2] & 0xFF, bg_buf[1] & 0xFF, bg_buf[0] & 0xFF);
+ }
+ graphics.setColor(pixel);
+ graphics.fillRect(x, y, w, h);
+
+ byte[] buf = new byte[nSubrects * (bytesPerPixel + 4)];
+ rfbis.readFully(buf);
+
+ //
+ // Save decoded data to data output stream
+ //
+
+ if (dos != null) {
+ dos.writeInt(nSubrects);
+ dos.write(bg_buf);
+ dos.write(buf);
+ }
+
+ int sx, sy, sw, sh;
+ int i = 0;
+
+ for (int j = 0; j < nSubrects; j++) {
+ if (bytesPerPixel == 1) {
+ pixel = getColor256()[buf[i++] & 0xFF];
+ } else {
+ pixel = new Color(buf[i+2] & 0xFF, buf[i+1] & 0xFF, buf[i] & 0xFF);
+ i += 4;
+ }
+ sx = x + (buf[i++] & 0xFF);
+ sy = y + (buf[i++] & 0xFF);
+ sw = buf[i++] & 0xFF;
+ sh = buf[i++] & 0xFF;
+
+ graphics.setColor(pixel);
+ graphics.fillRect(sx, sy, sw, sh);
+ }
+ }
+}