Java+Swing可视化图像处理软件
- 一、系统介绍
- 二、功能展示
- 1.图片裁剪
- 2.图片缩放
- 3.图片旋转
- 4.图像灰度处理
- 5.图像变形
- 6.图像扭曲
- 7.图像移动
- 三、系统实现
- 1.ImageProcessing.java
- 四、其它
- 1.其他系统实现
一、系统介绍
该系统实现了图片裁剪、缩放、旋转、图像灰度处理、变形、扭曲、保存、移动。
二、功能展示
1.图片裁剪
2.图片缩放
3.图片旋转
4.图像灰度处理
5.图像变形
6.图像扭曲
7.图像移动
三、系统实现
1.ImageProcessing.java
package cn.image;import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Transparency;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;public class ImageProcessing extends JFrame {String filepath = "";String filename = "";File file2;BufferedImage buffimg = null;ImageIcon ic;Image ia, l;JLabel jLabel1 = null;BorderLayout borderLayout1 = new BorderLayout();JMenuBar jmb = new JMenuBar();JMenu file, edit, view, caijian, suofang, gray, see, save, move, niuqu;public ImageProcessing(String title) {super(title);file = new JMenu(" 文件 ");JMenuItem dakai = new JMenuItem(" 打开 ");dakai.addActionListener(new dakai_actionAdapter(this));file.add(dakai);file.addSeparator();JMenuItem tuichu = new JMenuItem(" 退出 ");tuichu.addActionListener(new tuichu_actionAdapter(this));file.add(tuichu);jmb.add(file);caijian = new JMenu(" 裁剪 ");JMenuItem fangxingcaijian = new JMenuItem(" 方形裁剪 ");fangxingcaijian.addActionListener(new testImage_fangxingcaijian_actionAdapter(this));this.getContentPane().setLayout(borderLayout1);caijian.add(fangxingcaijian);caijian.addSeparator();
// JMenuItem juxingcaijian = new JMenuItem(" 矩形裁剪 ");
// juxingcaijian.addActionListener(new testImage_fangxingcaijian_actionAdapter(this));
// this.getContentPane().setLayout(borderLayout1);
// caijian.add(juxingcaijian);jmb.add(caijian);suofang = new JMenu(" 缩放 ");JMenuItem suoxiao = new JMenuItem(" 缩小 ");suoxiao.addActionListener(new testImage_suoxiao_actionAdapter(this));this.getContentPane().setLayout(borderLayout1);suofang.add(suoxiao);suofang.addSeparator();JMenuItem fangda = new JMenuItem(" 放大 ");fangda.addActionListener(new testImage_fangda_actionAdapter(this));suofang.add(fangda);jmb.add(suofang);edit = new JMenu(" 旋转 ");JMenuItem xuanzhuan90 = new JMenuItem(" 旋转 90 度(顺时针)");xuanzhuan90.addActionListener(new xuanzhuan90_actionAdapter(this));edit.add(xuanzhuan90);edit.addSeparator();JMenuItem xuanzhuan180 = new JMenuItem(" 旋转 180 度 (顺时针)");xuanzhuan180.addActionListener(new xuanzhuan180_actionAdapter(this));edit.add(xuanzhuan180);edit.addSeparator();JMenuItem xuanzhuanziyou = new JMenuItem(" 旋转 270度(顺时针)");xuanzhuanziyou.addActionListener(new xuanzhuanziyou_actionAdapter(this));edit.add(xuanzhuanziyou);edit.addSeparator();JMenuItem xuanzhuan270 = new JMenuItem(" 自由旋转角度 ");xuanzhuan270.addActionListener(new xuanzhuan270_actionAdapter(this));edit.add(xuanzhuan270);jmb.add(edit);gray = new JMenu(" 图像灰度处理 ");JMenuItem huidu = new JMenuItem(" 灰度变换 ");huidu.addActionListener(new huidu_actionAdapter(this));gray.add(huidu);gray.addSeparator();JMenuItem junhenghua = new JMenuItem(" 直方图均衡化 ");junhenghua.addActionListener(new junhenghua_actionAdapter(this));gray.add(junhenghua);jmb.add(gray);// zyf/see = new JMenu(" 变形 ");JMenuItem lashen = new JMenuItem(" 拉伸 ");lashen.addActionListener(new testImage_lashen_actionAdapter(this));see.add(lashen);see.addSeparator();JMenuItem zhankuan = new JMenuItem(" 展宽 ");zhankuan.addActionListener(new testImage_zhankuan_actionAdapter(this));see.add(zhankuan);see.addSeparator();jmb.add(see);niuqu = new JMenu(" 扭曲 ");JMenuItem niuqu1 = new JMenuItem(" 扭曲 ");niuqu1.addActionListener(new testImage_niuqu1_actionAdapter(this));niuqu.add(niuqu1);niuqu.addSeparator();jmb.add(niuqu);save = new JMenu(" 保存 ");JMenuItem saveas = new JMenuItem(" 另存为 ");saveas.addActionListener(new saveas_actionAdapter(this));save.add(saveas);save.addSeparator();jmb.add(save);move = new JMenu(" 移动 ");JMenuItem lmove = new JMenuItem(" 向左移动 ");lmove.addActionListener(new lmove_actionAdapter(this));move.add(lmove);move.addSeparator();JMenuItem rmove = new JMenuItem(" 向右移动 ");rmove.addActionListener(new rmove_actionAdapter(this));move.add(rmove);move.addSeparator();JMenuItem cmove = new JMenuItem(" 居中移动 ");cmove.addActionListener(new cmove_actionAdapter(this));move.add(cmove);move.addSeparator();JMenuItem umove = new JMenuItem(" 向上移动 ");umove.addActionListener(new umove_actionAdapter(this));move.add(umove);move.addSeparator();JMenuItem dmove = new JMenuItem(" 向下移动 ");dmove.addActionListener(new dmove_actionAdapter(this));move.add(dmove);move.addSeparator();jmb.add(move);// zyf/view = new JMenu(" 详情 ");JMenuItem banben = new JMenuItem(" 版本说明 ");banben.addActionListener(new banben_actionAdapter(this));view.add(banben);jmb.add(view);// zyfthis.setSize(800, 600);this.setJMenuBar(jmb);jLabel1 = new JLabel("", JLabel.CENTER);JScrollPane pane = new JScrollPane(jLabel1);this.add(pane, borderLayout1.CENTER);this.setVisible(true);//设置窗口居中this.setLocationRelativeTo(null);}public static void main(String[] args) {ImageProcessing testImage1 = new ImageProcessing(" 基于Java语言的的可视化图像处理软件 ");testImage1.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {System.exit(0);}});}
}
四、其它
1.其他系统实现
Java+Swing实现学生选课管理系统
Java+Swing图书管理系统
Java+Swing学生信息管理系统