【发布时间】:2018-05-14 14:38:09
【问题描述】:
我使用 java 找到了这个屏幕共享代码。这是接收屏幕的客户端。
客户端:
class ReceiveScreen extends Thread{
private ObjectInputStream cObjectInputStream = null;
private JPanel cPanel = null;
private boolean continueLoop = true;
InputStream oin = null;
Image image1 = null;
public ReceiveScreen(InputStream in,JPanel p){
oin = in;
cPanel = p;
start();
}
public void run(){
try{
//Read screenshots of the client and then draw them
while(continueLoop){
byte[] bytes = new byte[1024*1024];
int count = 0;
do{
count+=oin.read(bytes,count,bytes.length-count);
}while(!(count>4 && bytes[count-2]==(byte)-1 && bytes[count-1]==(byte)-39));
image1 = ImageIO.read(new ByteArrayInputStream(bytes));
image1 = image1.getScaledInstance(cPanel.getWidth(),cPanel.getHeight(),Image.SCALE_FAST);
//Draw the received screenshots
Graphics graphics = cPanel.getGraphics();
graphics.drawImage(image1, 0, 0, cPanel.getWidth(), cPanel.getHeight(), cPanel);
}
} catch(IOException ex) {
ex.printStackTrace();
}
}
}
谁能解释一下这个while条件有什么作用?
while(!(count>4 && 字节[count-2]==(byte)-1 && 字节[count-1]==(字节)-39));
查看Server side。
【问题讨论】:
-
它正在检查几个字节的值。或者您是在问为什么这些特定值?
-
"谁能解释一下这个 while 条件有什么作用?"是的。 Someone can.
-
你用java实现了屏幕共享吗?你能分享任何来源吗
标签: java swing screensharing