-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestGrayLevelImage2D.cpp
More file actions
55 lines (36 loc) · 1.11 KB
/
testGrayLevelImage2D.cpp
File metadata and controls
55 lines (36 loc) · 1.11 KB
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
//
// Created by Clément.
//
#include <iostream>
#include <fstream>
#include "Image2D.hpp"
#include "Color.hpp"
#include "Image2DWriter.hpp"
#include "Image2DReader.hpp"
int main(int argc, char **argv) {
typedef unsigned char GrayLevel;
typedef Image2D<GrayLevel> GrayLevelImage2D;
typedef GrayLevelImage2D::Iterator Iterator;
typedef GrayLevelImage2D::ConstIterator ConstIterator;
if (argc < 3) {
std::cerr << "Commande : testColor <input.pgm> <output.pgm>" << std::endl;
return 0;
}
GrayLevelImage2D img;
std::ifstream input(argv[1]);
bool ok = Image2DReader<GrayLevel>::read(img, input);
if (!ok) {
std::cerr << "Erreur lors de la lecture du fichier !" << std::endl;
return 1;
}
input.close();
std::cout << "L'import a été réussi !" << std::endl;
std::ofstream output(argv[2]);
bool ok2 = Image2DWriter<GrayLevel>::write(img, output, false);
if (!ok2) {
std::cerr << "Une erreur s'est produite lors de l'écriture du fichier !" << std::endl;
return 1;
}
output.close();
return 0;
}