From: enikey Date: Fri, 19 Dec 2008 05:28:12 +0000 (+0000) Subject: [Developement] Added handleRect method to RawDecoder class. X-Git-Tag: v0.0.90~270 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4f92da4998bc3b290c1e91e4c4d69573b6da10fe;p=tigervnc.git [Developement] Added handleRect method to RawDecoder class. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3414 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/java/src/com/tightvnc/decoder/RawDecoder.java b/java/src/com/tightvnc/decoder/RawDecoder.java index c1b2ca1e..507ed816 100644 --- a/java/src/com/tightvnc/decoder/RawDecoder.java +++ b/java/src/com/tightvnc/decoder/RawDecoder.java @@ -2,6 +2,7 @@ package com.tightvnc.decoder; import com.tightvnc.vncviewer.RecordInterface; import com.tightvnc.vncviewer.RfbInputStream; +import java.io.IOException; import java.awt.Graphics; import java.awt.Image; import java.awt.image.ColorModel; @@ -59,9 +60,59 @@ public class RawDecoder { framebufferHeight = h; } + // + // Decodes Raw Pixels data and draw it into graphics + // + + public void handleRect(int x, int y, int w, int h) throws IOException, Exception { + if (bytesPerPixel == 1) { + for (int dy = y; dy < y + h; dy++) { + if (pixels8 != null) { + rfbis.readFully(pixels8, dy * framebufferWidth + x, w); + } + if (rec.canWrite()) { + rec.write(pixels8, dy * framebufferWidth + x, w); + } + } + } else { + byte[] buf = new byte[w * 4]; + int i, offset; + for (int dy = y; dy < y + h; dy++) { + rfbis.readFully(buf); + // + // Save decoded data to RecordInterface + // + if (rec.canWrite()) { + rec.write(buf); + } + offset = dy * framebufferWidth + x; + if (pixels24 != null) { + for (i = 0; i < w; i++) { + pixels24[offset + i] = + (buf[i * 4 + 2] & 0xFF) << 16 | + (buf[i * 4 + 1] & 0xFF) << 8 | + (buf[i * 4] & 0xFF); + } //for + } // if + } // for + } // else + handleUpdatedPixels(x, y, w, h); + } // void + + // + // Display newly updated area of pixels. + // + protected void handleUpdatedPixels(int x, int y, int w, int h) { + // Draw updated pixels of the off-screen image. + pixelsSource.newPixels(x, y, w, h); + graphics.setClip(x, y, w, h); + graphics.drawImage(rawPixelsImage, 0, 0, null); + graphics.setClip(0, 0, framebufferWidth, framebufferHeight); + } + // // Updates pixels data. - // This methods must be called when framebuffer is resized + // This method must be called when framebuffer is resized // or BPP is changed. //