]> source.dussan.org Git - tigervnc.git/commitdiff
[Developement] Added update() method to RawDecoder class. This method must be called...
authorenikey <enikey@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Fri, 19 Dec 2008 05:14:15 +0000 (05:14 +0000)
committerenikey <enikey@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Fri, 19 Dec 2008 05:14:15 +0000 (05:14 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3413 3789f03b-4d11-0410-bbf8-ca57d06f2519

java/src/com/tightvnc/decoder/RawDecoder.java

index 8272d3b4b8d6dd7d1cf840d05d88a0c04f72a480..c1b2ca1ebc65c6bba475c3b5637d16071ad8eb9e 100644 (file)
@@ -8,6 +8,7 @@ import java.awt.image.ColorModel;
 import java.awt.image.DirectColorModel;
 import java.awt.image.MemoryImageSource;
 import java.awt.Color;
+import java.awt.Toolkit;
 
 //
 // This is base decoder class.
@@ -58,6 +59,33 @@ public class RawDecoder {
     framebufferHeight = h;
   }
 
+  //
+  // Updates pixels data.
+  // This methods must be called when framebuffer is resized
+  // or BPP is changed.
+  //
+
+  public void update() {
+    // Images with raw pixels should be re-allocated on every change
+    // of geometry or pixel format.
+    int fbWidth = framebufferWidth;
+    int fbHeight = framebufferHeight;
+
+    if (bytesPerPixel == 1) {
+      pixels24 = null;
+      pixels8 = new byte[fbWidth * fbHeight];
+      pixelsSource = new MemoryImageSource(fbWidth, fbHeight, getColorModel8(),
+                                           pixels8, 0, fbWidth);
+    } else {
+      pixels8 = null;
+      pixels24 = new int[fbWidth * fbHeight];
+      pixelsSource =
+        new MemoryImageSource(fbWidth, fbHeight, cm24, pixels24, 0, fbWidth);
+    }
+    pixelsSource.setAnimated(true);
+    rawPixelsImage = Toolkit.getDefaultToolkit().createImage(pixelsSource);
+  }
+
   //
   // Private static members access methdos
   //