From 3c58a1ac262fe6250e6d8b52c3f31ba015bc679f Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 14 Jan 2003 00:59:55 +0000 Subject: [PATCH] Use the appropriate transparency when creating our prepared image. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2135 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../media/image/VolatileMirage.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/java/com/threerings/media/image/VolatileMirage.java b/src/java/com/threerings/media/image/VolatileMirage.java index 5a92f6564..628ba2753 100644 --- a/src/java/com/threerings/media/image/VolatileMirage.java +++ b/src/java/com/threerings/media/image/VolatileMirage.java @@ -1,12 +1,12 @@ // -// $Id: VolatileMirage.java,v 1.1 2003/01/13 22:49:46 mdb Exp $ +// $Id: VolatileMirage.java,v 1.2 2003/01/14 00:59:55 mdb Exp $ package com.threerings.media.image; +import java.awt.Color; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.Rectangle; -import java.awt.Transparency; import java.awt.image.BufferedImage; import java.awt.image.VolatileImage; @@ -49,13 +49,21 @@ public abstract class VolatileMirage implements Mirage // break; // } - // now we can render it - gfx.drawImage(_image, x, y, null); +// // now we can render it +// gfx.drawImage(_image, x, y, null); // renders++; // // don't try forever // } while (_image.contentsLost() && (renders < 10)); + if (IMAGE_DEBUG) { + gfx.setColor(new Color(_image.getRGB(_bounds.width/2, + _bounds.height/2))); + gfx.fillRect(x, y, _bounds.width, _bounds.height); + } else { + gfx.drawImage(_image, x, y, null); + } + // TODO: note number of attempted renders for performance } @@ -101,12 +109,18 @@ public abstract class VolatileMirage implements Mirage // _image = gc.createCompatibleVolatileImage( // _bounds.width, _bounds.height); _image = gc.createCompatibleImage( - _bounds.width, _bounds.height, Transparency.BITMASK); + _bounds.width, _bounds.height, getTransparency()); // render our source image into the volatile image refreshVolatileImage(); } + /** + * Returns the transparency that should be used when creating our + * volatile image. + */ + protected abstract int getTransparency (); + /** * Rerenders our volatile image from the its source image data. */ @@ -141,4 +155,7 @@ public abstract class VolatileMirage implements Mirage * any time. */ // protected VolatileImage _image; protected BufferedImage _image; + + /** Turns off image rendering for testing. */ + protected static final boolean IMAGE_DEBUG = false; }