查找指定区域内的所有颜色块 - FindColorBlockListEx
函数简介
在绑定窗口中查找符合指定颜色范围的所有颜色块,支持去重与方向优先策略。
接口名称
FindColorBlockListEx
DLL调用
long FindColorBlockListEx(int64_t instance, int32_t x1, int32_t y1, int32_t x2, int32_t y2,
string colorList, int32_t count, int32_t width, int32_t height,
int32_t type, int32_t dir)
参数定义
instance(长整型数): OLAPlug对象指针,由 CreateCOLAPlugInterFace 生成x1/y1/x2/y2(整型数): 搜索区域(全0为整个客户区)colorList(字符串): 颜色模型配置字符串,用于限定图像匹配中的颜色范围,格式说明见 颜色模型说明 - ColorModel。JSON格式示例:[{"StartColor":"3278FA","EndColor":"6496FF","Type":0}];简化格式示例:3278FA-000000|6496FF-202020或3278FA~6496FF或FF0000|00FF00count(整型数): 色块最小匹配像素数量width(整型数): 颜色块的宽度,单位为像素。height(整型数): 颜色块的高度,单位为像素。type(整型数): 0 不重复,1 重复dir(整型数): 查找方向- 0: 左→右,上→下
- 1: 左→右,下→上
- 2: 右→左,上→下
- 3: 右→左,下→上
- 4: 从中心向外
- 5: 上→下,左→右
- 6: 上→下,右→左
- 7: 下→上,左→右
- 8: 下→上,右→左
返回值
- 返回JSON字符串指针,形如:
[{"x":1,"y":2},{"x":2,"y":1}];未找到返回空指针 - 使用完需调用 FreeStringPtr 释放
示例
long json_ptr = FindColorBlockListEx(ola, 0, 0, 0, 0, color_json, 10, 20, 20, 0, 0);
if (json_ptr) {
printf("%s\n", (char*)json_ptr);
FreeStringPtr(ola, json_ptr);
}
