From 800ae8195cde55675a2a7e5e56e901003742f7c9 Mon Sep 17 00:00:00 2001 From: Dave Hoover Date: Wed, 5 Aug 2009 18:34:56 +0000 Subject: [PATCH] I will not apply colorizations one after another. I will not apply colorizations one after another. I will not apply colorizations one after another. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@845 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/java/com/threerings/resource/Handler.java | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/java/com/threerings/resource/Handler.java b/src/java/com/threerings/resource/Handler.java index de4a0779..0f2ff7d0 100644 --- a/src/java/com/threerings/resource/Handler.java +++ b/src/java/com/threerings/resource/Handler.java @@ -21,6 +21,7 @@ package com.threerings.resource; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -38,6 +39,7 @@ import java.awt.image.BufferedImage; import javax.imageio.ImageIO; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.samskivert.io.ByteArrayOutInputStream; @@ -193,29 +195,34 @@ public class Handler extends URLStreamHandler BufferedImage tile = src.getSubimage(trect.x, trect.y, trect.width, trect.height); if (zations != null) { ColorPository pository = ColorPository.loadColorPository(_rmgr); + ArrayList colorizations = Lists.newArrayList(); for (Map.Entry entry : zations.entrySet()) { String zClass = entry.getKey(); String zColor = entry.getValue(); + + Colorization zation = null; + + // First try looking if we got a number try { - Colorization zation = null; + zation = pository.getColorization(zClass, Integer.parseInt(zColor)); + } catch (NumberFormatException nfe) { } - // First try looking if we got a number - try { - zation = pository.getColorization(zClass, Integer.parseInt(zColor)); - } catch (NumberFormatException nfe) { } - - // If that didn't work, try it as a zation name - if (zation == null) { - zation = pository.getColorization(zClass, zColor); - } - - tile = ImageUtil.recolorImage( - tile, zation.rootColor, zation.range, zation.offsets); - } catch (Exception e) { - log.warning("Trouble recoloring image in resource handler", - "zClass", zClass, "zColor", zColor, e); + // If that didn't work, try it as a zation name + if (zation == null) { + zation = pository.getColorization(zClass, zColor); } + + if (zation == null) { + log.warning("Couldn't figure out requested zation", + "class", zClass, "color", zColor); + } else { + colorizations.add(zation); + } + } + + tile = ImageUtil.recolorImage(tile, + colorizations.toArray(new Colorization[colorizations.size()])); } ByteArrayOutInputStream data = new ByteArrayOutInputStream();