CSDN博客

img programlover

如何将form保存到图片中!

发表于2001/10/7 10:51:00  415人阅读

public void OnSaveJPG() {
Rectangle rect = getBounds();
BufferedImage image =
(BufferedImage)createImage(rect.width, rect.height);
Graphics g = image.getGraphics();
paint(g);
g.dispose();

try {
FileOutputStream fileStream =
new FileOutputStream("E://Test.jpg");
JPEGImageEncoder encoder =
JPEGCodec.createJPEGEncoder(fileStream);
encoder.encode(image);
fileStream.close();
} catch (Exception e) {
System.out.println("Error saving JPEG file!");
}
}
0 0

相关博文

我的热门文章

img
取 消
img