| 1188 | } |
| 1189 | |
| 1190 | static 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 | |
| 1206 | static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) |
| 1207 | { |
no test coverage detected