Hello,
I currently have this code to buffer an image:
public void paintComponent(Graphics g){
Graphics2D g2 = (Graphics2D) g;
ImageIcon icon = new ImageIcon("back.gif");
Image image = icon.getImage();
BufferedImage buff = new BufferedImage(image.getWidth(this), image.getHeight(this), BufferedImage.TYPE_INT_ARGB);
Graphics2D b = (Graphics2D) buff.createGraphics();
b.drawImage(image,imgX,imgY,this);
b.setColor(Color.BLUE);
b.fillRect((window.getWidth()/2)-13, (window.getHeight()/2)-13, 26, 26);
g2.drawImage(buff, 0, 0, this);
}
What it (should) do is load a background image. The background moves as I press the arrow keys (changing the imgX and imgY variables). The back.gif image is 5000 pixels square.
The issue is that when I don't buffer it flickers, when I use the above code, it takes FOREVER to move.
I know that 5000 pixel image isn't the best way to do this. And I think I'm on the right track when I say I need to crop it.
I would prefer to crop it in Java, although the code I find simply does not work. It either doesn't crop or doesn't show.
For reference: My JFrame is 1000x800.
Any advice/code is appreciated!
--Turt2Live