当前位置:网站首页>VC hacon joint programming genimage3extern writeimage

VC hacon joint programming genimage3extern writeimage

2022-06-12 19:06:00 weixin_ thirty-nine million nine hundred and twenty-six thousan

// In the previous article, I described the joint programming diagram reading , See vc halcon Joint programming configuration ReadImage demo_weixin_39926429 The blog of -CSDN Blog

// This article describes Generate and save pictures To hard disk .

void NewImage(HObject* pHobj)
{
    unsigned char* image_red;
    unsigned char* image_green;
    unsigned char* image_blue;
    int            r, c;
    image_red = (unsigned char*)malloc(640 * 480);
    image_green =( unsigned char*) malloc(640 * 480);
    image_blue = (unsigned char*)malloc(640 * 480);
    for (r = 0; r < 480; r++)
        for (c = 0; c < 640; c++)
        {
            image_red[r * 640 + c] = c % 255;
            image_green[r * 640 + c] = (c + 64) % 255;
            image_blue[r * 640 + c] = (c + 128) % 255;
        }

        //halcon Function to generate a picture
        GenImage3Extern(pHobj, "byte", 640, 480, (Hlong)image_red, \
        (Hlong)image_green, (Hlong)image_blue, (Hlong)free);
}
main()

{   HObject Image;
    NewImage(&Image);
    WriteImage(Image, "bmp", 0, "d:\\test1000.bmp");// Save pictures to hard disk

}

// After the saved picture is opened, it is as follows

 

原网站

版权声明
本文为[weixin_ thirty-nine million nine hundred and twenty-six thousan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206121902371775.html