MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__tga_read_rgb16

Function stbi__tga_read_rgb16

include/stb/stb_image.h:5852–5869  ·  view source on GitHub ↗

read 16bit value and convert to 24bit RGB

Source from the content-addressed store, hash-verified

5850
5851// read 16bit value and convert to 24bit RGB
5852static 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
5871static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
5872{

Callers 1

stbi__tga_loadFunction · 0.85

Calls 1

stbi__get16leFunction · 0.85

Tested by

no test coverage detected