diff options
Diffstat (limited to 'java/com/tigervnc/vncviewer/JavaPixelBuffer.java')
-rw-r--r-- | java/com/tigervnc/vncviewer/JavaPixelBuffer.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/java/com/tigervnc/vncviewer/JavaPixelBuffer.java b/java/com/tigervnc/vncviewer/JavaPixelBuffer.java index b639673c..89c42fe3 100644 --- a/java/com/tigervnc/vncviewer/JavaPixelBuffer.java +++ b/java/com/tigervnc/vncviewer/JavaPixelBuffer.java @@ -21,7 +21,7 @@ package com.tigervnc.vncviewer; import java.awt.*; import java.awt.image.*; -import java.nio.ByteOrder; +import java.nio.*; import com.tigervnc.rfb.*; @@ -31,6 +31,22 @@ public class JavaPixelBuffer extends PlatformPixelBuffer public JavaPixelBuffer(int w, int h) { super(getPreferredPF(), w, h, getPreferredPF().getColorModel().createCompatibleWritableRaster(w,h)); + image = new BufferedImage(getPreferredPF().getColorModel(), + getBufferRW(new Rect(0, 0, w, h)), true, null); + } + + public synchronized void fillRect(Rect r, byte[] pix) + { + ColorModel cm = format.getColorModel(); + int pixel = + ByteBuffer.wrap(pix).order(format.getByteOrder()).asIntBuffer().get(0); + Color c = new Color(cm.getRGB(pixel)); + Graphics2D g2 = ((BufferedImage)image).createGraphics(); + g2.setColor(c); + g2.fillRect(r.tl.x, r.tl.y, r.width(), r.height()); + g2.dispose(); + + commitBufferRW(r); } private static PixelFormat getPreferredPF() |