Hi everyone, I've tried to write code about draw line on picture, but I don't know how can I do.
1. Open picture
2. click many points on picture. For example, point 1 point2 point3 , the point will appear.
3. when you keyC from keyboard. Line will appear like point 1 ---> point 2 ---> point 3 ---> point 1 sth like that
Ps. I use Cimg.h and I don't know how to do, I've tried to read many code but don't understand at all. So I know you can help me, thank you :)
#include <cimg.h>
#include<math.h>
using namespace cimg_library;
int main(){
CImg<unsigned char> img("picture_trial/lion.jpg");
CImgDisplay img2(img,"Display Image");
const unsigned char color[3] = {0,0,255};
while(!img2.is_closed())
{
if(img2.key() == cimg::keyESC)
img2.close();
if(img2.button()&1)
{
img.draw_line(img2.width()/2,img2.height()/2,img2.mouse_x(),img2.mouse_y(),color,1);
img2.display(img);
}
}
}