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

Function WriteChannelInfo

SampleFramework11/v1.02/TinyEXR.cpp:6822–6865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6820}
6821
6822void WriteChannelInfo(std::vector<unsigned char> &data,
6823 const std::vector<ChannelInfo> &channels) {
6824
6825 size_t sz = 0;
6826
6827 // Calculate total size.
6828 for (int c = 0; c < channels.size(); c++) {
6829 sz += strlen(channels[c].name.c_str()) + 1; // +1 for \0
6830 sz += 16; // 4 * int
6831 }
6832 data.resize(sz + 1);
6833
6834 unsigned char *p = &data.at(0);
6835
6836 for (int c = 0; c < channels.size(); c++) {
6837 memcpy(p, channels[c].name.c_str(), strlen(channels[c].name.c_str()));
6838 p += strlen(channels[c].name.c_str());
6839 (*p) = '\0';
6840 p++;
6841
6842 int pixelType = channels[c].pixelType;
6843 int xSampling = channels[c].xSampling;
6844 int ySampling = channels[c].ySampling;
6845 if (IsBigEndian()) {
6846 swap4(reinterpret_cast<unsigned int*>(&pixelType));
6847 swap4(reinterpret_cast<unsigned int*>(&xSampling));
6848 swap4(reinterpret_cast<unsigned int*>(&ySampling));
6849 }
6850
6851 memcpy(p, &pixelType, sizeof(int));
6852 p += sizeof(int);
6853
6854 (*p) = channels[c].pLinear;
6855 p += 4;
6856
6857 memcpy(p, &xSampling, sizeof(int));
6858 p += sizeof(int);
6859
6860 memcpy(p, &ySampling, sizeof(int));
6861 p += sizeof(int);
6862 }
6863
6864 (*p) = '\0';
6865}
6866
6867void CompressZip(unsigned char *dst, unsigned long long &compressedSize,
6868 const unsigned char *src, unsigned long srcSize) {

Callers 1

SaveMultiChannelEXRFunction · 0.85

Calls 5

IsBigEndianFunction · 0.85
swap4Function · 0.85
atMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected