Skip to content
Snippets Groups Projects
Commit eaa0bd52 authored by Jean-Marc's avatar Jean-Marc
Browse files

modifs v14

parent df21e7ac
No related branches found
No related tags found
No related merge requests found
Pipeline #188949 failed
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -92,7 +92,7 @@ void Image::ouvrir(const string &filename) ...@@ -92,7 +92,7 @@ void Image::ouvrir(const string &filename)
{ {
ifstream fichier(filename.c_str()); ifstream fichier(filename.c_str());
assert(fichier.is_open()); assert(fichier.is_open());
int r, g, b; unsigned char r, g, b;
string mot; string mot;
dimx = dimy = 0; dimx = dimy = 0;
fichier >> mot >> dimx >> dimy >> mot; fichier >> mot >> dimx >> dimy >> mot;
...@@ -106,9 +106,9 @@ void Image::ouvrir(const string &filename) ...@@ -106,9 +106,9 @@ void Image::ouvrir(const string &filename)
{ {
fichier >> r >> g >> b; fichier >> r >> g >> b;
//cout<<r<<" , "<<g<<" , "<<b<<endl; //cout<<r<<" , "<<g<<" , "<<b<<endl;
getPix(x, y).r = int(r); getPix(x, y).r = r;
getPix(x, y).g = int(g); getPix(x, y).g = g;
getPix(x, y).b = int(b); getPix(x, y).b = b;
} }
fichier.close(); fichier.close();
cout << "Lecture de l'image " << filename << " ... OK\n"; cout << "Lecture de l'image " << filename << " ... OK\n";
...@@ -122,7 +122,7 @@ void Image::afficherConsole() ...@@ -122,7 +122,7 @@ void Image::afficherConsole()
for (unsigned int x = 0; x < dimx; ++x) for (unsigned int x = 0; x < dimx; ++x)
{ {
Pixel &pix = getPix(x, y); Pixel &pix = getPix(x, y);
cout << +pix.r << " " << +pix.g << " " << +pix.b << " "; cout << pix.r << " " << pix.g << " " << pix.b << " ";
} }
cout << endl; cout << endl;
} }
......
...@@ -51,6 +51,8 @@ private: ...@@ -51,6 +51,8 @@ private:
}; };
void sauver(const string &filename) const; void sauver(const string &filename) const;
void ouvrir(const string &filename); void ouvrir(const string &filename);
void afficherConsole(); void afficherConsole();
......
...@@ -14,9 +14,9 @@ Pixel::Pixel(unsigned int x,unsigned int y, unsigned int z) ...@@ -14,9 +14,9 @@ Pixel::Pixel(unsigned int x,unsigned int y, unsigned int z)
assert(x>=0 && x<=255); assert(x>=0 && x<=255);
assert(y>=0 && y<=255); assert(y>=0 && y<=255);
assert(z>=0 && z<=255); assert(z>=0 && z<=255);
r = x; r = char(x);
g = y; g = char(y);
b = z; b = char(z);
} }
Pixel Pixel::operator=(Pixel p) Pixel Pixel::operator=(Pixel p)
......
...@@ -4,13 +4,14 @@ ...@@ -4,13 +4,14 @@
class Pixel class Pixel
{ {
public : public :
unsigned int r; unsigned char r;
unsigned int g; unsigned char g;
unsigned int b; unsigned char b;
Pixel(); Pixel();
Pixel(unsigned ro, unsigned int ve, unsigned int bl); Pixel(unsigned int ro, unsigned int ve, unsigned int bl);
Pixel operator=(Pixel p); Pixel operator=(Pixel p);
}; };
#endif #endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment