MCPcopy Create free account
hub / github.com/RenderKit/embree / LoadEXRWithLayer

Function LoadEXRWithLayer

tutorials/common/image/tinyexr.h:6269–6515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6267}
6268
6269int LoadEXRWithLayer(float **out_rgba, int *width, int *height,
6270 const char *filename, const char *layername,
6271 const char **err) {
6272 if (out_rgba == NULL) {
6273 tinyexr::SetErrorMessage("Invalid argument for LoadEXR()", err);
6274 return TINYEXR_ERROR_INVALID_ARGUMENT;
6275 }
6276
6277 EXRVersion exr_version;
6278 EXRImage exr_image;
6279 EXRHeader exr_header;
6280 InitEXRHeader(&exr_header);
6281 InitEXRImage(&exr_image);
6282
6283 {
6284 int ret = ParseEXRVersionFromFile(&exr_version, filename);
6285 if (ret != TINYEXR_SUCCESS) {
6286 std::stringstream ss;
6287 ss << "Failed to open EXR file or read version info from EXR file. code("
6288 << ret << ")";
6289 tinyexr::SetErrorMessage(ss.str(), err);
6290 return ret;
6291 }
6292
6293 if (exr_version.multipart || exr_version.non_image) {
6294 tinyexr::SetErrorMessage(
6295 "Loading multipart or DeepImage is not supported in LoadEXR() API",
6296 err);
6297 return TINYEXR_ERROR_INVALID_DATA; // @fixme.
6298 }
6299 }
6300
6301 {
6302 int ret = ParseEXRHeaderFromFile(&exr_header, &exr_version, filename, err);
6303 if (ret != TINYEXR_SUCCESS) {
6304 FreeEXRHeader(&exr_header);
6305 return ret;
6306 }
6307 }
6308
6309 // Read HALF channel as FLOAT.
6310 for (int i = 0; i < exr_header.num_channels; i++) {
6311 if (exr_header.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) {
6312 exr_header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT;
6313 }
6314 }
6315
6316 // TODO: Probably limit loading to layers (channels) selected by layer index
6317 {
6318 int ret = LoadEXRImageFromFile(&exr_image, &exr_header, filename, err);
6319 if (ret != TINYEXR_SUCCESS) {
6320 FreeEXRHeader(&exr_header);
6321 return ret;
6322 }
6323 }
6324
6325 // RGBA
6326 int idxR = -1;

Callers 1

LoadEXRFunction · 0.85

Calls 13

SetErrorMessageFunction · 0.85
InitEXRHeaderFunction · 0.85
InitEXRImageFunction · 0.85
ParseEXRVersionFromFileFunction · 0.85
ParseEXRHeaderFromFileFunction · 0.85
FreeEXRHeaderFunction · 0.85
LoadEXRImageFromFileFunction · 0.85
GetLayersFunction · 0.85
ChannelsInLayerFunction · 0.85
FreeEXRImageFunction · 0.85
mallocFunction · 0.85
strMethod · 0.45

Tested by

no test coverage detected