After I rotate a BufferedImage, I still see the old one.
I can flip (vertical, and horizontal) an image but when I try to scale or rotate it, the old image is still showing up. I've tried every repaint, remove, removeall, etc that I can think of but still have double vision!
Note that if I resize the window large enough ( just a little movement won't do it) then the old image does go away!
Here is the code that I use to rotate a loaded BufferedImage:
public static BufferedImage rotateImage(BufferedImage bi)
BufferedImage new_bi = new BufferedImage( bi.getHeight(),
Graphics2D g2d = new_bi.createGraphics();
AffineTransform at = g2d.getTransform();
AffineTransform rotation = new AffineTransform();
rotation.rotate(Math.PI / 2, bi.getWidth() / 2, bi.getHeight() / 2);
bi.getWidth() / 2 - new_bi.getWidth() / 2,
(bi.getHeight() / 2 - new_bi.getHeight() / 2) * -1);
The code that displays the new BufferedImage that is returned from the rotateImage method looks like this
private void displayBufferedImage(BufferedImage bif)
jpMainPanel = new JPanel();
if(jlBackground != null)
//This doesn't help...but I tried it
jlBackground = new JLabel();
ImageIcon backImage = new ImageIcon(bif);
jlBackground.setBounds(0, 0, backImage.getIconWidth(), backImage.getIconHeight());
getLayeredPane().add(jlBackground, new Integer(Integer.MIN_VALUE));
//Tried all of the following too...no help
I think if I can get the Rotate to work, then the scale will follow the same principle.
Can anyone help me cure my double vision please?