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
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
package com.threerings.resource;
|
package com.threerings.resource;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ import java.awt.image.BufferedImage;
|
|||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import com.samskivert.io.ByteArrayOutInputStream;
|
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);
|
BufferedImage tile = src.getSubimage(trect.x, trect.y, trect.width, trect.height);
|
||||||
if (zations != null) {
|
if (zations != null) {
|
||||||
ColorPository pository = ColorPository.loadColorPository(_rmgr);
|
ColorPository pository = ColorPository.loadColorPository(_rmgr);
|
||||||
|
ArrayList<Colorization> colorizations = Lists.newArrayList();
|
||||||
for (Map.Entry<String, String> entry : zations.entrySet()) {
|
for (Map.Entry<String, String> entry : zations.entrySet()) {
|
||||||
String zClass = entry.getKey();
|
String zClass = entry.getKey();
|
||||||
String zColor = entry.getValue();
|
String zColor = entry.getValue();
|
||||||
|
|
||||||
|
Colorization zation = null;
|
||||||
|
|
||||||
|
// First try looking if we got a number
|
||||||
try {
|
try {
|
||||||
Colorization zation = null;
|
zation = pository.getColorization(zClass, Integer.parseInt(zColor));
|
||||||
|
} catch (NumberFormatException nfe) { }
|
||||||
|
|
||||||
// First try looking if we got a number
|
// If that didn't work, try it as a zation name
|
||||||
try {
|
if (zation == null) {
|
||||||
zation = pository.getColorization(zClass, Integer.parseInt(zColor));
|
zation = pository.getColorization(zClass, 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 (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();
|
ByteArrayOutInputStream data = new ByteArrayOutInputStream();
|
||||||
|
|||||||
Reference in New Issue
Block a user