I've been trying to get an image from a JLabel icon and then convert that image to bytes before inserting it to database. I've done something like that but when I get the bytes from database and set it back to the JLabel as Icon, its just black. Any help? This is my code.
try {
Icon icons = passpo.getIcon();
BufferedImage image = new BufferedImage(icons.getIconWidth(),
icons.getIconHeight(),BufferedImage.TYPE_INT_RGB);
ByteArrayOutputStream b =new ByteArrayOutputStream();
ImageIO.write(image, "jpg", b );
byte[] imageInByte = b.toByteArray();
byte[] photos = imageInByte;
} catch (IOException d) {
JOptionPane.showMessageDialog(this, d);
}