| 1205 | } |
| 1206 | |
| 1207 | static stbi_uc* stbi__convert_16_to_8(stbi__uint16* orig, int w, int h, int channels) { |
| 1208 | int i; |
| 1209 | int img_len = w * h * channels; |
| 1210 | stbi_uc* reduced; |
| 1211 | |
| 1212 | reduced = (stbi_uc*)stbi__malloc(img_len); |
| 1213 | if (reduced == NULL) |
| 1214 | return stbi__errpuc("outofmem", "Out of memory"); |
| 1215 | |
| 1216 | for (i = 0; i < img_len; ++i) |
| 1217 | reduced[i] = |
| 1218 | (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient |
| 1219 | // approx of 16->8 bit scaling |
| 1220 | |
| 1221 | STBI_FREE(orig); |
| 1222 | return reduced; |
| 1223 | } |
| 1224 | |
| 1225 | static stbi__uint16* stbi__convert_8_to_16(stbi_uc* orig, int w, int h, int channels) { |
| 1226 | int i; |
no test coverage detected