Foros del Web » Programación para mayores de 30 ;) » Java »

Como hago un printscreen y lo guardo automaticamente

Estas en el tema de Como hago un printscreen y lo guardo automaticamente en el foro de Java en Foros del Web. eso... Como hago un printscreen y lo guardo automaticamente en una ubicacion x Gracias...
  #1 (permalink)  
Antiguo 26/04/2006, 08:27
 
Fecha de Ingreso: mayo-2005
Mensajes: 84
Antigüedad: 19 años
Puntos: 0
Como hago un printscreen y lo guardo automaticamente

eso... Como hago un printscreen y lo guardo automaticamente en una ubicacion x

Gracias
  #2 (permalink)  
Antiguo 26/04/2006, 09:24
Avatar de dogduck  
Fecha de Ingreso: enero-2006
Ubicación: ¿Atlantida, Hesperides, Islas afortunadas?
Mensajes: 2.231
Antigüedad: 18 años, 4 meses
Puntos: 19
Pues siento no poder ayudarte en la totalidad de tu pregunta . Pero por si te vale de algo , en este link verás como guardar una imagen en un fichero jpg
http://club.idecnet.com/~ccastano/femepa/050106.htm
--- editado : 5 minutes later ---
Mirate las clases java.awt.Robot y ImageIO , para lo de el printscreen ( http://forum.java.sun.com/thread.jsp...sageID=3859652 )

Aquí hay código que supuestamente toma un printscreen y lo guarda en un fichero
http://forum.java.sun.com/thread.jsp...sageID=4131659
Código:
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
 
public class Screenshot {
	public static void main(String[] args) throws Exception {
		// make sure we have exactly two arguments, 
		// a waiting period and a file name
		if (args.length != 2) {
			System.err.println("Usage: java Screenshot " +
				"WAITSECONDS OUTFILE.png");
			System.exit(1);
		}
		// check if file name is valid
		String outFileName = args[1];
		if (!outFileName.toLowerCase().endsWith(".png")) {
			System.err.println("Error: output file name must " +
				"end with \".png\".");
			System.exit(1);
		}
		// wait for a user-specified time
		try {
			long time = Long.parseLong(args[0]) * 1000;
			System.out.println("Waiting " + (time / 1000) + 
				" second(s)...");
			Thread.sleep(time);
		} catch(NumberFormatException nfe) {
			System.err.println(args[0] + " does not seem to be a " +
				"valid number of seconds.");
			System.exit(1);
		}
		// determine current screen size
		Toolkit toolkit = Toolkit.getDefaultToolkit();
		Dimension screenSize = toolkit.getScreenSize();
		Rectangle screenRect = new Rectangle(screenSize);
		// create screen shot
		Robot robot = new Robot();
		BufferedImage image = robot.createScreenCapture(screenRect);
		// save captured image to PNG file
		ImageIO.write(image, "png", new File(outFileName));
		// give feedback
		System.out.println("Saved screen shot (" + image.getWidth() +
			" x " + image.getHeight() + " pixels) to file \"" +
			outFileName + "\".");
		// use System.exit if the program hangs after writing the file;
		// that's an old bug which got fixed only recently
		// System.exit(0); 
	}
}

Última edición por dogduck; 26/04/2006 a las 09:37
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:34.