Skip to content

Commit

Permalink
Handle bogus gamma correction on new GRAY texturepack images
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeprimm committed Dec 22, 2023
1 parent 574a400 commit 328954b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,17 @@ private void loadImage(InputStream is, int idx, String fname, String modid) thro
imgs[idx].width = img.getWidth();
imgs[idx].height = img.getHeight();
imgs[idx].argb = new int[imgs[idx].width * imgs[idx].height];
img.getRGB(0, 0, imgs[idx].width, imgs[idx].height, imgs[idx].argb, 0, imgs[idx].width);
if (img.getType() == BufferedImage.TYPE_BYTE_GRAY) { // We don't want alpha correction, apparently
float[] buffer = new float[imgs[idx].width * imgs[idx].height];
img.getData().getPixels(0, 0, imgs[idx].width, imgs[idx].height, buffer);
for (int i = 0; i < imgs[idx].argb.length; i++) {
int v = (int) buffer[i];
imgs[idx].argb[i] = 0xFF000000 | (v << 16) | (v << 8) | v;
}
}
else {
img.getRGB(0, 0, imgs[idx].width, imgs[idx].height, imgs[idx].argb, 0, imgs[idx].width);
}
img.flush();
imgs[idx].isLoaded = true;
}
Expand Down

0 comments on commit 328954b

Please sign in to comment.