当前位置: 技术问答>java相关
如何在java下截取桌面图像存为jpg格式?
来源: 互联网 发布时间:2015-10-22
本文导语: 如何在java下截取桌面图像存为jpg格式? | import java.awt.*; import java.awt.image.*; import com.sun.image.codec.jpeg.*; import java.io.*; public class ScCap { public static void main(String[] args) throws Exception { Robot...
如何在java下截取桌面图像存为jpg格式?
|
import java.awt.*;
import java.awt.image.*;
import com.sun.image.codec.jpeg.*;
import java.io.*;
public class ScCap
{
public static void main(String[] args) throws Exception
{
Robot r=new Robot();
Rectangle rect=new Rectangle(0,0,1024,768);
BufferedImage bimg=r.createScreenCapture(rect);
FileOutputStream fo=new FileOutputStream("a.jpeg");
JPEGImageEncoder jer=JPEGCodec.createJPEGEncoder(fo);
jer.encode(bimg);
fo.close();
}
}
请看
http://expert.csdn.net/Expert/topic/1127/1127994.xml?temp=.9430963
import java.awt.image.*;
import com.sun.image.codec.jpeg.*;
import java.io.*;
public class ScCap
{
public static void main(String[] args) throws Exception
{
Robot r=new Robot();
Rectangle rect=new Rectangle(0,0,1024,768);
BufferedImage bimg=r.createScreenCapture(rect);
FileOutputStream fo=new FileOutputStream("a.jpeg");
JPEGImageEncoder jer=JPEGCodec.createJPEGEncoder(fo);
jer.encode(bimg);
fo.close();
}
}
请看
http://expert.csdn.net/Expert/topic/1127/1127994.xml?temp=.9430963