Advertisement
wandrake

Untitled

Nov 24th, 2014
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.58 KB | None | 0 0
  1. #include <fstream>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6. using namespace System;
  7. using namespace System::Drawing;
  8.  
  9. typedef struct pixel_t {
  10.     unsigned char r, g, b;
  11. } pixel_t;
  12.  
  13. #define COSE 9
  14.  
  15. int sizes[COSE][2] = {
  16.         {64, 768},
  17.         {64, 128},
  18.         {256, 32},
  19.         {256, 32},
  20.         {256, 32},
  21.         {256, 32},
  22.         {256, 64},
  23.         {256, 96},
  24.         {800, 600},
  25. };
  26.  
  27. typedef struct roba_t {
  28.     char unk1[4];
  29.     int size;
  30.     char unk2[71];
  31.     int dsize;
  32.     pixel_t* cose[COSE];
  33.     struct roba_t() {
  34.         cout << "Robo?" << endl;
  35.         for (int i = 0; i < COSE; ++i) {
  36.             this->cose[i] = new pixel_t[sizes[i][0] * sizes[i][1]];
  37.         }
  38.         cout << "Robo!" << cose[0]<<  endl;
  39.     }
  40. } roba_t;
  41.  
  42. roba_t* readFile(string fname) {
  43.     roba_t* ret = new roba_t;
  44.     ifstream f;
  45.     const char* fc = fname.c_str();
  46.     f.open(fc, ios::binary);
  47.     f.read(ret->unk1, 4);
  48.     f.read((char*)&ret->size, 4);
  49.     cout << "Data size: " << ret->size << endl;
  50.     f.read(ret->unk2, 72);
  51.     cout << ret->cose[0] << endl;
  52.     f.read((char*)ret->cose[0], sizes[0][0] * sizes[0][1] * 3);
  53.     cout << "OK" << endl;
  54.     f.read((char*)ret->cose[1], sizes[1][0] * sizes[1][1] * 3);
  55.     f.seekg(1, ios::cur);
  56.     f.read((char*)ret->cose[2], sizes[2][0] * sizes[2][1] * 3);
  57.     f.seekg(67, ios::cur);
  58.     f.read((char*)ret->cose[3], sizes[3][0] * sizes[3][1] * 3);
  59.     f.read((char*)ret->cose[4], sizes[4][0] * sizes[4][1] * 3);
  60.     f.read((char*)ret->cose[5], sizes[5][0] * sizes[5][1] * 3);
  61.     f.read((char*)ret->cose[6], sizes[6][0] * sizes[6][1] * 3);
  62.     f.read((char*)ret->cose[7], sizes[7][0] * sizes[7][1] * 3);
  63.     f.seekg(128 * 6 + 108 * 3, ios::cur);
  64.     for (int i = 0; i < sizes[8][1]; ++i) {
  65.         f.read((char*)&ret->cose[8][i*sizes[8][0]], sizes[8][0] * 3);
  66.         f.seekg(5, ios::cur);
  67.     }
  68.     return ret;
  69. }
  70.  
  71. void printabitta(System::String ^fname, pixel_t* data, int w, int h) {
  72.     cout << "Printabitto " << endl;
  73.     Bitmap b(w, h);
  74.     for (int i = 0; i < h; ++i) {
  75.         for (int j = 0; j < w; ++j) {
  76.             pixel_t* p = &data[i*w + j];
  77.             b.SetPixel(j, h-i-1, Color::FromArgb(p->r, p->g, p->b));
  78.         }
  79.     }
  80.     b.Save(fname);
  81. }
  82.  
  83. int main(int argc, char* argv[]) {
  84.     roba_t* r = readFile("D:\\Desktop\\Disney Interactive\\Toy Story 2\\data\\gfx\\bonus.ngn");
  85.  
  86.     for (int i = 0; i < COSE; ++i) {
  87.         printabitta("roba" + System::Convert::ToString(i+1) + ".bmp", r->cose[i], sizes[i][0], sizes[i][1]);
  88.     }
  89.     char c;
  90.     cin >> c;
  91.     return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement