I have a method to paint a image inside a bufferedimage, but when I return the bufferedimage it just shows up as a 200 by 200 black square instead of the image inside of it, which is suppose to be a goldfish. Here's my code:
Image returnGoldfish() {
BufferedImage bufferedImage = new BufferedImage(200, 200, BufferedImage.TYPE_3BYTE_BGR);
Graphics g = bufferedImage.getGraphics();
g.drawImage(imageFishy, x1, y1, null);
return bufferedImage;
}
If anyone know what I did wrong, please help. Thanks. Also, my image is set correctly.
Image imageFishy = new ImageIcon("I://Picture//fishy.jpg").getImage();
It shows up in the paint when I just paint it as imageFishy, without the bufferedImage.
Aucun commentaire:
Enregistrer un commentaire