|
| ||||||||||
| Tags: awt, capturing, java, programming, screenshot |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| Capturing a Screenshot in Awt
|
|
#2
| ||||
| ||||
| Re: Capturing a Screenshot in Awt
Hello, I have the code below which can simply help you for taking the screenshot of the screen which you want. Code: import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Screenshot
{
public static void main(String[] args)
{
try
{
Robot robo = new Robot();
BufferedImage bufferedIm=robo.createScreenCapture(new Rectangle(100,100));
ImageIO.write(bufferedIm, "jpg", new File("C:/img.jpg"));
}
catch (AWTException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
} |
|
#3
| |||
| |||
| Re: Capturing a Screenshot in Awt
Hello, if you make use of the code below then you will able to get the solution for your problem for getting the screenshot in jpg format. So, just make use of it and solve your problem. Code: try
{
Robot rbt = new Robot();
int num = 100;
int num1 = 100;
int wdth = 200;
int hght = 200;
Rectangle rectarea = new Rectangle(num, num1, wdth, hght);
BufferedImage buffImage = rbt.createScreenCapture(rectarea);
rectarea = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
buffImage = rbt.createScreenCapture(rectarea);
}
catch (AWTException e)
{
} |
|
#4
| ||||
| ||||
| Re: Capturing a Screenshot in Awt
Hello, if you want to capture the screen with the help of java awt then you must need to make use of the trick of the Print screen in our windows application. For getting the solution for your problem you must need to make use of the methods below: createScreenCapture(): If you make use of this method then you are using the method of the Robot class. This methd will create an image which can be read by the screen. For getting the screen size it make uses the getDefaultToolkit().getScreenSize() method of the Toolkit class. write(): write() is the method of the ImageIO class. Image is saved into the image buffer before creating the new image. If you are using this method then it is necessary to make use of the three arguments below:
ImageIO: it is the class which is available in javax.imageio.*; package. It will help you to read the image. |
|
#5
| ||||
| ||||
| Re: Capturing a Screenshot in Awt
Hello, if you want to capture the screenshot in Awt then you just need to make use of the code below in your program and you will able to get solved your problem: Code: Robot robot = new Robot();
BufferedImage bufferedimage=robot.createScreenCapture(new Rectangle(250,400));
ImageIO.write(bufferedimage, "jpg", new File("C:/img.jpg")); |
|
#6
| ||||
| ||||
| Re: Capturing a Screenshot in Awt
Hello, for getting this problem solved you must need to make use of the following books in AWT:
|
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Capturing a Screenshot in Awt" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is it possible to capturing on-screen pictures with HTC HD2 | Sosie | Portable Devices | 5 | 27-04-2011 07:36 PM |
| How to take a Screenshot on the iPad and iPhone without a screenshot application | Emily123 | Tips & Tweaks | 2 | 21-07-2010 05:14 AM |
| Capturing Program? | alex198555 | Windows Software | 1 | 12-07-2010 11:06 AM |
| about capturing video | what can i do?? | Vista Help | 8 | 09-08-2009 10:29 PM |
| Capturing Images From Wmv Video | Akshita | Windows Software | 3 | 02-06-2009 09:38 PM |