| 6820 | } |
| 6821 | |
| 6822 | void 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 | |
| 6867 | void CompressZip(unsigned char *dst, unsigned long long &compressedSize, |
| 6868 | const unsigned char *src, unsigned long srcSize) { |
no test coverage detected