Skip to content

Commit

Permalink
Fix when X11 nor GDI are available
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Aug 30, 2023
1 parent 0309b24 commit c64766c
Showing 1 changed file with 51 additions and 42 deletions.
93 changes: 51 additions & 42 deletions tutorial/image/tutorial-draw-circle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,66 @@
int main()
{
vpImage<unsigned char> I(2160, 3840, 128);
vpImage<vpRGBa> I_rgb(2160, 3840, vpColor(0, 0, 0));

try {

{
#if defined(VISP_HAVE_X11)
vpDisplayX d(I, vpDisplay::SCALE_AUTO);
vpDisplayX d(I, vpDisplay::SCALE_AUTO);
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI d(I, vpDisplay::SCALE_AUTO);
vpDisplayGDI d(I, vpDisplay::SCALE_AUTO);
#endif

vpDisplay::setTitle(I, "My image");
vpDisplay::display(I);
//! [Circle display]
vpImageCircle circle(vpImagePoint(I.getHeight()/3, I.getWidth()/3), I.getWidth()/10);
// Displays in overlay a red circle on the image
// i.e. does not modify I
vpDisplay::displayCircle(I, circle, vpColor::red, 2);
//! [Circle display]
vpDisplay::flush(I);
vpDisplay::setTitle(I, "Overlay");
std::cout << "Result of displaying a red circle on overlay on the display..." << std::endl;
std::cout << "A click to continue..." << std::endl;
vpDisplay::getClick(I);
vpDisplay::setTitle(I, "Gray image");
vpDisplay::display(I);
//! [Circle display]
vpImageCircle circle(vpImagePoint(I.getHeight()/3, I.getWidth()/3), I.getWidth()/10);
// Displays in overlay a red circle on the image
// i.e. does not modify I
vpDisplay::displayCircle(I, circle, vpColor::red, 2);
//! [Circle display]
vpDisplay::flush(I);
vpDisplay::setTitle(I, "Overlay");
std::cout << "Result of displaying a red circle on overlay on the display..." << std::endl;
std::cout << "A click to continue..." << std::endl;
vpDisplay::getClick(I);

//! [Circle draw uchar]
vpImageCircle circle2(vpImagePoint(I.getHeight()/3, 2*I.getWidth()/3), I.getWidth()/10);
// Draws a white circle on the image
// i.e. modifies I
vpImageDraw::drawCircle(I, circle2, 255, 2);
//! [Circle draw uchar]
vpDisplay::display(I);
vpDisplay::flush(I);
vpDisplay::setTitle(I, "Modification of a uchar image");
std::cout << "Result of the modification of a uchar image..." << std::endl;
std::cout << "A click to continue..." << std::endl;
vpDisplay::getClick(I);
}

//! [Circle draw uchar]
vpImageCircle circle2(vpImagePoint(I.getHeight()/3, 2*I.getWidth()/3), I.getWidth()/10);
// Draws a white circle on the image
// i.e. modifies I
vpImageDraw::drawCircle(I, circle2, 255, 2);
//! [Circle draw uchar]
vpDisplay::display(I);
vpDisplay::flush(I);
vpDisplay::setTitle(I, "Modification of a uchar image");
std::cout << "Result of the modification of a uchar image..." << std::endl;
std::cout << "A click to continue..." << std::endl;
vpDisplay::getClick(I);
{
//! [Circle draw color]
vpImageCircle circle3(vpImagePoint(2*I.getHeight()/3, I.getWidth()/2), I.getWidth()/10);
// Draws a blue circle on the image
// i.e. modifies I_rgb
vpImageDraw::drawCircle(I_rgb, circle3, vpColor::blue, 2);
//! [Circle draw color]

vpImage<vpRGBa> Irgb(2160, 3840, vpColor(0, 0, 0));
//! [Circle draw color]
vpImageCircle circle3(vpImagePoint(2*I.getHeight()/3, I.getWidth()/2), I.getWidth()/10);
// Draws a blue circle on the image
// i.e. modifies Irgb
vpImageDraw::drawCircle(Irgb, circle3, vpColor::blue, 2);
//! [Circle draw color]
d.init(Irgb);
vpDisplay::display(Irgb);
vpDisplay::flush(Irgb);
vpDisplay::setTitle(I, "Modification of a vpRGBa image");
std::cout << "Result of the modification of a vpRGBa image..." << std::endl;
std::cout << "A click to continue..." << std::endl;
vpDisplay::getClick(Irgb);
#if defined(VISP_HAVE_X11)
vpDisplayX d_rgb(I_rgb, vpDisplay::SCALE_AUTO);
#elif defined(VISP_HAVE_GDI)
vpDisplayGDI d_rgb(I_rgb, vpDisplay::SCALE_AUTO);
#endif

vpDisplay::setTitle(I_rgb, "Color image");
vpDisplay::display(I_rgb);
vpDisplay::flush(I_rgb);
vpDisplay::setTitle(I, "Modification of a vpRGBa image");
std::cout << "Result of the modification of a vpRGBa image..." << std::endl;
std::cout << "A click to continue..." << std::endl;
vpDisplay::getClick(I_rgb);
}
}
catch (const vpException &e) {
std::cout << "Catch an exception: " << e.getMessage() << std::endl;
Expand Down

0 comments on commit c64766c

Please sign in to comment.