⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui.java

📁 class with yuv2rgb and rgb2yuv conversion and also simple dpcm algorithm just line after line
💻 JAVA
字号:
/* * Gui.java * * Created on 14. březen 2009, 10:03 */package transformace;import java.awt.Image;import javax.swing.ImageIcon;/** * * @author  xbalak00 */public class Gui extends javax.swing.JFrame {    private String cesta;    /** Creates new form Gui */    public Gui() {        initComponents();    }        /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    @SuppressWarnings("unchecked")    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        jFileChooser1 = new javax.swing.JFileChooser();        jPanel1 = new javax.swing.JPanel();        jPanel2 = new javax.swing.JPanel();        jLabel1 = new javax.swing.JLabel();        jPanel3 = new javax.swing.JPanel();        jLabel2 = new javax.swing.JLabel();        jMenuBar1 = new javax.swing.JMenuBar();        jMenu1 = new javax.swing.JMenu();        jMenuItem1 = new javax.swing.JMenuItem();        jMenu2 = new javax.swing.JMenu();        jMenuItem2 = new javax.swing.JMenuItem();        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);        jPanel1.setLayout(null);        jPanel2.setBackground(new java.awt.Color(255, 204, 204));        jPanel2.setLayout(null);        jPanel2.add(jLabel1);        jLabel1.setBounds(0, 0, 256, 256);        jPanel1.add(jPanel2);        jPanel2.setBounds(10, 10, 270, 270);        jPanel3.setBackground(new java.awt.Color(153, 255, 153));        jPanel3.setMinimumSize(new java.awt.Dimension(270, 270));        jPanel3.setLayout(null);        jPanel3.add(jLabel2);        jLabel2.setBounds(0, 0, 256, 256);        jPanel1.add(jPanel3);        jPanel3.setBounds(300, 10, 270, 270);        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);        jMenu1.setText("File");        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));        jMenuItem1.setText("Open");        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jMenuItem1ActionPerformed(evt);            }        });        jMenu1.add(jMenuItem1);        jMenuBar1.add(jMenu1);        jMenu2.setText("Edit");        jMenuItem2.setText("DoSomeStuff");        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jMenuItem2ActionPerformed(evt);            }        });        jMenu2.add(jMenuItem2);        jMenuBar1.add(jMenu2);        setJMenuBar(jMenuBar1);        pack();    }// </editor-fold>//GEN-END:initComponentsprivate void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed    if(jFileChooser1.showOpenDialog(this) == jFileChooser1.APPROVE_OPTION){        this.cesta = jFileChooser1.getSelectedFile().getAbsolutePath();        ImageIcon imageIcon = new ImageIcon(cesta);        jLabel1.setIcon(imageIcon);    }}//GEN-LAST:event_jMenuItem1ActionPerformedprivate void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed    Picture picture = new Picture(this.cesta);    double rgb[][][] = picture.getRGB();    double yuv[][][] = picture.rgb2yuv(rgb);    Image i = picture.createImage(picture.yuv2rgb(yuv));    ImageIcon imageIcon = new ImageIcon(i);    jLabel2.setIcon(imageIcon);}//GEN-LAST:event_jMenuItem2ActionPerformed        /**     * @param args the command line arguments     */    public static void main(String args[]) {        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                new Gui().setVisible(true);            }        });    }        // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JFileChooser jFileChooser1;    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel2;    private javax.swing.JMenu jMenu1;    private javax.swing.JMenu jMenu2;    private javax.swing.JMenuBar jMenuBar1;    private javax.swing.JMenuItem jMenuItem1;    private javax.swing.JMenuItem jMenuItem2;    private javax.swing.JPanel jPanel1;    private javax.swing.JPanel jPanel2;    private javax.swing.JPanel jPanel3;    // End of variables declaration//GEN-END:variables    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -