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

erreur tab3

parent 20495edb
No related branches found
No related tags found
No related merge requests found
Pipeline #190193 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
......@@ -8,6 +8,7 @@ using namespace std;
Image::Image()
{
tab = nullptr;
cout<<"tab cons : "<<tab<<endl;
dimx = 0;
dimy = 0;
}
......@@ -19,6 +20,7 @@ Image::Image(unsigned int x, unsigned int y)
dimx = x;
dimy = y;
tab = new Pixel [dimx*dimy];
cout<<"tab cons2 : "<<tab<<endl;
}
Image::~Image()
......@@ -27,6 +29,7 @@ Image::~Image()
dimy = 0;
delete [] tab;
tab = nullptr;
cout<<"tab dest : "<<tab<<endl;
}
......@@ -34,7 +37,7 @@ Pixel & Image::getPix(unsigned int x, unsigned int y) const
{
assert (x>=0 && y>=0);
return tab[y*dimx+x];;
return tab[y*dimx+x];
}
Pixel Image::getPix2(unsigned int x, unsigned int y) const
......
......@@ -32,30 +32,30 @@ private:
Pixel p2(10,20,30);
Image im(50,50);
p = im.getPix2(20,26);
cout<<int(p.r)<<endl;
p = im.getPix(20,26);
cout<<"expecting 0 : "<<int(p.r)<<endl;
cout<<endl;
Image im2;
cout<<"dim im2 : "<<im2.dimx<<" , "<<im2.dimy<<endl;
cout<<endl;
im.setPix(27,12,p2);
Pixel p3 = im.getPix2(27,12);
cout<<int(p3.r)<<","<<int(p3.g)<<","<<int(p3.b)<<endl;
cout<<"expecting 10 20 30: "<<int(p3.r)<<","<<int(p3.g)<<","<<int(p3.b)<<endl;
cout<<endl;
im.dessinerRectangle(10,10,30,30,Pixel(78,36,108));
Pixel p4 = im.getPix2(15,20);
cout<<int(p4.r)<<","<<int(p4.g)<<","<<int(p4.b)<<endl;
cout<<"expecting 78 36 108: "<<int(p4.r)<<","<<int(p4.g)<<","<<int(p4.b)<<endl;
cout<<endl;
im.effacer(Pixel(0,0,0));
p4 = im.getPix2(18,25);
cout<<int(p4.r)<<","<<int(p4.g)<<","<<int(p4.b)<<endl;
im.~Image();
};
cout<<"expecting 0 0 0: "<<int(p4.r)<<","<<int(p4.g)<<","<<int(p4.b)<<endl;
//im.~Image();
}
};
......
......@@ -4,9 +4,9 @@
Pixel::Pixel()
{
r = char(0);
g = char(0);
b = char(0);
r = 0;
g = 0;
b = 0;
}
Pixel::Pixel(unsigned int x,unsigned int y, unsigned int z)
......@@ -21,9 +21,9 @@ Pixel::Pixel(unsigned int x,unsigned int y, unsigned int z)
Pixel Pixel::operator=(Pixel p)
{
r = p.r;
g = p.g;
b = p.b;
r = char(p.r);
g = char(p.g);
b = char(p.b);
return *this;
}
......
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