0

There are 2 applications. One application act as server and sends continuously screen shot of desktop by using the following code.

Robot robot=new Robot();
OutputStream os;
BufferedImage image = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(image, "png", os);

The second application is Android application acts a client application and has to read continuously the above image stream from inputstream.

Could please help me to read the png images from inputstream in the client application.

Thanks & Regards Mini.

mini
  • 855
  • 4
  • 15
  • 22

2 Answers2

2

In client application, read the InputStream via Socket.getInputStream() method.

 BufferedInputStream in = new BufferedInputStream(socket.getInputStream());
 BufferedImage image = ImageIO.read(in);
KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
  • Here I am not using the java.awt package – mini Jul 04 '12 at 13:27
  • As `ImageIO` will wrap the stream in an `ImageInputStream` I doubt that the added `BufferedInputStream` will be of much use. – MvG Jul 04 '12 at 13:27
  • The Application thread is hanging at this line BufferedInputStream in = new BufferedInputStream(socket.getInputStream()); Since the server sends the imagestream continously to the client. – mini Jul 04 '12 at 13:43
1

Android SDK does not support the method ImageIO.read(). Even if you can compile your code, your android application will get crashed and have error about missing libraries like this:

could not find method javax.imageio.imageio.read

What I suggest is using bitmapping instead of this...

0014
  • 893
  • 4
  • 13
  • 40