blob: c3f1c8cbae6d3c2daa6446f68874c7d00eda0ed0 [file] [log] [blame]
package com.tigervnc.decoder;
import com.tigervnc.vncviewer.RfbInputStream;
import java.awt.Graphics;
import java.io.IOException;
//
// Class that used for decoding CopyRect encoded data.
//
public class CopyRectDecoder extends RawDecoder {
final static int EncodingCopyRect = 1;
public CopyRectDecoder(Graphics g, RfbInputStream is) {
super(g, is);
}
public CopyRectDecoder(Graphics g, RfbInputStream is, int frameBufferW,
int frameBufferH) {
super(g, is, frameBufferW, frameBufferH);
}
//
// Override handleRect method handle CopyRect
//
public void handleRect(int x, int y, int w, int h) throws IOException {
//
// Write encoding ID to record output stream
//
if (dos != null) {
dos.writeInt(CopyRectDecoder.EncodingCopyRect);
}
int copyRectSrcX = rfbis.readU16();
int copyRectSrcY = rfbis.readU16();
// If the session is being recorded:
if (dos != null) {
dos.writeShort(copyRectSrcX);
dos.writeShort(copyRectSrcY);
}
graphics.copyArea(copyRectSrcX, copyRectSrcY, w, h,
x - copyRectSrcX, y - copyRectSrcY);
}
}