Revamped image loading such that the ResourceManager handles loading images

given a resource path so that it can be smart about loading from files versus
streams depending on what works based based on where the resources are coming
from. Also moved FastImageIO into com.threerings.resource to avoid a dependence
on com.threerings.media in resource.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@310 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Michael Bayne
2007-10-26 19:50:53 +00:00
parent 3e47134b06
commit ecc173d6ad
11 changed files with 86 additions and 87 deletions
@@ -21,6 +21,8 @@
package com.threerings.resource;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -251,8 +253,7 @@ public class ResourceBundle
}
// copy the resource into the temporary file
BufferedOutputStream fout =
new BufferedOutputStream(new FileOutputStream(tfile));
BufferedOutputStream fout = new BufferedOutputStream(new FileOutputStream(tfile));
InputStream jin = _jarSource.getInputStream(entry);
IOUtils.copy(jin, fout);
jin.close();
@@ -261,6 +262,16 @@ public class ResourceBundle
return tfile;
}
/**
* Decodes and returns the specified image resource. Returns null if no resource exists at the
* specified path.
*/
public BufferedImage getImageResource (String path)
throws IOException
{
return ResourceManager.loadImage(getResourceFile(path));
}
/**
* Returns true if this resource bundle contains the resource with the
* specified path. This avoids actually loading the resource, in the