| 6976 | } // namespace |
| 6977 | |
| 6978 | int LoadEXR(float **out_rgba, int *width, int *height, const char *filename, |
| 6979 | const char **err) { |
| 6980 | |
| 6981 | if (out_rgba == NULL) { |
| 6982 | if (*err) { |
| 6983 | (*err) = "Invalid argument.\n"; |
| 6984 | } |
| 6985 | return -1; |
| 6986 | } |
| 6987 | |
| 6988 | EXRImage exrImage; |
| 6989 | int ret = LoadMultiChannelEXR(&exrImage, filename, err); |
| 6990 | if (ret != 0) { |
| 6991 | return ret; |
| 6992 | } |
| 6993 | |
| 6994 | // RGBA |
| 6995 | int idxR = -1; |
| 6996 | int idxG = -1; |
| 6997 | int idxB = -1; |
| 6998 | int idxA = -1; |
| 6999 | for (int c = 0; c < exrImage.num_channels; c++) { |
| 7000 | if (strcmp(exrImage.channel_names[c], "R") == 0) { |
| 7001 | idxR = c; |
| 7002 | } else if (strcmp(exrImage.channel_names[c], "G") == 0) { |
| 7003 | idxG = c; |
| 7004 | } else if (strcmp(exrImage.channel_names[c], "B") == 0) { |
| 7005 | idxB = c; |
| 7006 | } else if (strcmp(exrImage.channel_names[c], "A") == 0) { |
| 7007 | idxA = c; |
| 7008 | } |
| 7009 | } |
| 7010 | |
| 7011 | if (idxR == -1) { |
| 7012 | if (*err) { |
| 7013 | (*err) = "R channel not found\n"; |
| 7014 | } |
| 7015 | |
| 7016 | // @todo { free exrImage } |
| 7017 | return -1; |
| 7018 | } |
| 7019 | |
| 7020 | if (idxG == -1) { |
| 7021 | if (*err) { |
| 7022 | (*err) = "G channel not found\n"; |
| 7023 | } |
| 7024 | // @todo { free exrImage } |
| 7025 | return -1; |
| 7026 | } |
| 7027 | |
| 7028 | if (idxB == -1) { |
| 7029 | if (*err) { |
| 7030 | (*err) = "B channel not found\n"; |
| 7031 | } |
| 7032 | // @todo { free exrImage } |
| 7033 | return -1; |
| 7034 | } |
| 7035 |
nothing calls this directly
no test coverage detected