基于java的JPEG图像生成器(课程设计)

时间:2013-09-11 06:17:16
【文件属性】:

文件名称:基于java的JPEG图像生成器(课程设计)

文件大小:22KB

文件格式:RAR

更新时间:2013-09-11 06:17:16

基于java的JPEG图像生成器(课程设计)

部分代码如下: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package makejpeg; /** * * @author Administrator */ import java.awt.*; import java.util.*; import java.awt.geom.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import javax.swing.*; import com.sun.image.codec.jpeg.*; class Point {int x,y; Point(int x,int y) {this.x=x;this.y=y; } } public class MakeJPEG extends Canvas implements MouseMotionListener,MouseListener,ActionListener { int x=-1,y=-1,橡皮擦通知=0,清除通知=0; Vector v=null;int n=1; Graphics2D ggg ; BufferedImage image; Frame window; Button 保存,调色板,橡皮,清除,画笔,获取屏幕,绘制图形; Color 画笔颜色; Panel pCenter,pSouth,pNorth; public MakeJPEG() { 保存=new Button("将绘制的图形或屏幕保存为JPG文件"); 获取屏幕=new Button("获取屏幕"); 绘制图形=new Button("绘制图形"); 调色板=new Button("打开调色板"); 画笔=new Button("画笔"); 橡皮=new Button("橡皮"); 清除=new Button("清除"); 调色板.addActionListener(this); 绘制图形.addActionListener(this); 保存.addActionListener(this); 画笔.addActionListener(this); 橡皮.addActionListener(this); 清除.addActionListener(this); 获取屏幕.addActionListener(this); 画笔颜色=new Color(0,0,0); addMouseMotionListener(this); addMouseListener(this); v=new Vector(); setBackground(Color.white); image=new BufferedImage(200,200,BufferedImage.TYPE_INT_RGB); ggg=image.createGraphics(); Rectangle2D rect=new Rectangle2D.Double(0,0,200,200); ggg.setColor(getBackground()); ggg.fill(rect); window=new Frame("JPEG图像生成器"); pCenter=new Panel(); pCenter.setLayout(null); pCenter.add(this); pCenter.setBackground(Color.gray); this.setBounds(80,30,210,210); window.add(pCenter,BorderLayout.CENTER); pNorth=new Panel(); pNorth.add(保存); pNorth.add(绘制图形); pNorth.add(获取屏幕);


网友评论

  • 没什么实质性的内容,感觉像骗分的