The image manager now falls back to loading images via the Toolkit if it

can't load the ImageIO classes. This unfortunately means that we're back
to passing a Component instance to the ImageManager at construct time.
Whee!


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@749 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-12-07 01:33:29 +00:00
parent 14b9708e9e
commit 940154d7e3
17 changed files with 241 additions and 56 deletions
@@ -1,9 +1,9 @@
//
// $Id: ImageProvider.java,v 1.1 2001/11/18 04:09:21 mdb Exp $
// $Id: ImageProvider.java,v 1.2 2001/12/07 01:33:29 mdb Exp $
package com.threerings.media.tile;
import java.awt.image.BufferedImage;
import java.awt.Image;
import java.io.IOException;
/**
@@ -21,6 +21,6 @@ public interface ImageProvider
* @exception IOException thrown if an error occurs loading the image
* data.
*/
public BufferedImage loadImage (String path)
public Image loadImage (String path)
throws IOException;
}
@@ -1,12 +1,11 @@
//
// $Id: SwissArmyTileSet.java,v 1.4 2001/11/29 21:57:31 mdb Exp $
// $Id: SwissArmyTileSet.java,v 1.5 2001/12/07 01:33:29 mdb Exp $
package com.threerings.media.tile;
import java.awt.Image;
import java.awt.Point;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -14,7 +13,7 @@ import java.io.ObjectInputStream;
import com.samskivert.util.StringUtil;
import com.threerings.media.Log;
import com.threerings.media.ImageManager;
import com.threerings.media.ImageUtil;
/**
* The swiss army tileset supports a diverse variety of tiles in the
@@ -131,7 +130,7 @@ public class SwissArmyTileSet extends TileSet
// documentation inherited
protected Image extractTileImage (int tileIndex)
{
BufferedImage tsimg = getTilesetImage();
Image tsimg = getTilesetImage();
if (tsimg == null) {
return null;
}
@@ -160,7 +159,8 @@ public class SwissArmyTileSet extends TileSet
// ", tx=" + tx + ", ty=" + ty + "].");
// crop the tile-sized image chunk from the full image
return tsimg.getSubimage(tx, ty, _widths[ridx], _heights[ridx]);
return ImageUtil.getSubimage(
tsimg, tx, ty, _widths[ridx], _heights[ridx]);
}
private void readObject (ObjectInputStream in)
@@ -1,9 +1,9 @@
//
// $Id: TileManager.java,v 1.22 2001/11/30 02:34:57 mdb Exp $
// $Id: TileManager.java,v 1.23 2001/12/07 01:33:29 mdb Exp $
package com.threerings.media.tile;
import java.awt.image.BufferedImage;
import java.awt.Image;
import java.io.IOException;
import com.samskivert.io.PersistenceException;
@@ -136,7 +136,7 @@ public class TileManager implements ImageProvider
}
// documentation inherited
public BufferedImage loadImage (String path)
public Image loadImage (String path)
throws IOException
{
// load up the image data from the resource manager
@@ -1,5 +1,5 @@
//
// $Id: TileSet.java,v 1.22 2001/11/27 08:40:34 mdb Exp $
// $Id: TileSet.java,v 1.23 2001/12/07 01:33:29 mdb Exp $
package com.threerings.media.tile;
@@ -227,7 +227,7 @@ public abstract class TileSet
* @return the tileset image or null if an error occurred loading the
* image.
*/
protected BufferedImage getTilesetImage ()
protected Image getTilesetImage ()
{
// return it straight away if it's already loaded
if (_tilesetImg != null) {
@@ -281,5 +281,5 @@ public abstract class TileSet
/** The image containing all tile images for this set. This is private
* because it should be accessed via {@link #getTilesetImage} even by
* derived classes. */
private transient BufferedImage _tilesetImg;
private transient Image _tilesetImg;
}
@@ -1,13 +1,12 @@
//
// $Id: UniformTileSet.java,v 1.4 2001/11/29 21:57:31 mdb Exp $
// $Id: UniformTileSet.java,v 1.5 2001/12/07 01:33:29 mdb Exp $
package com.threerings.media.tile;
import java.awt.Image;
import java.awt.image.BufferedImage;
import com.threerings.media.Log;
import com.threerings.media.ImageManager;
import com.threerings.media.ImageUtil;
/**
* A uniform tileset is one that is composed of tiles that are all the
@@ -68,7 +67,7 @@ public class UniformTileSet extends TileSet
// documentation inherited
protected Image extractTileImage (int tileId)
{
BufferedImage tsimg = getTilesetImage();
Image tsimg = getTilesetImage();
if (tsimg == null) {
return null;
}
@@ -79,7 +78,8 @@ public class UniformTileSet extends TileSet
int col = tileId % tilesPerRow;
// crop the tile-sized image chunk from the full image
return tsimg.getSubimage(_width*col, _height*row, _width, _height);
return ImageUtil.getSubimage(
tsimg, _width*col, _height*row, _width, _height);
}
// documentation inherited
@@ -1,9 +1,9 @@
//
// $Id: TileSetBundle.java,v 1.4 2001/11/30 02:34:57 mdb Exp $
// $Id: TileSetBundle.java,v 1.5 2001/12/07 01:33:29 mdb Exp $
package com.threerings.media.tile.bundle;
import java.awt.image.BufferedImage;
import java.awt.Image;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -73,7 +73,7 @@ public class TileSetBundle
}
// documentation inherited
public BufferedImage loadImage (String path)
public Image loadImage (String path)
throws IOException
{
// obtain the image data from our jarfile
@@ -1,5 +1,5 @@
//
// $Id: DumpBundle.java,v 1.3 2001/11/30 02:34:58 mdb Exp $
// $Id: DumpBundle.java,v 1.4 2001/12/07 01:33:29 mdb Exp $
package com.threerings.media.tools.tile.bundle;
@@ -34,7 +34,7 @@ public class DumpBundle
// create a resource and image manager in case they want to dump
// the tiles
ResourceManager rmgr = new ResourceManager(null, "rsrc");
ImageManager imgr = new ImageManager(rmgr);
ImageManager imgr = new ImageManager(rmgr, null);
for (int i = 0; i < args.length; i++) {
// oh the hackery