New type of ResourceBundle - NetworkResourceBundle - This bundle grabs its resources over HTTP from a root URL rather than from a local jar file. To make use of this, we need a way to put all the contents of the bundle into an appropriate directory instead of a jar, including its metadata, so some new Bundler Tasks were created to do this. Finally, allow tile set trimming to be done to a non-raw image format through passing an optional imgFormat parameter. If no parameter is passed, it'll default ot the old behavior of using raw/FastIO. Note that to use network bundles, you can set the set_type in the resource manager.properties file. (e.g. "resource.set_type.tilesets = network") If no set_type is set for a resource set, it defaults to a normal FileResourceBundle

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@343 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Mike Thomas
2007-11-13 01:12:18 +00:00
parent 785eb10234
commit ee73dd43de
13 changed files with 713 additions and 73 deletions
@@ -22,6 +22,7 @@
package com.threerings.media.tile.util;
import java.awt.Rectangle;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.awt.image.RasterFormatException;
@@ -68,6 +69,16 @@ public class TileSetTrimmer
int trimWidth, int trimHeight);
}
/**
* Convenience function to trim the tile set using FastImageIO to save the result.
*/
public static void trimTileSet (
TileSet source, OutputStream destImage, TrimMetricsReceiver tmr)
throws IOException
{
trimTileSet(source, destImage, tmr, FastImageIO.FILE_SUFFIX);
}
/**
* Generates a trimmed tileset image from the supplied source
* tileset. The source tileset must be configured with an image
@@ -80,9 +91,10 @@ public class TileSetTrimmer
* will be written.
* @param tmr a callback object that will be used to inform the caller
* of the trimmed tile metrics.
* @param imgFormat the format in which to write the image file - or if null, use FastImageIO.
*/
public static void trimTileSet (
TileSet source, OutputStream destImage, TrimMetricsReceiver tmr)
TileSet source, OutputStream destImage, TrimMetricsReceiver tmr, String imgFormat)
throws IOException
{
int tcount = source.getTileCount();
@@ -140,6 +152,10 @@ public class TileSetTrimmer
}
// write out trimmed image
FastImageIO.write(image, destImage);
if (imgFormat == null || FastImageIO.FILE_SUFFIX.equals(imgFormat)) {
FastImageIO.write(image, destImage);
} else {
ImageIO.write(image, imgFormat, destImage);
}
}
}