Queria realizar capturas en un equipo remoto, y convertirlas a un arreglo de bytes para luego enviarlas (si queremos fragmentado ) para luego reconstruirlo en el pc remoto:
Realizando la captura:
Código
{ try { // TODO Auto-generated catch block e2.printStackTrace(); } try { // TODO Auto-generated catch block e1.printStackTrace(); } //---- try { robot.createScreenCapture(screenRectangle); } { e.printStackTrace(); } return imageFile; }
Obteniendola y escribiendo a un arreglo de bytes:
Código
captura = funciones.getScreenShot(); try { long length = captura.length(); } // Create the byte array to hold the data byte[] bytes = new byte[(int)length]; // Read in the bytes int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) { offset += numRead; } // Ensure all the bytes have been read in if (offset < bytes.length) { } // Close the input stream and return bytes is.close();
Y ahora tratandola, por ejemplo enviarla:
Código
Y los vamos reciviendo recursivamente (muy parecido a lo anterior)
for(int i = 0; i < bytes.length; i++) { os.write(bytes[i]); S}
Y ahora lo escribimos a un fichero:
Código
fileNuevo.write(bytes);
Y habremos transferido nuestra imagen!
Saludos