TheBigPJ
2008-04-01 19:11:23 UTC
Suggestions on the best (preferably easiest way) to compare two images
(captured both from the desktop via java robot) ?
The following code is the code I will be using to take the screen shot
(currently it saves just to a file):
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
class Screenshot{
static public void main()
{
try
{
//Get the screen size
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
Rectangle rect = new
Rectangle(0,0,screenSize.width,screenSize.height);
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(rect);
File file;
//Save the screenshot as a png
file = new File("screen.png");
ImageIO.write(image, "png", file);
//Save the screenshot as a jpg
file = new File("screen.jpg");
ImageIO.write(image, "jpg", file);
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
Thank you,
Peter (thebigpj)
(captured both from the desktop via java robot) ?
The following code is the code I will be using to take the screen shot
(currently it saves just to a file):
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
class Screenshot{
static public void main()
{
try
{
//Get the screen size
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
Rectangle rect = new
Rectangle(0,0,screenSize.width,screenSize.height);
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(rect);
File file;
//Save the screenshot as a png
file = new File("screen.png");
ImageIO.write(image, "png", file);
//Save the screenshot as a jpg
file = new File("screen.jpg");
ImageIO.write(image, "jpg", file);
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
Thank you,
Peter (thebigpj)