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

Function SaveEXR

SampleFramework12/v1.00/TinyEXR.cpp:7371–7538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected