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

Function SaveDeepEXR

SampleFramework11/v1.02/TinyEXR.cpp:8089–8331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8087}
8088
8089int SaveDeepEXR(const DeepImage *deepImage, const char *filename,
8090 const char **err) {
8091 if (deepImage == NULL || filename == NULL) {
8092 if (err) {
8093 (*err) = "Invalid argument.";
8094 }
8095 return -1;
8096 }
8097
8098 FILE *fp = fopen(filename, "rb");
8099 if (!fp) {
8100 if (err) {
8101 (*err) = "Cannot write file.";
8102 }
8103 return -1;
8104 }
8105
8106 // Write header check.
8107 {
8108 const char header[] = {0x76, 0x2f, 0x31, 0x01};
8109 size_t n = fwrite(header, 1, 4, fp);
8110 if (n != 4) {
8111 if (err) {
8112 (*err) = "Header write failed.";
8113 }
8114 fclose(fp);
8115 return -3;
8116 }
8117 }
8118
8119 // Version, scanline.
8120 {
8121 // ver 2.0, scanline, deep bit on(0x800)
8122 const char data[] = {2, 8, 0, 0};
8123 size_t n = fwrite(data, 1, 4, fp);
8124 if (n != 4) {
8125 if (err) {
8126 (*err) = "Flag write failed.";
8127 }
8128 fclose(fp);
8129 return -3;
8130 }
8131 }
8132
8133 // Write attributes.
8134 {
8135 int data = 2; // ZIPS
8136 WriteAttribute(fp, "compression", "compression",
8137 reinterpret_cast<const unsigned char *>(&data), sizeof(int));
8138 }
8139
8140 {
8141 int data[4] = {0, 0, deepImage->width - 1, deepImage->height - 1};
8142 WriteAttribute(fp, "dataWindow", "box2i",
8143 reinterpret_cast<const unsigned char *>(data),
8144 sizeof(int) * 4);
8145 WriteAttribute(fp, "displayWindow", "box2i",
8146 reinterpret_cast<const unsigned char *>(data),

Callers

nothing calls this directly

Calls 5

WriteAttributeFunction · 0.85
DecompressZipFunction · 0.85
half_to_floatFunction · 0.85
atMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected