Okay, I've done some testing and figured out the fastest way to do it. Both the scaled drawImage() and g.create() are not the fastest. The best way to do it is:
1 2 3 4 5 6 7
| paint (Graphics g) { Shape oldClip = g.getClip (); g.setClip (x, y, width, height); g.drawImage (sx, sy, x - sx, y - sy, null ); g.setClip (oldClip); } |
The cool thing about this approach is that if you have a loop that renders several pieces from different images, you can take the "Shape oldClip = g.getClip()" and "g.setClip (oldClip)" out of the loop and only call them once the loop is done, saving yourself some processor cycles.
from, Stefan