From: enikey Date: Fri, 19 Dec 2008 05:14:15 +0000 (+0000) Subject: [Developement] Added update() method to RawDecoder class. This method must be called... X-Git-Tag: v0.0.90~271 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=663025d68eef73269749de134e147f7e2a6e3ae7;p=tigervnc.git [Developement] Added update() method to RawDecoder class. This method must be called when framebuffer is resized or BPP is changed. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3413 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/java/src/com/tightvnc/decoder/RawDecoder.java b/java/src/com/tightvnc/decoder/RawDecoder.java index 8272d3b4..c1b2ca1e 100644 --- a/java/src/com/tightvnc/decoder/RawDecoder.java +++ b/java/src/com/tightvnc/decoder/RawDecoder.java @@ -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 //