0

My question in brief:

I have many coordinates points(x,y) which needs to be drawn and saved as a picture in a folder. I need to write codes using C++.

Detailed Explanation:

Let's say i have n coordinate points(x ,y). I have two functions namely the "jump" and the "mark".

The function call would be in this sequence always:

jump(x,y)

mark(x,y)

jump(x,y)

mark(x,y)

..............this sequence happens till all coordinate points are considered finished.

1)The first Jump function will point to the current coordinate position/start position.

2)All mark functions would draw a continuous line from the previous jump function coordinates to the the coordinates it received.

3)Rest of the jump functions(except the first jump function) would draw a dotted line/dashed line from the previous mark coordinates till the coordinates it received. So this line would tell us from where did the jump function jumped to draw the next mark line(Refer attached Picture for better clarity)

How do i implement it? Any graphic libraries in C++ available to perform simple plotting and saving of an image like i wanted?

I read about few graphics libraries like SDL, OpenCV, OpenGL, PNGWriter. But not sure what and how to use.

I have shown a small example of what i wanted to do, which is attached as an image. Click here for the Image

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Ramanan
  • 79
  • 1
  • 9
  • 1
    `SDL, OpenCV, OpenGL` are not what you want. Look at libpng. As soon as you can save a raw pixel value array as image file, the plotting part is easy. – deviantfan Jun 10 '16 at 12:35

2 Answers2

0

I work with opencv, but it not support dash line while in this link there is a guide for dash line in opencv dotted line and dotted and dashed rectangle in OpenCV, for your program, you can create an white image with desired size and draw line by charactrize the start and end point coordinate and apply function: Line draw You can store the latest point's coordinate in a Point variable....

Community
  • 1
  • 1
opencv train
  • 29
  • 2
  • 13
0

I suggest you use the Allegro, it's much more simple and lighter than OpenCV. I believe it will be more agile for this. This link you can find the binaries (~44MB) for VS (select the appropriate for your vesrion).

Extract the zip file. You will see the include\, lib\ and bin\ directories. Link them appropriately in Visual Studio (this is the complete tutorial).

Here you will have the basics of reading, writing and displaying an image (Bitmaps).

I think the function al_draw_line() will help you on this specific task.

douglasjfm
  • 54
  • 6