blob: c3f1c8cbae6d3c2daa6446f68874c7d00eda0ed0 [file] [log] [blame]
Adam Tkacf53e62a2009-03-13 13:20:26 +00001package com.tigervnc.decoder;
enikey970eb522008-12-25 07:46:04 +00002
Adam Tkacf53e62a2009-03-13 13:20:26 +00003import com.tigervnc.vncviewer.RfbInputStream;
enikey970eb522008-12-25 07:46:04 +00004import java.awt.Graphics;
5import java.io.IOException;
6
7//
8// Class that used for decoding CopyRect encoded data.
9//
10
11public 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
enikey32b421b2008-12-25 08:03:49 +000038 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);
enikey970eb522008-12-25 07:46:04 +000049 }
50}