Adam Tkac | f53e62a | 2009-03-13 13:20:26 +0000 | [diff] [blame] | 1 | package com.tigervnc.decoder; |
enikey | 970eb52 | 2008-12-25 07:46:04 +0000 | [diff] [blame] | 2 | |
Adam Tkac | f53e62a | 2009-03-13 13:20:26 +0000 | [diff] [blame] | 3 | import com.tigervnc.vncviewer.RfbInputStream; |
enikey | 970eb52 | 2008-12-25 07:46:04 +0000 | [diff] [blame] | 4 | import java.awt.Graphics; |
| 5 | import java.io.IOException; |
| 6 | |
| 7 | // |
| 8 | // Class that used for decoding CopyRect encoded data. |
| 9 | // |
| 10 | |
| 11 | public class CopyRectDecoder extends RawDecoder { |
| 12 | |
| 13 | final static int EncodingCopyRect = 1; |
| 14 | |
| 15 | public CopyRectDecoder(Graphics g, RfbInputStream is) { |
| 16 | super(g, is); |
| 17 | } |
| 18 | |
| 19 | public CopyRectDecoder(Graphics g, RfbInputStream is, int frameBufferW, |
| 20 | int frameBufferH) { |
| 21 | super(g, is, frameBufferW, frameBufferH); |
| 22 | } |
| 23 | |
| 24 | // |
| 25 | // Override handleRect method handle CopyRect |
| 26 | // |
| 27 | |
| 28 | public void handleRect(int x, int y, int w, int h) throws IOException { |
| 29 | |
| 30 | // |
| 31 | // Write encoding ID to record output stream |
| 32 | // |
| 33 | |
| 34 | if (dos != null) { |
| 35 | dos.writeInt(CopyRectDecoder.EncodingCopyRect); |
| 36 | } |
| 37 | |
enikey | 32b421b | 2008-12-25 08:03:49 +0000 | [diff] [blame] | 38 | int copyRectSrcX = rfbis.readU16(); |
| 39 | int copyRectSrcY = rfbis.readU16(); |
| 40 | |
| 41 | // If the session is being recorded: |
| 42 | if (dos != null) { |
| 43 | dos.writeShort(copyRectSrcX); |
| 44 | dos.writeShort(copyRectSrcY); |
| 45 | } |
| 46 | |
| 47 | graphics.copyArea(copyRectSrcX, copyRectSrcY, w, h, |
| 48 | x - copyRectSrcX, y - copyRectSrcY); |
enikey | 970eb52 | 2008-12-25 07:46:04 +0000 | [diff] [blame] | 49 | } |
| 50 | } |