Handle bogus gamma correction on new GRAY texturepack images

This commit is contained in:
Michael Primm 2023-12-22 11:08:10 -06:00
parent 574a400ada
commit 328954b256
1 changed files with 11 additions and 1 deletions

View File

@ -1273,7 +1273,17 @@ public class TexturePack {
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;
}