This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes After screen Capture(to a Gif File)????????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "After screen Capture(to a Gif File)?????????" Watch "After screen Capture(to a Gif File)?????????" New topic
Author

After screen Capture(to a Gif File)?????????

netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
Hi Nate i've captured the screen & put it in a BufferedImage.I've used Jpegencoder to encode &
save it to a jpeg image file.How to improve the quality of the jpeg image& how to increase the
resolution of the image? I also want the BufferedImage to be saved as a gif file.Please reply this Nate.
The source is:
.............
Robot rob=new Robot();
Dimension d=Toolkit.getDefaultToolkit().getScreenSize();
System.out.println("dimension: "+d.toString());
BufferedImage bi=rob.createScreenCapture(new Rectangle(d));
File file = new File("test.jpg");
FileOutputStream out = new FileOutputStream(file);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
param.setQuality(1.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(bi);
.................
Happy middling with java.
Netharam.:confused.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

JPEG is a compressed image format, so there is always going to be some image degradation... The basic Java API's will read GIF's, but will not write them ( I'm assuming this is because of the idiotic Unisys GIF software patent. ) so you'll have to use a third party library... there are a list of several on this page.

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: After screen Capture(to a Gif File)?????????
 
Similar Threads
Saving runtime Swing UI as image
capture system screen to a gif file![immdtly.]
Java 2D Border Issue
how to save text as gif ?
maintain a BufferedImage as it is.........