文档介绍:作者:jeru
email: jeru@
日期:2001-2-9 11:09:49
/**
jeruGraphics v
*
看到一些动态生成图象的例子都是servlet完成的,
而且程序很长,觉得不是无论从实用性还是可读性来说都不是太好。
这里给了段代码,命令行生成图象文件。这样是不是简单易用些呢?
*
创建一个 BufferedImage 对象,将你的“画”放到这个缓冲里,
再打开一个文件,将图像流编码后输入这个文件,这样就有一个
jpg文件出现了,试试吧。。。
*
Mender :
Jeru Liu
Homepage :
http://javaren.
Email: jeru@
*
这仅仅是一个范例程序,没什么实用,却极具参考价值。
*
*/
import .*;
import .*;
..*;
import .*;
import .*;
public class jeruGraphics {
BufferedImage image;
// 创建 jpg 文件到指定路径下
public void createJpg(String path) {
try {
FileOutputStream fos = new FileOutputStream(path);
BufferedOutputStream bos = new BufferedOutputStream(fos);
JPEGImageEncoder encoder = (bos);
(image);
();
} catch(FileNotFoundException fnfe) {
(fnfe);
} catch(IOException ioe) {
(ioe);
}
}
public static void main(String[] args) {
int width=400, height=200;
int xLength=300, yLength=150;
int count=5;
Vector data=new Vector();
(new Integer(100));
(new Integer(120));
(new Integer(150));
(new Integer(40));
(new Integer(5));
jeruGraphics jg = new jeruGraphics();
= new BufferedImage(width, height,