Saturday, August 13, 2011

Screen Capture

Related Articles


Introduction

In this article, you will see a simple program that captures the screen and saves the image to a jpeg file. It consists of only a few lines of Java code and yet it is doing something meaningful.

Getting the Screen Dimension




Save it as A.java and run it, a sample run is shown below :
javac A.java
java A
screen dimension = 1280x800

Screen Capture


Once we get the screen dimension and save it in a Rectangle structure, we can define a capture() method that takes the rectangle as a parameter. Compile and run the following program, a jpeg file screen.jpg would be created.

No comments:

Post a Comment