All pastes #776206 Raw Edit

Untitled

public text v1 · immutable
·published 2007-11-15 22:54 UTC
rendered paste body
#include <iostream>
#include <fstream>
using namespace std;

const int MAX = 1000;
const int N = 50;
int IMG[MAX][MAX];

void chargerImage(char fichier[N], int&l, int &h)
{
     char identifiant[N];
     int niveaux;
     
     ifstream fin(fichier);
     fin >> identifiant;
     fin >> l;
     fin >> h;
     fin >> niveaux;
     for(int i = 0; i < h; i++)
        for(int j = 0; j < l; j++)
          fin >> IMG[i][j];
}   

void ecrireImage(char fichier[N], int l, int h)
{  
   ofstream fout(fichier);
   fout << "P2" << endl;
   fout << l << " " << h << endl;
   fout << "255" << endl;
   for(int i = 0; i < h; i++)
   {
        fout << IMG[i][0];
        for(int j = 1; j < l; j++)
            fout << " " << IMG[i][j];
        fout << endl;
   }       
}     
  
int main()
{
  int l, h;
  chargerImage("hippo.pgm",l,h);
  ecrireImage("hippo1.pgm",l,h);
  cin >> l;
}