From 06e3217d6b0f8df24dd4939ab9d35ad7066467b9 Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Tue, 10 Jun 2008 20:29:20 +0000 Subject: [PATCH] Well that's just peachy. When we drawImage from a BufferedImage, the performance is relative to the size of the source image, not to the size of the resulting tile subimage. Therefore, for largish tileset sources, this was taking a Very Long Time. So, we take a subimage first and use that for our drawing. (I believe it's still accurate that we cannot just use the subimage directly due to various factors - though if we somehow could, it would save us some cache space). git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@534 ed5b42cb-e716-0410-a449-f6a68f950b19 --- .../com/threerings/media/image/CachedVolatileMirage.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/media/image/CachedVolatileMirage.java b/src/java/com/threerings/media/image/CachedVolatileMirage.java index c4680af1..5e65d6cc 100644 --- a/src/java/com/threerings/media/image/CachedVolatileMirage.java +++ b/src/java/com/threerings/media/image/CachedVolatileMirage.java @@ -72,7 +72,11 @@ public class CachedVolatileMirage extends VolatileMirage BufferedImage source = _imgr.getImage(_source, _zations); if (source != null) { gfx = _image.getGraphics(); - gfx.drawImage(source, -_bounds.x, -_bounds.y, null); + // We grab a subimage before drawing because otherwise bufferedimage does all its + // computations across the entire image, including those parts outside the bounds. + BufferedImage subImg = + source.getSubimage(_bounds.x, _bounds.y, _bounds.width, _bounds.height); + gfx.drawImage(subImg, 0, 0, null); } } catch (Exception e) {