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() )
}
}