Worldstone
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
DC6extract.cpp
1 #include <FileStream.h>
2 #include <dc6.h>
3 #include <fmt/format.h>
4 
5 using WorldStone::DC6;
8 
9 int main(int argc, char* argv[])
10 {
11  if (argc == 4) {
12  Palette palette;
13  if (!palette.decode(argv[2])) {
14  fmt::print("Couldn't read the palette file\n");
15  return 1;
16  }
17  DC6 dc6;
18  if (dc6.initDecoder(std::make_unique<FileStream>(argv[1]))) {
19  int frameIndex = 0;
20  for (auto& frameHeader : dc6.getFrameHeaders())
21  {
22  fmt::print("\nframe index {}\n", frameIndex);
23  fmt::print("flip {}\n", frameHeader.flip);
24  fmt::print("width {}\n", frameHeader.width);
25  fmt::print("height {}\n", frameHeader.height);
26  fmt::print("offsetX {}\n", frameHeader.offsetX);
27  fmt::print("offsetY {}\n", frameHeader.offsetY);
28  fmt::print("allocatedSize {}\n", frameHeader.allocSize);
29  fmt::print("nextBlock {}\n", frameHeader.nextBlock);
30  fmt::print("length {}\n", frameHeader.length);
31  }
32  dc6.exportToPPM(argv[3], palette);
33 
34  return 0;
35  }
36  }
37 
38  fmt::print("Usage : DC6extract file.dc6 palette.dat output\n");
39  fmt::print("This tool will extract all frames of dc6 file to output[direction][frame].ppm\n");
40  return 1;
41 }
bool initDecoder(StreamPtr &&streamPtr)
Start decoding the stream and preparing data.
Definition: dc6.cpp:17
Decoder for the DC6 image format.
Definition: dc6.h:39
Wrapper around POSIX file io, same as ifstream but without iostream formatting.
Definition: FileStream.h:16
Helper to load a Diablo 2 palette (.pal/.dat format)
Definition: Palette.h:21