It's not the drawImage
that's taking up a lot of CPU, it's the ImageIO.read(…)
! Opening streams is expensive and thus should only be done once; when you first need to load the images. The best way to draw an image is to pre-load it into a BufferedImage
(or if you manipulate the pixels a VolatileImage
).
BufferedImage imageToDraw = ImageIO.read(getClass().getResource("path/To/Image.png"));
That path starts in the directory of your .java files. So, you'll want to add a folder containing your image(s). There are many different ways to load images, more of which are discussed here.
Then you can draw it just like you did before.
g.drawImage(imageToDraw, x, y, null);
This should be much faster. If you are still having problems with speed then this question might be useful.