diff --git a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java index 1d340eb4..22362d0c 100644 --- a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java +++ b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java @@ -277,7 +277,7 @@ public class BundledComponentRepository // from interface ImageDataProvider public BufferedImage loadImage (String path) throws IOException { - return _bundle.getImageResource(path); + return _bundle.getImageResource(path, true); } // from interface FrameProvider @@ -357,7 +357,7 @@ public class BundledComponentRepository BufferedImage src = _imgr.getImage(getImageKey(path), zations); float percentageOfDataBuffer = 1; if (bounds != null) { - percentageOfDataBuffer = + percentageOfDataBuffer = (bounds.height * bounds.width) / (float)(src.getHeight() * src.getWidth()); src = src.getSubimage(bounds.x, bounds.y, bounds.width, bounds.height); } @@ -485,7 +485,7 @@ public class BundledComponentRepository { return _set.getTile(getTileIndex(orient, index)); } - + public Mirage getTileMirage(int orient, int index) { return _set.getTileMirage(getTileIndex(orient, index)); } diff --git a/src/java/com/threerings/media/tile/bundle/TileSetBundle.java b/src/java/com/threerings/media/tile/bundle/TileSetBundle.java index 9493c7c6..c4ad097c 100644 --- a/src/java/com/threerings/media/tile/bundle/TileSetBundle.java +++ b/src/java/com/threerings/media/tile/bundle/TileSetBundle.java @@ -30,6 +30,7 @@ import java.io.Serializable; import java.util.Iterator; import com.samskivert.util.HashIntMap; +import com.threerings.resource.FastImageIO; import com.threerings.resource.ResourceBundle; import com.threerings.media.image.ImageDataProvider; @@ -93,7 +94,11 @@ public class TileSetBundle extends HashIntMap public BufferedImage loadImage (String path) throws IOException { - return _bundle.getImageResource(path); + if (path.endsWith(FastImageIO.FILE_SUFFIX)) { + return _bundle.getImageResource(path, true); + } else { + return _bundle.getImageResource(path, false); + } } // custom serialization process @@ -108,7 +113,7 @@ public class TileSetBundle extends HashIntMap out.writeInt(entry.getIntKey()); out.writeObject(entry.getValue()); } - } + } // custom unserialization process private void readObject (ObjectInputStream in) diff --git a/src/java/com/threerings/resource/FileResourceBundle.java b/src/java/com/threerings/resource/FileResourceBundle.java index 88c1d3ee..a3b97901 100644 --- a/src/java/com/threerings/resource/FileResourceBundle.java +++ b/src/java/com/threerings/resource/FileResourceBundle.java @@ -93,10 +93,10 @@ public class FileResourceBundle extends ResourceBundle } @Override // from ResourceBundle - public BufferedImage getImageResource (String path) + public BufferedImage getImageResource (String path, boolean forceFastIO) throws IOException { - return ResourceManager.loadImage(getResourceFile(path)); + return ResourceManager.loadImage(getResourceFile(path), forceFastIO); } /** diff --git a/src/java/com/threerings/resource/ResourceBundle.java b/src/java/com/threerings/resource/ResourceBundle.java index f163e6b3..6243bc61 100644 --- a/src/java/com/threerings/resource/ResourceBundle.java +++ b/src/java/com/threerings/resource/ResourceBundle.java @@ -54,6 +54,6 @@ public abstract class ResourceBundle * Decodes and returns the specified image resource. Returns null if no resource exists at the * specified path. */ - public abstract BufferedImage getImageResource (String path) + public abstract BufferedImage getImageResource (String path, boolean forceFastIO) throws IOException; } diff --git a/src/java/com/threerings/resource/ResourceManager.java b/src/java/com/threerings/resource/ResourceManager.java index e360562a..a19684a9 100644 --- a/src/java/com/threerings/resource/ResourceManager.java +++ b/src/java/com/threerings/resource/ResourceManager.java @@ -459,7 +459,7 @@ public class ResourceManager { // first look for this resource in our default resource bundle for (ResourceBundle bundle : _default) { - BufferedImage image = bundle.getImageResource(path); + BufferedImage image = bundle.getImageResource(path, false); if (image != null) { return image; } @@ -468,7 +468,11 @@ public class ResourceManager // fallback next to an unpacked resource file File file = getResourceFile(path); if (file != null && file.exists()) { - return loadImage(file); + if (path.endsWith(FastImageIO.FILE_SUFFIX)) { + return loadImage(file, true); + } else { + return loadImage(file, false); + } } // first try a locale-specific file @@ -569,12 +573,13 @@ public class ResourceManager BufferedImage image = null; // try a localized version first if (_localePrefix != null) { - image = bundles[ii].getImageResource(PathUtil.appendPath(_localePrefix, path)); + image = + bundles[ii].getImageResource(PathUtil.appendPath(_localePrefix, path), false); } // if we didn't find that, try generic if (image == null) { - image = bundles[ii].getImageResource(path); + image = bundles[ii].getImageResource(path, false); } if (image != null) { @@ -652,14 +657,14 @@ public class ResourceManager /** * Loads an image from the supplied file. Supports {@link FastImageIO} files and formats - * supported by {@link ImageIO}. + * supported by {@link ImageIO} and will load the appropriate one based on the useFastIO param. */ - protected static BufferedImage loadImage (File file) + protected static BufferedImage loadImage (File file, boolean useFastIO) throws IOException { if (file == null) { return null; - } else if (file.getName().endsWith(FastImageIO.FILE_SUFFIX)) { + } else if (useFastIO) { return FastImageIO.read(file); } else { return ImageIO.read(file);