Fix issue with white blank tiles at edge of JPG rendered maps

This commit is contained in:
Mike Primm 2011-12-23 13:27:36 +08:00 committed by mikeprimm
parent b872aa039e
commit cd067adfdc
2 changed files with 19 additions and 7 deletions

View File

@ -388,6 +388,7 @@ public class DynmapWorld {
int width = 128, height = 128; int width = 128, height = 128;
BufferedImage zIm = null; BufferedImage zIm = null;
DynmapBufferedImage kzIm = null; DynmapBufferedImage kzIm = null;
boolean blank = true;
int[] argb = new int[width*height]; int[] argb = new int[width*height];
int step = pd.stepsize << pd.zoomlevel; int step = pd.stepsize << pd.zoomlevel;
int ztx = tx; int ztx = tx;
@ -415,6 +416,7 @@ public class DynmapWorld {
if(im != null) { if(im != null) {
im.getRGB(0, 0, width, height, argb, 0, width); /* Read data */ im.getRGB(0, 0, width, height, argb, 0, width); /* Read data */
im.flush(); im.flush();
blank = false;
/* Do binlinear scale to 64x64 */ /* Do binlinear scale to 64x64 */
int off = 0; int off = 0;
for(int y = 0; y < height; y += 2) { for(int y = 0; y < height; y += 2) {
@ -434,17 +436,15 @@ public class DynmapWorld {
/* blit scaled rendered tile onto zoom-out tile */ /* 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); 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)) { else {
Arrays.fill(argb, pd.background); 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)) { else {
Arrays.fill(argb, pd.background); 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);
} }
/* 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); FileLockManager.getWriteLock(zf);
try { try {
@ -456,7 +456,15 @@ public class DynmapWorld {
int tilex = ztx/step/2; int tilex = ztx/step/2;
int tiley = zty/step/2; int tiley = zty/step/2;
String key = world.getName()+".z"+pd.zoomprefix+pd.baseprefix; String key = world.getName()+".z"+pd.zoomprefix+pd.baseprefix;
if((!zf.exists()) || (crc != mm.hashman.getImageHashCode(key, null, tilex, tiley))) { if(blank) {
if(zf.exists()) {
zf.delete();
hashman.updateHashCode(key, null, tilex, tiley, -1);
MapManager.mapman.pushUpdate(this.world, new Client.Tile(zfname));
enqueueZoomOutUpdate(zf, pd.zoomlevel+1);
}
}
else if((!zf.exists()) || (crc != mm.hashman.getImageHashCode(key, null, tilex, tiley))) {
try { try {
if(!zf.getParentFile().exists()) if(!zf.getParentFile().exists())
zf.getParentFile().mkdirs(); zf.getParentFile().mkdirs();

View File

@ -122,6 +122,10 @@ public class HDMap extends MapType {
if(c != null) { if(c != null) {
bgcolornight = parseColor(c); bgcolornight = parseColor(c);
} }
if(imgformat != ImageFormat.FORMAT_PNG) { /* If JPG, set background color opacity */
bgcolorday |= 0xFF000000;
bgcolornight |= 0xFF000000;
}
} }
public HDShader getShader() { return shader; } public HDShader getShader() { return shader; }