private void whileConnecting() throws IOException, AWTException { byte[] buffer; while(connection.isConnected()){ x = input.readFloat(); y = input.readFloat(); System.out.println("x = y"); capture = robot.createScreenCapture(screenRectangle);//capture whole screen baos = new ByteArrayOutputStream();//this object will receive the capture image ImageIO.write(capture, "jpg", baos);//chose "JPG" because this is the best image's format from size and quality baos.flush();//flush all the bytes System.out.println("Size of baos = " + baos.size()); buffer = baos.toByteArray();//convert ByteArrayOutputStream to bytes array that can to send it over socket baos.close();//close the ByteArrayOutputStream to can write in it again, if not closed it will append images output.writeObject(buffer);//send the image's byte array over the socket output.flush();//flush all bytes } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)