Skip to content

Commit 328954b

Browse files
committed
Handle bogus gamma correction on new GRAY texturepack images
1 parent 574a400 commit 328954b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,17 @@ private void loadImage(InputStream is, int idx, String fname, String modid) thro
12731273
imgs[idx].width = img.getWidth();
12741274
imgs[idx].height = img.getHeight();
12751275
imgs[idx].argb = new int[imgs[idx].width * imgs[idx].height];
1276-
img.getRGB(0, 0, imgs[idx].width, imgs[idx].height, imgs[idx].argb, 0, imgs[idx].width);
1276+
if (img.getType() == BufferedImage.TYPE_BYTE_GRAY) { // We don't want alpha correction, apparently
1277+
float[] buffer = new float[imgs[idx].width * imgs[idx].height];
1278+
img.getData().getPixels(0, 0, imgs[idx].width, imgs[idx].height, buffer);
1279+
for (int i = 0; i < imgs[idx].argb.length; i++) {
1280+
int v = (int) buffer[i];
1281+
imgs[idx].argb[i] = 0xFF000000 | (v << 16) | (v << 8) | v;
1282+
}
1283+
}
1284+
else {
1285+
img.getRGB(0, 0, imgs[idx].width, imgs[idx].height, imgs[idx].argb, 0, imgs[idx].width);
1286+
}
12771287
img.flush();
12781288
imgs[idx].isLoaded = true;
12791289
}

0 commit comments

Comments
 (0)