mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-01-12 10:50:37 +01:00
Fix transparency handling in WEBP tile generation
This commit is contained in:
parent
50e6317fa9
commit
9066fa0135
@ -30,13 +30,15 @@ public abstract class MapType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum ImageEncoding {
|
public enum ImageEncoding {
|
||||||
PNG("png", "image/png"), JPG("jpg", "image/jpeg"), WEBP("webp", "image/webp");
|
PNG("png", "image/png", true), JPG("jpg", "image/jpeg", false), WEBP("webp", "image/webp", true);
|
||||||
public final String ext;
|
public final String ext;
|
||||||
public final String mimetype;
|
public final String mimetype;
|
||||||
|
public final boolean hasAlpha;
|
||||||
|
|
||||||
ImageEncoding(String ext, String mime) {
|
ImageEncoding(String ext, String mime, boolean has_alpha) {
|
||||||
this.ext = ext;
|
this.ext = ext;
|
||||||
this.mimetype = mime;
|
this.mimetype = mime;
|
||||||
|
this.hasAlpha = has_alpha;
|
||||||
}
|
}
|
||||||
public String getFileExt() { return ext; }
|
public String getFileExt() { return ext; }
|
||||||
public String getContentType() { return mimetype; }
|
public String getContentType() { return mimetype; }
|
||||||
|
@ -1250,7 +1250,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
DynmapBufferedImage dayim[] = new DynmapBufferedImage[numshaders];
|
DynmapBufferedImage dayim[] = new DynmapBufferedImage[numshaders];
|
||||||
int[][] argb_buf = new int[numshaders][];
|
int[][] argb_buf = new int[numshaders][];
|
||||||
int[][] day_argb_buf = new int[numshaders][];
|
int[][] day_argb_buf = new int[numshaders][];
|
||||||
boolean isjpg[] = new boolean[numshaders];
|
boolean isOpaque[] = new boolean[numshaders];
|
||||||
int bgday[] = new int[numshaders];
|
int bgday[] = new int[numshaders];
|
||||||
int bgnight[] = new int[numshaders];
|
int bgnight[] = new int[numshaders];
|
||||||
|
|
||||||
@ -1262,7 +1262,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
dayim[i] = DynmapBufferedImage.allocateBufferedImage(tileSize * sizescale, tileSize * sizescale);
|
dayim[i] = DynmapBufferedImage.allocateBufferedImage(tileSize * sizescale, tileSize * sizescale);
|
||||||
day_argb_buf[i] = dayim[i].argb_buf;
|
day_argb_buf[i] = dayim[i].argb_buf;
|
||||||
}
|
}
|
||||||
isjpg[i] = shaderstate[i].getMap().getImageFormat() != ImageFormat.FORMAT_PNG;
|
isOpaque[i] = !shaderstate[i].getMap().getImageFormat().getEncoding().hasAlpha;
|
||||||
bgday[i] = shaderstate[i].getMap().getBackgroundARGBDay();
|
bgday[i] = shaderstate[i].getMap().getBackgroundARGBDay();
|
||||||
bgnight[i] = shaderstate[i].getMap().getBackgroundARGBNight();
|
bgnight[i] = shaderstate[i].getMap().getBackgroundARGBNight();
|
||||||
}
|
}
|
||||||
@ -1325,17 +1325,17 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
}
|
}
|
||||||
shaderstate[i].getRayColor(rslt, 0);
|
shaderstate[i].getRayColor(rslt, 0);
|
||||||
int c_argb = rslt.getARGB();
|
int c_argb = rslt.getARGB();
|
||||||
if(c_argb != 0) rendered[i] = true;
|
if (c_argb != 0) rendered[i] = true;
|
||||||
if(isjpg[i] && (c_argb == 0)) {
|
if (isOpaque[i] && (c_argb == 0)) {
|
||||||
argb_buf[i][(tileSize*sizescale-y-1)*tileSize*sizescale + x] = bgnight[i];
|
argb_buf[i][(tileSize*sizescale-y-1)*tileSize*sizescale + x] = bgnight[i];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
argb_buf[i][(tileSize*sizescale-y-1)*tileSize*sizescale + x] = c_argb;
|
argb_buf[i][(tileSize*sizescale-y-1)*tileSize*sizescale + x] = c_argb;
|
||||||
}
|
}
|
||||||
if(day_argb_buf[i] != null) {
|
if (day_argb_buf[i] != null) {
|
||||||
shaderstate[i].getRayColor(rslt, 1);
|
shaderstate[i].getRayColor(rslt, 1);
|
||||||
c_argb = rslt.getARGB();
|
c_argb = rslt.getARGB();
|
||||||
if(isjpg[i] && (c_argb == 0)) {
|
if (isOpaque[i] && (c_argb == 0)) {
|
||||||
day_argb_buf[i][(tileSize*sizescale-y-1)*tileSize*sizescale + x] = bgday[i];
|
day_argb_buf[i][(tileSize*sizescale-y-1)*tileSize*sizescale + x] = bgday[i];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user