correct the scaling of the 5 bit color map types

This commit is contained in:
Bill Currie 2003-03-21 16:18:51 +00:00
parent fa775c6e30
commit 16eac174e6

View file

@ -284,9 +284,9 @@ parse_colormap (TargaHeader *targa, byte **dataByte)
for (i = 0; i < targa->colormap_length; i++, cm++) { for (i = 0; i < targa->colormap_length; i++, cm++) {
word = *data++; word = *data++;
word |= (*data++) << 8; word |= (*data++) << 8;
cm->red = word & 0x1f; cm->red = (word << 3) & 0xf8;
cm->green = (word >> 5) & 0x1f; cm->green = (word >> 2) & 0xf8;
cm->blue = (word >> 10) & 0x1f; cm->blue = (word >> 7) & 0xf8;
cm->alpha = 255; cm->alpha = 255;
} }
break; break;
@ -294,9 +294,9 @@ parse_colormap (TargaHeader *targa, byte **dataByte)
for (i = 0; i < targa->colormap_length; i++, cm++) { for (i = 0; i < targa->colormap_length; i++, cm++) {
word = *data++; word = *data++;
word |= (*data++) << 8; word |= (*data++) << 8;
cm->red = word & 0x1f; cm->red = (word << 3) & 0xf8;
cm->green = (word >> 5) & 0x1f; cm->green = (word >> 2) & 0xf8;
cm->blue = (word >> 10) & 0x1f; cm->blue = (word >> 7) & 0xf8;
cm->alpha = (word & 0x8000) ? 255 : 0; cm->alpha = (word & 0x8000) ? 255 : 0;
} }
break; break;