From baf4879aadb2d8f701ecb6eec61240b67308e1ba Mon Sep 17 00:00:00 2001 From: melvin Date: Wed, 3 Aug 2011 10:55:42 +0800 Subject: [PATCH] manage origImages cache and scaledImages cache separately --- .../data/HighQualityCardImagesProvider.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/magic/data/HighQualityCardImagesProvider.java b/src/magic/data/HighQualityCardImagesProvider.java index a19feda842..717ef61d89 100644 --- a/src/magic/data/HighQualityCardImagesProvider.java +++ b/src/magic/data/HighQualityCardImagesProvider.java @@ -67,16 +67,18 @@ public class HighQualityCardImagesProvider implements CardImagesProvider { final String filename=getFilename(cardDefinition,index); - //put image into the cache - if (!(origImages.containsKey(filename) && scaledImages.containsKey(filename))) { - final BufferedImage origImage = loadCardImage(filename); - origImages.put(filename, origImage); + if (!origImages.containsKey(filename)) { + origImages.put(filename, loadCardImage(filename)); + } - final BufferedImage scaledImage = magic.GraphicsUtilities.scale( - origImage, + if (!scaledImages.containsKey(filename)) { + scaledImages.put(filename, + magic.GraphicsUtilities.scale( + origImages.get(filename), CARD_WIDTH, - CARD_HEIGHT); - scaledImages.put(filename, scaledImage); + CARD_HEIGHT + ) + ); } return orig ? origImages.get(filename) : scaledImages.get(filename);