目录
上一篇博文
Qt + Python + OpenCV图标替换工具 之 获取颜色及生成图片(二)
https://blog.csdn.net/qq78442761/article/details/85940989
程序的下载地址以及源码
源码已经打包:
运行版本(release版本(编译好)下载地址如下):
https://download.csdn.net/download/qq78442761/10899496
源码下载地址如下:
https://download.csdn.net/download/qq78442761/10899518
Python调用dll
只要使用ctypes就能完成,但有一点要注意,就是编码问题,我这里是使用GBK编码
如下所示:
调用上一节 extern "C"__declspec(dllexport) char* getColorName(char *FileName) 这个函数:
源码如下:
- import ctypes
- import sys
-
- if __name__=='__main__':
-
- fileName = str(sys.argv[1])
- ll = ctypes.cdll.LoadLibrary
- lib = ll("AlgColor.dll")
- charPointer = bytes(fileName,"gbk")
- result = lib.getColorName(charPointer)
- pyResult = ctypes.string_at(result);
- result = pyResult.decode("gbk")
- print(result)
- pass
调用上一节的 extern "C"__declspec(dllexport) void createPic(const char *fileName, const char *color)
源码如下:
- import ctypes
- import sys
-
- if __name__=='__main__':
-
- originalFileName = str(sys.argv[1])
- colorFileName = str(sys.argv[2])
- ll = ctypes.cdll.LoadLibrary
- lib = ll("AlgColor.dll")
- charPointer1 = bytes(originalFileName,"gbk")
- charPointer2 = bytes(colorFileName,"gbk")
- result = lib.createPic(charPointer1, charPointer2)
- pyResult = ctypes.string_at(result);
- result = pyResult.decode("gbk")
- print(result)
- pass
下一节说明Qt界面设计
Qt + Python + OpenCV图标替换工具 之 Qt界面设计(四)
https://blog.csdn.net/qq78442761/article/details/85942362