欢迎光临散文网 会员登陆 & 注册

Halcon10-C语言编程

2023-07-02 11:35 作者:Halcom中国  | 我要投稿

#include "HalconC.h"


main()

{

  Hobject   Monkey;

  long      Row,Column,Button;

  long      WindowHandle;

  long      Pointer,Width,Height;

  char      Type[MAX_STRING];

  Herror    err;

  int       i;

 


  (void)printf("-----------------------------\n");

  (void)printf("Example program for HALCON/C:\n");

  (void)printf("-----------------------------\n");

  (void)printf("- read image <monkey>\n");

  (void)printf("- open graphics window\n");

  (void)printf("- display image with zooming\n");

  (void)printf("- program ends by mouse click\n\n");


  (void)printf("Read image file <monkey> ...\n");

  err = read_image(&Monkey,"monkey");

  if (err != H_MSG_TRUE)

  {

    (void)printf("Could not find or open file <monkey>\n");

    (void)printf("Specify HALCONIMAGES to the image directory\n");

    return(1);

  }

  (void)printf("Open the graphics window ...\n");

  (void)get_image_pointer1(Monkey,&Pointer,Type,&Width,&Height);

  (void)open_window(0,0,Width,Height,0,"visible","",&WindowHandle);

  (void)printf("Display the image with zooming ...\n");

  (void)disp_image(Monkey,WindowHandle);

  for (i=255; i>0; i-=2)

  {

    (void)set_part(WindowHandle,255-i,255-i,255+i,255+i);

    (void)disp_image(Monkey,WindowHandle);

  }

  (void)set_part(WindowHandle,0,0,511,511);

  (void)disp_image(Monkey,WindowHandle);

  (void)printf("To quit program: Click with mouse into graphics window ...\n");

  (void)get_mbutton(WindowHandle,&Row,&Column,&Button);

  switch (Button) {

    case 1: 

      (void)printf("-> Left button pressed!\n");

      break;

    case 2: 

      (void)printf("-> Middle button pressed!\n");

      break;

    case 4: 

      (void)printf("-> Right button pressed!\n");

      break;

  }

  (void)printf("-> Mouse position: (row,column) = (%d,%d)\n",Row,Column);


  (void)printf("The End.\n");

  return(0);

}



Halcon10-C语言编程的评论 (共 条)

分享到微博请遵守国家法律