MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / LoadEXR

Function LoadEXR

SampleFramework11/v1.02/TinyEXR.cpp:6977–7061  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

LoadMultiChannelEXRFunction · 0.85

Tested by

no test coverage detected