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 46 47 48 49 50 51 52 53 54 55 56 57 58 59
   | #include <iostream>
#include <string>
#include <fstream>
#include <new>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include "read_header.h"
 
using namespace std;
 
void initialize(std::size_t size_tabA, std::size_t size_tabB);
 
template <typename T>
 
void initialize(std::size_t size_tabA, std::size_t size_tabB)
{
  T* tabA = new T[size_tabA];
  T* tabB = new T[size_tabB];
}
 
int main(int argc, char *argv[])
{
  string file_in;
 
  long int TYPE, nbheadA, px_i, px_j, px_k;
  string og;
 
  file_in=argv[1];
  read_header(file_in, &TYPE, &nbheadA, &px_i, &px_j, &px_k, &og);
  if (px_k != 1 && og != "jhd") exit (-1);
 
  unsigned long int size_tabA=px_i*nbheadA;
  unsigned long int size_tabB=px_i*px_j;
//*******************************************************************************
//Ouverture du fichier en lecture
  ifstream fichier(file_in.c_str(), ios::in);
  if(!fichier.is_open()) exit (-1);
//*******************************************************************************
  switch(TYPE) 
  {
    case 1:
      initialize<unsigned char>(size_tabA,size_tabB);
      fichier.read(reinterpret_cast<unsigned char*>(*tabA),size_tabA*sizeof(unsigned char));
      fichier.read(reinterpret_cast<unsigned char*>(*tabB),size_tabB*sizeof(unsigned char));
      break;
 
    case 2:
      initialize<unsigned short int>(size_tabA,size_tabB);
      fichier.read(reinterpret_cast<unsigned short int*>(*tabA),size_tabA*sizeof(unsigned short int));
      fichier.read(reinterpret_cast<unsigned short int*>(*tabB),size_tabB*sizeof(unsigned short int));
      break;
  }
  fichier.close();
  delete[] tabA;
  delete[] tabB;
  return (0);
} | 
Partager