Buenos días, Tengo un problema, y es que no se como sacar la imagen de un jpanel y transformarlo a un objeto Image, he intentado con el siguiente código:
private static BufferedImage createImage(JPanel panel) {
int w = panel.getWidth();
int h = panel.getHeight();
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi.createGraphics();
panel.print(g);
return bi;
}
Pero claro ahor no se como convertir de BufferedImage a Image. Alguien me puede echar una mano, me sería de gran ayuda.
Gracias de antemano.