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

Function LoadMultiChannelEXR

SampleFramework11/v1.02/TinyEXR.cpp:7063–7366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7061}
7062
7063int LoadMultiChannelEXR(EXRImage *exrImage, const char *filename,
7064 const char **err) {
7065 if (exrImage == NULL) {
7066 if (err) {
7067 (*err) = "Invalid argument.";
7068 }
7069 return -1;
7070 }
7071
7072 FILE *fp = fopen(filename, "rb");
7073 if (!fp) {
7074 if (err) {
7075 (*err) = "Cannot read file.";
7076 }
7077 return -1;
7078 }
7079
7080 size_t filesize;
7081 // Compute size
7082 fseek(fp, 0, SEEK_END);
7083 filesize = ftell(fp);
7084 fseek(fp, 0, SEEK_SET);
7085
7086 std::vector<char> buf(filesize); // @todo { use mmap }
7087 {
7088 size_t ret;
7089 ret = fread(&buf[0], 1, filesize, fp);
7090 assert(ret == filesize);
7091 fclose(fp);
7092 }
7093
7094 const char *head = &buf[0];
7095 const char *marker = &buf[0];
7096
7097 // Header check.
7098 {
7099 const char header[] = {0x76, 0x2f, 0x31, 0x01};
7100
7101 if (memcmp(marker, header, 4) != 0) {
7102 if (err) {
7103 (*err) = "Header mismatch.";
7104 }
7105 return -3;
7106 }
7107 marker += 4;
7108 }
7109
7110 // Version, scanline.
7111 {
7112 // must be [2, 0, 0, 0]
7113 if (marker[0] != 2 || marker[1] != 0 || marker[2] != 0 || marker[3] != 0) {
7114 if (err) {
7115 (*err) = "Unsupported version or scanline.";
7116 }
7117 return -4;
7118 }
7119
7120 marker += 4;

Callers 1

LoadEXRFunction · 0.85

Calls 10

ReadAttributeFunction · 0.85
ReadChannelInfoFunction · 0.85
IsBigEndianFunction · 0.85
swap4Function · 0.85
swap8Function · 0.85
DecompressZipFunction · 0.85
swap2Function · 0.85
half_to_floatFunction · 0.85
atMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected