aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/tightvnc
diff options
context:
space:
mode:
authorenikey <enikey@3789f03b-4d11-0410-bbf8-ca57d06f2519>2008-12-19 08:04:11 +0000
committerenikey <enikey@3789f03b-4d11-0410-bbf8-ca57d06f2519>2008-12-19 08:04:11 +0000
commita909a906d383ece072b488549eb11531da858fd1 (patch)
tree821c212af01501c7c1a0068039e8fcb3eeae366e /java/src/com/tightvnc
parentf7160bdb39a385925564bb7862e92698eb7059bc (diff)
downloadtigervnc-a909a906d383ece072b488549eb11531da858fd1.tar.gz
tigervnc-a909a906d383ece072b488549eb11531da858fd1.zip
[Developement] Added helper methods that decodes data in tight encoding (mono data and gradient data) to tight decoder class.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3432 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/src/com/tightvnc')
-rw-r--r--java/src/com/tightvnc/decoder/TightDecoder.java90
1 files changed, 90 insertions, 0 deletions
diff --git a/java/src/com/tightvnc/decoder/TightDecoder.java b/java/src/com/tightvnc/decoder/TightDecoder.java
index 94a82d38..476dac67 100644
--- a/java/src/com/tightvnc/decoder/TightDecoder.java
+++ b/java/src/com/tightvnc/decoder/TightDecoder.java
@@ -64,6 +64,96 @@ public class TightDecoder extends RawDecoder {
}
//
+ // Decode 1bpp-encoded bi-color rectangle (8-bit and 24-bit versions).
+ //
+
+ private void decodeMonoData(int x, int y, int w, int h, byte[] src, byte[] palette) {
+
+ int dx, dy, n;
+ int i = y * framebufferWidth + x;
+ int rowBytes = (w + 7) / 8;
+ byte b;
+
+ for (dy = 0; dy < h; dy++) {
+ for (dx = 0; dx < w / 8; dx++) {
+ b = src[dy*rowBytes+dx];
+ for (n = 7; n >= 0; n--)
+ pixels8[i++] = palette[b >> n & 1];
+ }
+ for (n = 7; n >= 8 - w % 8; n--) {
+ pixels8[i++] = palette[src[dy*rowBytes+dx] >> n & 1];
+ }
+ i += (framebufferWidth - w);
+ }
+ }
+
+ private void decodeMonoData(int x, int y, int w, int h, byte[] src, int[] palette) {
+
+ int dx, dy, n;
+ int i = y * framebufferWidth + x;
+ int rowBytes = (w + 7) / 8;
+ byte b;
+
+ for (dy = 0; dy < h; dy++) {
+ for (dx = 0; dx < w / 8; dx++) {
+ b = src[dy*rowBytes+dx];
+ for (n = 7; n >= 0; n--)
+ pixels24[i++] = palette[b >> n & 1];
+ }
+ for (n = 7; n >= 8 - w % 8; n--) {
+ pixels24[i++] = palette[src[dy*rowBytes+dx] >> n & 1];
+ }
+ i += (framebufferWidth - w);
+ }
+ }
+
+ //
+ // Decode data processed with the "Gradient" filter.
+ //
+
+ private void decodeGradientData (int x, int y, int w, int h, byte[] buf) {
+
+ int dx, dy, c;
+ byte[] prevRow = new byte[w * 3];
+ byte[] thisRow = new byte[w * 3];
+ byte[] pix = new byte[3];
+ int[] est = new int[3];
+
+ int offset = y * framebufferWidth + x;
+
+ for (dy = 0; dy < h; dy++) {
+
+ /* First pixel in a row */
+ for (c = 0; c < 3; c++) {
+ pix[c] = (byte)(prevRow[c] + buf[dy * w * 3 + c]);
+ thisRow[c] = pix[c];
+ }
+ pixels24[offset++] =
+ (pix[0] & 0xFF) << 16 | (pix[1] & 0xFF) << 8 | (pix[2] & 0xFF);
+
+ /* Remaining pixels of a row */
+ for (dx = 1; dx < w; dx++) {
+ for (c = 0; c < 3; c++) {
+ est[c] = ((prevRow[dx * 3 + c] & 0xFF) + (pix[c] & 0xFF) -
+ (prevRow[(dx-1) * 3 + c] & 0xFF));
+ if (est[c] > 0xFF) {
+ est[c] = 0xFF;
+ } else if (est[c] < 0x00) {
+ est[c] = 0x00;
+ }
+ pix[c] = (byte)(est[c] + buf[(dy * w + dx) * 3 + c]);
+ thisRow[dx * 3 + c] = pix[c];
+ }
+ pixels24[offset++] =
+ (pix[0] & 0xFF) << 16 | (pix[1] & 0xFF) << 8 | (pix[2] & 0xFF);
+ }
+
+ System.arraycopy(thisRow, 0, prevRow, 0, w * 3);
+ offset += (framebufferWidth - w);
+ }
+ }
+
+ //
// Private members
//