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

Function SaveEXR

SampleFramework11/v1.02/TinyEXR.cpp:7370–7537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7368// @deprecated
7369#if 0
7370int SaveEXR(const float *in_rgba, int width, int height, const char *filename,
7371 const char **err) {
7372 if (in_rgba == NULL || filename == NULL) {
7373 if (err) {
7374 (*err) = "Invalid argument.";
7375 }
7376 return -1;
7377 }
7378
7379 FILE *fp = fopen(filename, "wb");
7380 if (!fp) {
7381 if (err) {
7382 (*err) = "Cannot write a file.";
7383 }
7384 return -1;
7385 }
7386
7387 // Header
7388 {
7389 const char header[] = {0x76, 0x2f, 0x31, 0x01};
7390 size_t n = fwrite(header, 1, 4, fp);
7391 assert(n == 4);
7392 }
7393
7394 // Version, scanline.
7395 {
7396 const char marker[] = {2, 0, 0, 0};
7397 size_t n = fwrite(marker, 1, 4, fp);
7398 assert(n == 4);
7399 }
7400
7401 int numScanlineBlocks = 16; // 16 for ZIP compression.
7402
7403 // Write attributes.
7404 {
7405 unsigned char data[] = {
7406 'A', 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 'B',
7407 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 'G', 0,
7408 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 'R', 0, 1,
7409 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0}; // last 0 =
7410 // terminator.
7411
7412 WriteAttribute(fp, "channels", "chlist", data, 18 * 4 + 1); // +1 = null
7413 }
7414
7415 {
7416 int compressionType = 3; // ZIP compression
7417 WriteAttribute(fp, "compression", "compression",
7418 reinterpret_cast<const unsigned char *>(&compressionType),
7419 1);
7420 }
7421
7422 {
7423 int data[4] = {0, 0, width - 1, height - 1};
7424 WriteAttribute(fp, "dataWindow", "box2i",
7425 reinterpret_cast<const unsigned char *>(data),
7426 sizeof(int) * 4);
7427 WriteAttribute(fp, "displayWindow", "box2i",

Callers

nothing calls this directly

Calls 8

WriteAttributeFunction · 0.85
float_to_half_fullFunction · 0.85
mz_compressBoundFunction · 0.85
CompressZipFunction · 0.85
atMethod · 0.80
endMethod · 0.80
sizeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected