MCPcopy Create free account
hub / github.com/RenderKit/embree / SaveEXRNPartImageToMemory

Function SaveEXRNPartImageToMemory

tutorials/common/image/tinyexr.h:7692–8070  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

7690
7691// can save a single or multi-part image (no deep* formats)
7692static size_t SaveEXRNPartImageToMemory(const EXRImage* exr_images,
7693 const EXRHeader** exr_headers,
7694 unsigned int num_parts,
7695 unsigned char** memory_out, const char** err) {
7696 if (exr_images == NULL || exr_headers == NULL || num_parts == 0 ||
7697 memory_out == NULL) {
7698 SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory",
7699 err);
7700 return 0;
7701 }
7702 {
7703 for (unsigned int i = 0; i < num_parts; ++i) {
7704 if (exr_headers[i]->compression_type < 0) {
7705 SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory",
7706 err);
7707 return 0;
7708 }
7709#if !TINYEXR_USE_PIZ
7710 if (exr_headers[i]->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) {
7711 SetErrorMessage("PIZ compression is not supported in this build",
7712 err);
7713 return 0;
7714 }
7715#endif
7716 if (exr_headers[i]->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) {
7717#if !TINYEXR_USE_ZFP
7718 SetErrorMessage("ZFP compression is not supported in this build",
7719 err);
7720 return 0;
7721#else
7722 // All channels must be fp32.
7723 // No fp16 support in ZFP atm(as of 2023 June)
7724 // https://github.com/LLNL/fpzip/issues/2
7725 for (int c = 0; c < exr_headers[i]->num_channels; ++c) {
7726 if (exr_headers[i]->requested_pixel_types[c] != TINYEXR_PIXELTYPE_FLOAT) {
7727 SetErrorMessage("Pixel type must be FLOAT for ZFP compression",
7728 err);
7729 return 0;
7730 }
7731 }
7732#endif
7733 }
7734 }
7735 }
7736
7737 std::vector<unsigned char> memory;
7738
7739 // Header
7740 {
7741 const char header[] = { 0x76, 0x2f, 0x31, 0x01 };
7742 memory.insert(memory.end(), header, header + 4);
7743 }
7744
7745 // Version
7746 // using value from the first header
7747 int long_name = exr_headers[0]->long_name;
7748 {
7749 char marker[] = { 2, 0, 0, 0 };

Callers 2

SaveEXRImageToMemoryFunction · 0.85

Calls 15

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

Tested by

no test coverage detected