| 1258 | #endif |
| 1259 | |
| 1260 | static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) |
| 1261 | { |
| 1262 | stbi__result_info ri; |
| 1263 | void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); |
| 1264 | |
| 1265 | if (result == NULL) |
| 1266 | return NULL; |
| 1267 | |
| 1268 | // it is the responsibility of the loaders to make sure we get either 8 or 16 bit. |
| 1269 | STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16); |
| 1270 | |
| 1271 | if (ri.bits_per_channel != 8) { |
| 1272 | result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp); |
| 1273 | ri.bits_per_channel = 8; |
| 1274 | } |
| 1275 | |
| 1276 | // @TODO: move stbi__convert_format to here |
| 1277 | |
| 1278 | if (stbi__vertically_flip_on_load) { |
| 1279 | int channels = req_comp ? req_comp : *comp; |
| 1280 | stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); |
| 1281 | } |
| 1282 | |
| 1283 | return (unsigned char *) result; |
| 1284 | } |
| 1285 | |
| 1286 | static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) |
| 1287 | { |
no test coverage detected