/**
*
* @return BufferedImage
* @throws AWTException
*/
private BufferedImage getFullScreenPic() throws AWTException
{
GraphicsDevice screens[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
java.awt.Rectangle screen = new java.awt.Rectangle();
for(int x = 0; screens != null && x != screens.length; x++)
{
screen.add(new java.awt.Rectangle(screens[x].getDefaultConfiguration().getBounds()));
}
Robot mrRobotor = new Robot();
return mrRobotor.createScreenCapture(screen);
}
package net.cyb0rk.vwebcam;
import java.awt.AWTException;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Main
{
public static void uploadToFtp()
{
}
public static BufferedImage getFullScreenPic() throws AWTException
{
GraphicsDevice screens[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
java.awt.Rectangle screen = new java.awt.Rectangle();
for(int x = 0; screens != null && x != screens.length; x++)
{
screen.add(new java.awt.Rectangle(screens[x].getDefaultConfiguration().getBounds()));
}
Robot mrRobotor = new Robot();
return mrRobotor.createScreenCapture(screen);
}
public static void main(String[] args) throws AWTException, IOException
{
String fullscreenPicPath = "/home/eni/bild.jpg";
BufferedImage fullscreenPic = getFullScreenPic();
ImageIO.write(fullscreenPic, "jpg", new File(fullscreenPicPath));
System.exit( 0 );
}
}
thE_29 hat gesagt.:Maybe als png speichern. Aber sonst passts so.