Fix: Targa with Palette Shows Grayscale in Viewport.

Viewport assumes that when the number of planes of the image
buffer is less or equal to 8 it is a gray scale image. In that
case it will optimize the texture to be stored as a grayscale
image on the GPU.

When using a targa file with a palette, the bitplanes were not
extracted from the actual colors, but from the number of colors
that were present in the palette.

Image buffers don't support palettes so that doesn't make sense.
This PR uses the bitdepth of the actual colors inside the palette
to identify the number of planes to use in the image buffer.

Pull Request: https://projects.blender.org/blender/blender/pulls/106047
This commit is contained in:
Jeroen Bakker
2023-03-24 07:46:33 +01:00
parent a016d142e8
commit 1588f57602

View File

@@ -676,12 +676,7 @@ ImBuf *imb_loadtarga(const uchar *mem, size_t mem_size, int flags, char colorspa
cmap[count] = cp_data;
}
size = 0;
for (int cmap_index = cmap_max - 1; cmap_index > 0; cmap_index >>= 1) {
size++;
}
ibuf->planes = size;
ibuf->planes = tga.mapbits;
if (tga.mapbits != 32) { /* Set alpha bits. */
cmap[0] &= BIG_LONG(0x00ffffffl);
}