Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "czi_parser.h"
#include <fstream>
#include "bit_converter.cpp"
CziFile parse_czi_file(std::string file)
{
/*
std::ifstream fileStream = std::ifstream("data/CZT-Stack-Anno.czi", std::ios::binary);
assert(fileStream.is_open());
// Don't read newlines in binary mode??
fileStream.unsetf(std::ios::skipws);
const int readCount = 100;
std::vector<byte> fileHeaderBytes;
fileHeaderBytes.resize(readCount);
auto fileIterator = std::istream_iterator<byte>(fileStream);
for (size_t i = 0; i < readCount; i++)
{
fileHeaderBytes[i] = *fileIterator++;
}
//fileStream.read(reinterpret_cast<char *>(&fileHeaderBytes), 32);
printf("Read %i bytes.\n", ((int)fileHeaderBytes.size()));
SegmentHeader fileSegmentHeader = {};
std::vector<byte> sidBytes(fileHeaderBytes.begin(), fileHeaderBytes.begin() + 16);
fileSegmentHeader.sId = utf8bytes_to_string(fileHeaderBytes, 0, 16); // bytes_to_raw_string(fileHeaderBytes, 0, 16);
fileSegmentHeader.allocatedSize = bytes_to_long(fileHeaderBytes, 16);
fileSegmentHeader.usedSize = bytes_to_long(fileHeaderBytes, 16 + 8);
//std::vector<byte> x_guid(fileHeaderBytes.begin() + SegmentHeaderSize + 16, fileHeaderBytes.begin() + SegmentHeaderSize + 16 + 16);
//std::string utf8text = "\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64";
//std::string decoded = boost::locale::conv::from_utf<char>((char *)x_guid.data(), "utf-8");
std::string guid = utf8bytes_to_string(fileHeaderBytes, SegmentHeaderSize + 16, 16);
std::string guid2 = utf8bytes_to_string(fileHeaderBytes, SegmentHeaderSize + 32, 16);
assert(guid == guid2);
*/
return CziFile();
}