Package astro.util

Source Code of astro.util.ImgShow

package astro.util;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import org.opencv.core.Mat;
import org.opencv.core.MatOfByte;
import org.opencv.highgui.Highgui;

/**
*
* @author SzeliTom
*/
public class ImgShow extends JFrame {
    private final JLabel imgL;
    private boolean hidden = false;
   
    public ImgShow() {
        this.setTitle("Picture Viewer");
        this.setDefaultCloseOperation(JFrame.ICONIFIED);
        this.setResizable(true);
        this.setLocation(0, 0);
       
        this.imgL = new JLabel();
        this.imgL.setHorizontalAlignment(JLabel.CENTER);
       
        this.getContentPane().add(imgL);
        this.validate();
        this.setVisible(true);
    }
   
    public void show( Mat m ) {
//        if( this.hidden = true )
//            this.setState(JFrame.ICONIFIED);
//        else {
//            this.setState(JFrame.NORMAL);
//            this.hidden = false;
//        }
       
       
        this.setSize(m.width()+30, m.height()+50);
       
        MatOfByte mob = new MatOfByte();
        Highgui.imencode(".jpeg", m, mob);
       
        byte [] imgByteArray = mob.toArray();
        ImageIcon img = new ImageIcon(imgByteArray);
       
        this.imgL.setIcon(img);
      
        //if( !this.isVisible() )
           
           
    }
}
TOP

Related Classes of astro.util.ImgShow

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.