Changed default transparency of blank images to BITMASK rather than
TRANSLUCENT since that's what we prefer. Made ImageManager use ImageUtil to create blank images. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@871 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,15 +1,11 @@
|
|||||||
//
|
//
|
||||||
// $Id: ImageManager.java,v 1.11 2001/12/13 05:15:16 mdb Exp $
|
// $Id: ImageManager.java,v 1.12 2002/01/18 17:55:43 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.media;
|
package com.threerings.media;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.GraphicsConfiguration;
|
|
||||||
import java.awt.GraphicsDevice;
|
|
||||||
import java.awt.GraphicsEnvironment;
|
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.Transparency;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -44,12 +40,6 @@ public class ImageManager
|
|||||||
{
|
{
|
||||||
_rmgr = rmgr;
|
_rmgr = rmgr;
|
||||||
|
|
||||||
// obtain information on our graphics environment
|
|
||||||
GraphicsEnvironment genv =
|
|
||||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
|
||||||
GraphicsDevice gdev = genv.getDefaultScreenDevice();
|
|
||||||
_gconf = gdev.getDefaultConfiguration();
|
|
||||||
|
|
||||||
// try to figure out which image loader we'll be using
|
// try to figure out which image loader we'll be using
|
||||||
try {
|
try {
|
||||||
_loader = (ImageLoader)Class.forName(IMAGEIO_LOADER).newInstance();
|
_loader = (ImageLoader)Class.forName(IMAGEIO_LOADER).newInstance();
|
||||||
@@ -92,8 +82,7 @@ public class ImageManager
|
|||||||
int sheight = src.getHeight(null);
|
int sheight = src.getHeight(null);
|
||||||
|
|
||||||
// now convert the image to a format optimized for display
|
// now convert the image to a format optimized for display
|
||||||
BufferedImage dest = _gconf.createCompatibleImage(
|
BufferedImage dest = ImageUtil.createImage(swidth, sheight);
|
||||||
swidth, sheight, Transparency.BITMASK);
|
|
||||||
Graphics2D g2 = dest.createGraphics();
|
Graphics2D g2 = dest.createGraphics();
|
||||||
g2.drawImage(src, 0, 0, null);
|
g2.drawImage(src, 0, 0, null);
|
||||||
g2.dispose();
|
g2.dispose();
|
||||||
@@ -112,9 +101,6 @@ public class ImageManager
|
|||||||
/** A cache of loaded images. */
|
/** A cache of loaded images. */
|
||||||
protected HashMap _imgs = new HashMap();
|
protected HashMap _imgs = new HashMap();
|
||||||
|
|
||||||
/** The graphics configuration of our default display device. */
|
|
||||||
protected GraphicsConfiguration _gconf;
|
|
||||||
|
|
||||||
/** The classname of the ImageIO-based image loader which we attempt
|
/** The classname of the ImageIO-based image loader which we attempt
|
||||||
* to use but fallback from if we're not running a JVM that has
|
* to use but fallback from if we're not running a JVM that has
|
||||||
* ImageIO support. */
|
* ImageIO support. */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ImageUtil.java,v 1.2 2002/01/18 17:48:11 shaper Exp $
|
// $Id: ImageUtil.java,v 1.3 2002/01/18 17:55:43 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.media;
|
package com.threerings.media;
|
||||||
|
|
||||||
@@ -48,11 +48,11 @@ public class ImageUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new blank, translucent image with the given dimensions.
|
* Creates a new blank image with the given dimensions and
|
||||||
* The format of the created image is compatible with the graphics
|
* transparency set to {@link Transparency#BITMASK}. The format of
|
||||||
* configuration of the default screen device, such that no format
|
* the created image is compatible with the graphics configuration of
|
||||||
* conversion will be necessary when rendering the image to that
|
* the default screen device, such that no format conversion will be
|
||||||
* device.
|
* necessary when rendering the image to that device.
|
||||||
*
|
*
|
||||||
* @param width the desired image width.
|
* @param width the desired image width.
|
||||||
* @param height the desired image height.
|
* @param height the desired image height.
|
||||||
@@ -61,7 +61,7 @@ public class ImageUtil
|
|||||||
*/
|
*/
|
||||||
public static BufferedImage createImage (int width, int height)
|
public static BufferedImage createImage (int width, int height)
|
||||||
{
|
{
|
||||||
return createImage(width, height, Transparency.TRANSLUCENT);
|
return createImage(width, height, Transparency.BITMASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,6 +87,7 @@ public class ImageUtil
|
|||||||
/** The graphics configuration for the default screen device. */
|
/** The graphics configuration for the default screen device. */
|
||||||
protected static GraphicsConfiguration _gc;
|
protected static GraphicsConfiguration _gc;
|
||||||
static {
|
static {
|
||||||
|
// obtain information on our graphics environment
|
||||||
GraphicsEnvironment env =
|
GraphicsEnvironment env =
|
||||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
GraphicsDevice gd = env.getDefaultScreenDevice();
|
GraphicsDevice gd = env.getDefaultScreenDevice();
|
||||||
|
|||||||
Reference in New Issue
Block a user