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

Function stbi__convert_16_to_8

include/stb/stb_image.h:1190–1204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1188}
1189
1190static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels)
1191{
1192 int i;
1193 int img_len = w * h * channels;
1194 stbi_uc *reduced;
1195
1196 reduced = (stbi_uc *) stbi__malloc(img_len);
1197 if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory");
1198
1199 for (i = 0; i < img_len; ++i)
1200 reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling
1201
1202 STBI_FREE(orig);
1203 return reduced;
1204}
1205
1206static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels)
1207{

Callers 1

Calls 1

stbi__mallocFunction · 0.85

Tested by

no test coverage detected