获取像素颜色 - GetColorPtr
函数简介
从指定的图片中获取指定坐标(x, y)处的颜色值,颜色返回格式"AARRGGBB"。
接口名称
GetColorPtr
DLL调用
long GetColorPtr(long ola, long source, int x, int y);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| source | 长整数型 | 源图像对象的指针 |
| x | 整数型 | 要获取颜色的像素点横坐标 |
| y | 整数型 | 要获取颜色的像素点纵坐标 |
示例
long source = LoadImage(ola, "image.png");
long colorPtr = GetColorPtr(ola, source, 100, 200);
if (colorPtr != 0) {
printf("颜色值: %s\n", (char*)colorPtr);
FreeStringPtr(ola, colorPtr);
}
FreeImagePtr(ola, source);
返回值
长整数型:返回颜色字符串指针,格式为"AARRGGBB"(小写)。失败返回0。
注意事项
- 返回的字符串指针需调用 FreeStringPtr 释放内存。
