Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

take a screen shot and store it

Posted on 2004-09-07
9
Medium Priority
?
221 Views
Last Modified: 2010-03-31

Hi, I want to take a screenshot of a particular screen on on my system and store it as a jpeg. Is it possible to do this? If so how do I specify where to save the screen shot on my pc? Also is it possible to specify what program I want the jpeg (just this specific jpeg, not all jpegs on the system) to open with? in this case mozilla firebird. Thanks
0
Comment
Question by:VolSpeak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 12001161
Try

Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage bi = new Robot.createScreenCapture(screenRect);
ImageIO.writeImage(bi, "jpg", new FileOutputStream("screen.jpg");

What program opens a jpeg is not a Java issue - it's an OS one
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12003137
You can use
Runtime.getRuntime.exec()
to open the java file in some specific program
0
 

Author Comment

by:VolSpeak
ID: 12010098

Thanks for that CEHZ, this is the code im using:

  // capture the whole screen
BufferedImage screencapture = new Robot().createScreenCapture(
   new Rectangle(10, 10, 900, 750));
   
   // Save as JPEG
     File file = new File("screencapture.jpg");
     ImageIO.write(screencapture, "jpg", file);

For a points increase:
 The screen I want to capture has a scroll, is it possible to include the unscrolled part of the screen in the capture as well?
0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 86

Expert Comment

by:CEHJ
ID: 12010131
>>is it possible to include the unscrolled part of the screen in the capture as well?

AFAIK - no. Only what's visible. btw what kind of desktop scrolls?
0
 

Expert Comment

by:michaelfriesy
ID: 12010269
Its an open file, do you know of any work around?
0
 

Expert Comment

by:michaelfriesy
ID: 12010289
Apologies, not double accounts with one user, theres two of us using the same system....
0
 

Expert Comment

by:michaelfriesy
ID: 12010326
Ive just had an idea, can the resolution of the screen be changed using java so the whole file will be within the window?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12010349
>>can the resolution of the screen be changed using java so the whole file will be within the window?

Yes, but not without JNI or a Runtime.exec call
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12111123
8-)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question