Add support for JPEG encoding option for HDMaps

This commit is contained in:
Mike Primm 2011-08-12 14:44:49 +08:00 committed by mikeprimm
parent 49b38c10b7
commit d008548306
11 changed files with 72 additions and 33 deletions

View file

@ -19,6 +19,7 @@ import org.dynmap.utils.MapChunkCache;
import org.json.simple.JSONObject;
public class HDMap extends MapType {
private String name;
private String prefix;
private HDPerspective perspective;
@ -26,6 +27,11 @@ public class HDMap extends MapType {
private HDLighting lighting;
private ConfigurationNode configuration;
private int mapzoomout;
private MapType.ImageFormat imgformat;
public static final String IMGFORMAT_PNG = "png";
public static final String IMGFORMAT_JPG = "jpg";
public HDMap(ConfigurationNode configuration) {
name = configuration.getString("name", null);
@ -83,6 +89,12 @@ public class HDMap extends MapType {
mapzoomout++;
scale = scale / 2.0;
}
String fmt = configuration.getString("image-format", "png");
/* Only allow png or jpg */
if(fmt.equals(IMGFORMAT_PNG))
imgformat = ImageFormat.FORMAT_PNG;
else
imgformat = ImageFormat.FORMAT_JPG;
}
public HDShader getShader() { return shader; }
@ -104,14 +116,6 @@ public class HDMap extends MapType {
return perspective.getRequiredChunks(tile);
}
@Override
public boolean render(MapChunkCache cache, MapTile tile, File bogus) {
if(tile instanceof HDMapTile)
return perspective.render(cache, (HDMapTile)tile);
else
return false;
}
@Override
public List<String> baseZoomFilePrefixes() {
ArrayList<String> s = new ArrayList<String>();
@ -181,6 +185,8 @@ public class HDMap extends MapType {
return lst;
}
@Override
public ImageFormat getImageFormat() { return imgformat; }
@Override
public void buildClientConfiguration(JSONObject worldObject, DynmapWorld world) {
@ -197,6 +203,7 @@ public class HDMap extends MapType {
s(o, "bigmap", true);
s(o, "mapzoomout", (world.getExtraZoomOutLevels()+mapzoomout));
s(o, "mapzoomin", c.getInteger("mapzoomin", 2));
s(o, "image-format", imgformat.getFileExt());
perspective.addClientConfiguration(o);
shader.addClientConfiguration(o);
lighting.addClientConfiguration(o);