设置Halcon颜色(窗体背景颜色、区域颜色)

这篇博客展示了如何使用Halcon的颜色代码在窗口中设置背景颜色,并通过示例代码解释了如何用Halcon设置窗体颜色和区域颜色。示例涵盖了21种不同的颜色,包括'gray', 'magenta', 'dimgray', 'coral', 'slateblue'等,并提供了用于测试的颜色循环展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 支持的颜色
*  在set_color的算子中,列出Halcon支持的颜色代码,共21种。 
*  Suggested values: 'black', 'white', 'red', 'green', 
*  'blue', 'cyan', 'magenta', 'yellow', 'dim gray', 'gray', 
*  'light gray', 'medium slate blue', 'coral', 'slate blue', 
*  'spring green', 'orange red', 'orange', 'dark olive green', 
*  'pink', 'forest green','cadet blue' 
*  可以用以下的代码来测试颜色 
ColorSet:=[] 
ColorSet[1]:='gray' 
ColorSet[2]:='magenta' 
ColorSet[3]:='dim gray' 
ColorSet[4]:='coral' 
ColorSet[5]:='slate blue' 
ColorSet[6]:='spring green' 
ColorSet[7]:='orange red' 
ColorSet[8]:='cadet blue' 
ColorSet[9]:='light gray' 
ColorSet[10]:='medium slate blue' 
ColorSet[11]:='red' 
ColorSet[12]:='white' 
ColorSet[13]:='green' 
ColorSet[14]:='blue' 
ColorSet[15]:='yellow' 
ColorSet[16]:='pink' 
ColorSet[17]:='orange' 
ColorSet[18]:='cyan' 
ColorSet[19]:='black' 
ColorSet[20]:='dark olive green' 
ColorSet[21]:='forest green' 

for i:=1 to 21 by 1 
    dev_update_window('off') 
    dev_close_window() 
    dev_open_window(0,0,300,300,ColorSet[i],WindowHandle) 
    get_system ('operating_system', OS) 
    set_display_font (WindowHandle, 16, 'mono', 'true', 'false') 
    disp_message (WindowHandle, ['The Color is:',ColorSet[i], 'window', -1, -1, [ColorSet,ColorSet], 'true') 
    wait_seconds(1)   
endfor
  1. 设置窗体背景颜色
HalconCpp::SetWindowAttr("background_color", "blue");
            HalconCpp::OpenWindow(this->x(), this->y(), this->width(), this->height(), m_labelID, "visible", "blue", &m_hHalconID);
  1. 设置区域颜色
SetColored(m_hHalconID, 12); //3,6,12多颜色
SetColor(m_DispControl.GetWindowID(), "yellow");
//SetDraw(m_DispControl.GetWindowID(), "margin"); //边缘、填充
SetDraw(m_DispControl.GetWindowID(), "fill");
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值