blob: 07a14bdb05a890a72c2d8261aa6ebc1a1db934e4 [file] [log] [blame]
enikey970eb522008-12-25 07:46:04 +00001package com.tightvnc.decoder;
2
3import com.tightvnc.vncviewer.RfbInputStream;
4import 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}