-
Notifications
You must be signed in to change notification settings - Fork 1
/
SendScreen.java
42 lines (39 loc) · 1.09 KB
/
SendScreen.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
public class SendScreen extends Thread {
Socket socket = null;
Robot robot = null;
Rectangle rectangle = null;
boolean continueLoop = true;
OutputStream oos = null;
public SendScreen(Socket socket, Robot robot, Rectangle rect) {
this.socket = socket;
this.robot = robot;
rectangle = rect;
start();
}
public void run() {
try {
oos = socket.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
while (continueLoop) {
BufferedImage image = robot.createScreenCapture(rectangle);
try {
ImageIO.write(image, "jpeg", oos);
} catch (IOException e) {
e.printStackTrace();
}
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}