read 16bit value and convert to 24bit RGB
| 5850 | |
| 5851 | // read 16bit value and convert to 24bit RGB |
| 5852 | static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) |
| 5853 | { |
| 5854 | stbi__uint16 px = (stbi__uint16)stbi__get16le(s); |
| 5855 | stbi__uint16 fiveBitMask = 31; |
| 5856 | // we have 3 channels with 5bits each |
| 5857 | int r = (px >> 10) & fiveBitMask; |
| 5858 | int g = (px >> 5) & fiveBitMask; |
| 5859 | int b = px & fiveBitMask; |
| 5860 | // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later |
| 5861 | out[0] = (stbi_uc)((r * 255)/31); |
| 5862 | out[1] = (stbi_uc)((g * 255)/31); |
| 5863 | out[2] = (stbi_uc)((b * 255)/31); |
| 5864 | |
| 5865 | // some people claim that the most significant bit might be used for alpha |
| 5866 | // (possibly if an alpha-bit is set in the "image descriptor byte") |
| 5867 | // but that only made 16bit test images completely translucent.. |
| 5868 | // so let's treat all 15 and 16bit TGAs as RGB with no alpha. |
| 5869 | } |
| 5870 | |
| 5871 | static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) |
| 5872 | { |
no test coverage detected