Boa tarde Pessoal,
Estrou capturando uma stream RTSP de uma Camera IP e enviando para um Jpanel, porem eu também ploto uma régua (no formato de image .png) sobre esse Jpainel também, assim fazendo uma sobreposição.
Minha dúvida é de como retirar um screnshot do Jpanel a partir de um click em um JButton.
Segue meu código abaixo:
class ThreadCameraIP implements Runnable {
Frame frameCapturado = null;
protected volatile boolean runnable = false;
Java2DFrameConverter converte;
BufferedImage grade;
Graphics2D g ;
ThreadCameraIP() throws MalformedURLException, IOException {
grade = ImageIO.read(new File("src/imgs/regua.png"));
g = (Graphics2D) jPanel4.getGraphics();
converte = new Java2DFrameConverter();
}
@Override
public void run() {
synchronized (this) {
while (runnable) {
try {
Frame frame = cameraIP.grabImage();
BufferedImage buff = converte.convert(frame);
//plotando Stream RTSP da Camera IP no jPanel
if (g.drawImage(buff,0,0,1280,720, 0, 0, 1280, 720, null)) {
g.drawImage(grade,corX,corY,larguraRegua,245,null ); //plotando a regua sobre o jPanel
if (runnable == false) {
System.out.println("Paused ..... ");
this.wait();
}
}
} catch (Exception ex) {
System.out.println("Error!!");
ex.printStackTrace();
}
}
}
}
}