mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-02-17 20:31:37 +01:00
Fix background colors when rendering zoomout with JPEG format
This commit is contained in:
parent
37a9809f67
commit
21c68fa1b2
@ -1,10 +1,12 @@
|
||||
package org.dynmap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.Location;
|
||||
import org.dynmap.MapType.ImageFormat;
|
||||
import org.dynmap.debug.Debug;
|
||||
import org.dynmap.utils.DynmapBufferedImage;
|
||||
import org.dynmap.utils.FileLockManager;
|
||||
@ -151,6 +153,7 @@ public class DynmapWorld {
|
||||
boolean neg_step_y;
|
||||
String baseprefix;
|
||||
int zoomlevel;
|
||||
int background;
|
||||
String zoomprefix;
|
||||
String fnprefix;
|
||||
String zfnprefix;
|
||||
@ -233,7 +236,7 @@ public class DynmapWorld {
|
||||
/* If level is above top needed for this map, skip */
|
||||
if(zoomlevel > (this.extrazoomoutlevels + mt.getMapZoomOutLevels()))
|
||||
continue;
|
||||
List<String> pfx = mt.baseZoomFilePrefixes();
|
||||
List<MapType.ZoomInfo> pfx = mt.baseZoomFileInfo();
|
||||
int stepsize = mt.baseZoomFileStepSize();
|
||||
int bigworldshift = mt.getBigWorldShift();
|
||||
boolean neg_step_x = false;
|
||||
@ -252,13 +255,14 @@ public class DynmapWorld {
|
||||
break;
|
||||
}
|
||||
int[] stepseq = mt.zoomFileStepSequence();
|
||||
for(String p : pfx) {
|
||||
for(MapType.ZoomInfo p : pfx) {
|
||||
PrefixData pd = new PrefixData();
|
||||
pd.stepsize = stepsize;
|
||||
pd.neg_step_x = neg_step_x;
|
||||
pd.neg_step_y = neg_step_y;
|
||||
pd.stepseq = stepseq;
|
||||
pd.baseprefix = p;
|
||||
pd.baseprefix = p.prefix;
|
||||
pd.background = p.background_argb;
|
||||
pd.zoomlevel = zoomlevel;
|
||||
pd.zoomprefix = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz".substring(0, zoomlevel);
|
||||
pd.bigworldshift = bigworldshift;
|
||||
@ -279,7 +283,7 @@ public class DynmapWorld {
|
||||
pd.zfnprefix = "z" + pd.fnprefix;
|
||||
}
|
||||
|
||||
maptab.put(p, pd);
|
||||
maptab.put(p.prefix, pd);
|
||||
}
|
||||
}
|
||||
return maptab;
|
||||
@ -430,6 +434,16 @@ public class DynmapWorld {
|
||||
/* blit scaled rendered tile onto zoom-out tile */
|
||||
zIm.setRGB(((i>>1) != 0)?0:width/2, (i & 1) * height/2, width/2, height/2, argb, 0, width);
|
||||
}
|
||||
else if((pd.background != 0) && (pd.fmt != ImageFormat.FORMAT_PNG)) {
|
||||
Arrays.fill(argb, pd.background);
|
||||
/* blit scaled rendered tile onto zoom-out tile */
|
||||
zIm.setRGB(((i>>1) != 0)?0:width/2, (i & 1) * height/2, width/2, height/2, argb, 0, width);
|
||||
}
|
||||
}
|
||||
else if((pd.background != 0) && (pd.fmt != ImageFormat.FORMAT_PNG)) {
|
||||
Arrays.fill(argb, pd.background);
|
||||
/* blit scaled rendered tile onto zoom-out tile */
|
||||
zIm.setRGB(((i>>1) != 0)?0:width/2, (i & 1) * height/2, width/2, height/2, argb, 0, width);
|
||||
}
|
||||
}
|
||||
FileLockManager.getWriteLock(zf);
|
||||
|
@ -28,6 +28,12 @@ public abstract class MapType {
|
||||
public String getFileExt() { return ext; }
|
||||
public float getQuality() { return qual; }
|
||||
};
|
||||
|
||||
public static class ZoomInfo {
|
||||
public String prefix;
|
||||
public int background_argb;
|
||||
public ZoomInfo(String pre, int bg) { prefix = pre; background_argb = bg; }
|
||||
}
|
||||
|
||||
public abstract MapTile[] getTiles(Location l);
|
||||
|
||||
@ -54,7 +60,7 @@ public abstract class MapType {
|
||||
X_MINUS_Y_MINUS
|
||||
}
|
||||
public abstract MapStep zoomFileMapStep();
|
||||
public abstract List<String> baseZoomFilePrefixes();
|
||||
public abstract List<ZoomInfo> baseZoomFileInfo();
|
||||
public abstract int baseZoomFileStepSize();
|
||||
/* How many bits of coordinate are shifted off to make big world directory name */
|
||||
public abstract int getBigWorldShift();
|
||||
@ -64,7 +70,11 @@ public abstract class MapType {
|
||||
public int getMapZoomOutLevels() { return 0; }
|
||||
|
||||
public ImageFormat getImageFormat() { return ImageFormat.FORMAT_PNG; }
|
||||
|
||||
|
||||
public int getBackgroundARGBNight() { return 0; }
|
||||
|
||||
public int getBackgroundARGBDay() { return 0; }
|
||||
|
||||
/**
|
||||
* Step sequence for creating zoomed file: first index is top-left, second top-right, third bottom-left, forth bottom-right
|
||||
* Values correspond to tile X,Y (0), X+step,Y (1), X,Y+step (2), X+step,Y+step (3)
|
||||
|
@ -454,11 +454,11 @@ public class FlatMap extends MapType {
|
||||
return Collections.singletonList(name);
|
||||
}
|
||||
|
||||
public List<String> baseZoomFilePrefixes() {
|
||||
ArrayList<String> s = new ArrayList<String>();
|
||||
s.add(getPrefix() + "_128");
|
||||
public List<ZoomInfo> baseZoomFileInfo() {
|
||||
ArrayList<ZoomInfo> s = new ArrayList<ZoomInfo>();
|
||||
s.add(new ZoomInfo(getPrefix() + "_128", 0));
|
||||
if(night_and_day)
|
||||
s.add(getPrefix()+"_day_128");
|
||||
s.add(new ZoomInfo(getPrefix()+"_day_128", 0));
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -143,11 +143,11 @@ public class HDMap extends MapType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> baseZoomFilePrefixes() {
|
||||
ArrayList<String> s = new ArrayList<String>();
|
||||
s.add(prefix);
|
||||
public List<ZoomInfo> baseZoomFileInfo() {
|
||||
ArrayList<ZoomInfo> s = new ArrayList<ZoomInfo>();
|
||||
s.add(new ZoomInfo(prefix, getBackgroundARGBNight()));
|
||||
if(lighting.isNightAndDayEnabled())
|
||||
s.add(prefix + "_day");
|
||||
s.add(new ZoomInfo(prefix + "_day", getBackgroundARGBDay()));
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -259,6 +259,7 @@ public class HDMap extends MapType {
|
||||
v = 0xFF000000 | (v & 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -289,12 +289,12 @@ public class KzedMap extends MapType {
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> baseZoomFilePrefixes() {
|
||||
ArrayList<String> s = new ArrayList<String>();
|
||||
public List<ZoomInfo> baseZoomFileInfo() {
|
||||
ArrayList<ZoomInfo> s = new ArrayList<ZoomInfo>();
|
||||
for(MapTileRenderer r : renderers) {
|
||||
s.add("z" + r.getPrefix());
|
||||
s.add(new ZoomInfo("z" + r.getPrefix(), 0));
|
||||
if(r.isNightAndDayEnabled())
|
||||
s.add("z" + r.getPrefix() + "_day");
|
||||
s.add(new ZoomInfo("z" + r.getPrefix() + "_day", 0));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user