查找指定区域内的颜色块 - FindColorBlockPtr
函数简介
查找指定图像内符合指定颜色范围的第一个颜色块坐标点。
接口名称
FindColorBlockPtr
DLL调用
int FindColorBlockPtr(long ola, long image_ptr, string colors, int min_count, int block_width, int block_height, int* x, int* y);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| image_ptr | 长整数型 | 要搜索的图片句柄 |
| colors | 字符串 | 颜色模型配置字符串,格式说明见 颜色模型说明 - ColorModel。JSON格式示例:[{"StartColor":"3278FA","EndColor":"6496FF","Type":0}];简化格式示例:3278FA~6496FF |
| min_count | 整数型 | 在指定宽高的颜色块中,符合颜色条件的最小像素数量 |
| block_width | 整数型 | 颜色块的宽度(像素) |
| block_height | 整数型 | 颜色块的高度(像素) |
| x | 整数型指针 | 返回颜色块左上角X坐标 |
| y | 整数型指针 | 返回颜色块左上角Y坐标 |
示例
C++
long instance = CreateCOLAPlugInterFace();
// hwnd 为绑定的窗口句柄
long img = GetScreenDataPtr(instance, 0, 0, 0, 0);
int x = 0, y = 0;
// 查找20x20区域内至少100个像素符合颜色范围的色块
int ret = FindColorBlockPtr(instance, img, "3278FA~6496FF", 100, 20, 20, &x, &y);
if (ret == 1) {
printf("找到颜色块: x=%d, y=%d\n", x, y);
}
FreeImagePtr(instance, img);
Python
# 待补充
返回值
整数型:1 成功,0 失败。
