2

实际上,我正在尝试从 android 远程访问计算机,因为我在 java 中有服务器,我正在做这样的事情

 public class ScreenCapture
{

private Dimension screensize;
private BufferedImage bi;
private ByteArrayOutputStream byteout;
private byte[] data;

public ScreenCapture() throws IOException, AWTException
{
    screensize = Toolkit.getDefaultToolkit().getScreenSize();
    bi = new Robot().createScreenCapture(new Rectangle(0, 0, screensize.width, screensize.height));
    byteout = new ByteArrayOutputStream();
    ImageIO.write(bi, "jpeg", byteout);
    data = byteout.toByteArray();
}

public byte[] getScreenCapture()
{
    return data;
}


 }

然后我们有一个服务器

 public class Server
{
private Connection con;
private ScreenCapture sp;
private Socket soc;
private DataOutputStream out;

public Server() throws IOException, AWTException
{
    con = new Connection();
    sp = new ScreenCapture();
}

public void init() throws IOException

{
    con.setPort(3838);
    soc = con.openConnection();
    out.write(sp.getScreenCapture());
}

public static void main(String[] arg)
{


}

}

客户端是基于android的,代码就像它没有完成我的意思是我不知道如何获取图像

  public class Client extends Activity
{
private DataInputStream input;
private Socket soc;
private Connection con;
private Canvas can;

public void init() throws UnknownHostException, IOException
{
    con.setHost("10.0.2.2");
    con.setPort(3838);
    soc = con.openConnection();
    input.read();
    BitmapFactory b = b.decodeStream(input.readByte());
}
public void onCreate(Bundle b)
{
    super.onCreate(b);
    setContentView(R.layout.androidclientview);     

}

 }

所以请帮助我,如何显示这些图像,在服务器端捕获

4

0 回答 0