MCPcopy Create free account
hub / github.com/OpenPathGuidingLibrary/openpgl / SaveEXRNPartImageToMemory

Function SaveEXRNPartImageToMemory

third-party/tinyexr/tinyexr.h:7603–7981  ·  view source on GitHub ↗

can save a single or multi-part image (no deep* formats)

Source from the content-addressed store, hash-verified

7601
7602// can save a single or multi-part image (no deep* formats)
7603static size_t SaveEXRNPartImageToMemory(const EXRImage* exr_images,
7604 const EXRHeader** exr_headers,
7605 unsigned int num_parts,
7606 unsigned char** memory_out, const char** err) {
7607 if (exr_images == NULL || exr_headers == NULL || num_parts == 0 ||
7608 memory_out == NULL) {
7609 SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory",
7610 err);
7611 return 0;
7612 }
7613 {
7614 for (unsigned int i = 0; i < num_parts; ++i) {
7615 if (exr_headers[i]->compression_type < 0) {
7616 SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory",
7617 err);
7618 return 0;
7619 }
7620#if !TINYEXR_USE_PIZ
7621 if (exr_headers[i]->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) {
7622 SetErrorMessage("PIZ compression is not supported in this build",
7623 err);
7624 return 0;
7625 }
7626#endif
7627 if (exr_headers[i]->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) {
7628#if !TINYEXR_USE_ZFP
7629 SetErrorMessage("ZFP compression is not supported in this build",
7630 err);
7631 return 0;
7632#else
7633 // All channels must be fp32.
7634 // No fp16 support in ZFP atm(as of 2023 June)
7635 // https://github.com/LLNL/fpzip/issues/2
7636 for (int c = 0; c < exr_headers[i]->num_channels; ++c) {
7637 if (exr_headers[i]->requested_pixel_types[c] != TINYEXR_PIXELTYPE_FLOAT) {
7638 SetErrorMessage("Pixel type must be FLOAT for ZFP compression",
7639 err);
7640 return 0;
7641 }
7642 }
7643#endif
7644 }
7645 }
7646 }
7647
7648 std::vector<unsigned char> memory;
7649
7650 // Header
7651 {
7652 const char header[] = { 0x76, 0x2f, 0x31, 0x01 };
7653 memory.insert(memory.end(), header, header + 4);
7654 }
7655
7656 // Version
7657 // using value from the first header
7658 int long_name = exr_headers[0]->long_name;
7659 {
7660 char marker[] = { 2, 0, 0, 0 };

Callers 2

SaveEXRImageToMemoryFunction · 0.85

Calls 13

SetErrorMessageFunction · 0.85
NumScanlinesFunction · 0.85
PrecalculateTileInfoFunction · 0.85
InitTileOffsetsFunction · 0.85
WriteChannelInfoFunction · 0.85
WriteAttributeToMemoryFunction · 0.85
swap4Function · 0.85
EncodeChunkFunction · 0.85
endMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected