将form保存到图片中
2008-01-05 09:49:59 来源:WEB开发网核心提示: public void OnSaveJPG() {Rectangle rect = getBounds();BufferedImage image = (BufferedImage)createImage(rect.width, rect.height);Graphics g = image.getGraphics(
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!");
}
}
更多精彩
赞助商链接