INFO702 - TPs
Loading...
Searching...
No Matches
double-brightness.cpp
1// double-brightness.cpp
2#include <iostream>
3#include <fstream>
4#include "GrayLevelImage2D.hpp"
5
6using namespace std;
7
8int main( int argc, char** argv )
9{
10 typedef GrayLevelImage2D::GrayLevel GrayLevel;
11 typedef GrayLevelImage2D::Iterator Iterator;
12 if ( argc < 3 )
13 {
14 std::cerr << "Usage: double-brightness <input.pgm> <output.pgm>" << std::endl;
15 return 0;
16 }
18 ifstream input( argv[1] ); // récupère le 1er argument.
19 bool ok = img.importPGM( input );
20 if ( !ok )
21 {
22 std::cerr << "Error reading input file." << std::endl;
23 return 1;
24 }
25 input.close();
26 for ( Iterator it = img.begin(), itE = img.end(); it != itE; ++it )
27 {
28 *it = ( 2 * (int)(*it) ) % 256;
29 }
30 ofstream output( argv[2] ); // récupère le 2ème argument.
31 ok = img.exportPGM( output, false );
32 if ( !ok )
33 {
34 std::cerr << "Error writing output file." << std::endl;
35 return 1;
36 }
37 output.close();
38 return 0;
39}
Iterator begin()
[gli2d-sec3]