Clear out the background when building a trimmed tileset.

Otherwise it's filled with some random color (palette entry
0?) and there are splotches of that filling the gaps between
trimmed tiles.
This commit is contained in:
David Hoover
2012-11-30 13:13:21 -08:00
committed by Michael Bayne
parent ddf07dc905
commit 9e87bc3519
@@ -19,7 +19,9 @@
package com.threerings.media.tile.util; package com.threerings.media.tile.util;
import java.awt.AlphaComposite;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.Area; import java.awt.geom.Area;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@@ -163,6 +165,11 @@ public class TileSetTrimmer
image = ImageUtil.createCompatibleImage(source.getRawTileSetImage(), image = ImageUtil.createCompatibleImage(source.getRawTileSetImage(),
bounds.width, bounds.height); bounds.width, bounds.height);
// Empty it out
Graphics2D graphics = (Graphics2D)image.getGraphics();
graphics.setComposite(AlphaComposite.Clear);
graphics.fillRect(0, 0, bounds.width, bounds.height);
} catch (RasterFormatException rfe) { } catch (RasterFormatException rfe) {
throw new IOException("Failed to create trimmed tileset image " + throw new IOException("Failed to create trimmed tileset image " +
"[bounds=" + bounds + ", tset=" + source + ", rfe=" + rfe + "]."); "[bounds=" + bounds + ", tset=" + source + ", rfe=" + rfe + "].");