halcon源码如下
*8位图转24位图
*读取8位图
read_image (Image, 'D:/org_R1.jpg')
get_image_pointer1 (Image, Pointer, Type, Width, Height)
*生成24位图
gen_image3 (ImageRGB, 'byte', Width, Height, Pointer, Pointer, Pointer)
C++源码如下:
//图像属性
HObject ho_Image3;
HTuple hv_Pointer;
HTuple hv_Type;
HTuple hv_Width;
HTuple hv_Height;
//生成24位的图像文件
GetImagePointer1(ho_Image1, &hv_Pointer, &hv_Type, &hv_Width, &hv_Height);
GenImage3(&ho_Image3, "byte", hv_Width, hv_Height, hv_Pointer, hv_Pointer, hv_Pointer);
C源码如下:
void NewRGBImage(Hobject *new)
{
unsigned char red[768*525];
unsigned char green[768*525];
unsigned char blue[768*525];
int r,c;
for (r=0; r<525; r++)
for (c=0; c<768; c++)
{
red[r*768+c] = c % 255;
green[r*768+c] = (767 - c) % 255;
blue[r*768+c] = r % 255;
}
gen_image3(new,"byte",768,525,(Hlong)red,(long)green,(long)blue);
}
main()
{
Hobject rgb;
open_window(0,0,768,525,0,"","",&WindowHandle);
NewRGBImage(&rgb);
disp_color(rgb,WindowHandle);
}