Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing lines with boost::gil? [closed]

I need to draw some lines on an (off-screen) image. I'd like to use boost::gil because the lib is already integrated in my project.

I want to draw a line from start to end point in a 2dim array

Can anybody give me a quick example how to draw a line using gil?

Thank you.

like image 813
anhoppe Avatar asked Oct 21 '22 18:10

anhoppe


1 Answers

GIL itself is very much concerned with storage of images and pixels in various formats and converting between them... but no more than that. user1929959's answer is using a GIL extension which facilitates interoperability of GIL with OpenCV and then uses OpenCV's line drawing (but OpenCV doesn't come with boost so you'd need to add that into your project too).

For high quality antialiased line drawing AGG and Cairo might also be worth considering (although you'd need to figure out how best adapt GIL images to their own image buffer types). But if you just want basic one pixel wide lines, consult any basic computer graphics text for some Bresenham's line algorithm pseudocode which could be trivially implemented using pixel-setting.

like image 103
timday Avatar answered Oct 30 '22 22:10

timday