TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
/* 一个非常有意思的抓屏程序
www.xiaopu.com 2001-8-1 小浦热线*/
import java.awt.* ;
import java.awt.image.* ;
import java.io.* ;
import com.sun.image.codec.jpeg.* ;
public class SaveAsJpg{
public SaveAsJpg(){
}
public static void main(String[] args) {
try {
BufferedImage screenshot = (new Robot()).createScreenCapture(new Rectangle(0,0,800,600)) ;
OutputStream out = new BufferedOutputStream(new FileOutputStream ("test.jpg")) ;
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder (out) ;
encoder.encode(screenshot) ;
out.close() ;
}catch (Exception exc) {exc.printStackTrace();}
finally {
System.exit(0) ;
}
}
} |
|