| 1416 | } |
| 1417 | |
| 1418 | unsigned convertRGBModel(unsigned char* out, const unsigned char* in, |
| 1419 | unsigned w, unsigned h, |
| 1420 | const LodePNGState* state_out, |
| 1421 | const LodePNGState* state_in, |
| 1422 | unsigned rendering_intent) { |
| 1423 | if(modelsEqual(state_in, state_out)) { |
| 1424 | return lodepng_convert(out, in, &state_out->info_raw, &state_in->info_raw, w, h); |
| 1425 | } else { |
| 1426 | unsigned error = 0; |
| 1427 | size_t n, bytes; |
| 1428 | if(lodepng_mulofl((size_t)w, (size_t)h, &n)) return 92; |
| 1429 | if(lodepng_mulofl(n, 4 * sizeof(float), &bytes)) return 92; |
| 1430 | float* xyz = (float*)lodepng_malloc(bytes); |
| 1431 | float whitepoint[3]; |
| 1432 | error = convertToXYZ(xyz, whitepoint, in, w, h, state_in); |
| 1433 | if (!error) error = convertFromXYZ(out, xyz, w, h, state_out, whitepoint, rendering_intent); |
| 1434 | lodepng_free(xyz); |
| 1435 | return error; |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | unsigned convertToSrgb(unsigned char* out, const unsigned char* in, |
| 1440 | unsigned w, unsigned h, |