-
Notifications
You must be signed in to change notification settings - Fork 4
/
ImageConvert.py
50 lines (39 loc) · 1.58 KB
/
ImageConvert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# ACKNOWLEDGEMENT
# Pretty much ALL of this file was provided by Contrastech as part of their demo from the iCentral install
import os
from ctypes import *
if os.name == 'nt': # for windows
print('loaded dll for windows')
ImageConvertdll = cdll.LoadLibrary("C:\\Program Files\\iCentral\\iCentral\\Application\\x64\\ImageConvert.dll")
else:
print('loaded dll for linux')
ImageConvertdll = cdll.LoadLibrary("/opt/iCentral/iCentral/lib/libImageConvert.so")
def enum(**enums):
return type('Enum', (), enums)
# ImageConvert.h => enum tagIMGCNV_EErr
IMGCNV_EErr = enum(
IMGCNV_SUCCESS=0,
IMGCNV_ILLEGAL_PARAM=1,
IMGCNV_ERR_ORDER=2,
IMGCNV_NO_MEMORY=3,
IMGCNV_NOT_SUPPORT=4,
)
# ImageConvert.h => struct tagIMGCNV_SOpenParam
class IMGCNV_SOpenParam(Structure):
_fields_ = [
('width', c_int),
('height', c_int),
('paddingX', c_int),
('paddingY', c_int),
('dataSize', c_int),
('pixelFormat', c_uint),
]
# ImageConvert.h => IMGCNV_ConvertToBGR24(unsigned char* pSrcData, IMGCNV_SOpenParam* pOpenParam, unsigned char*
# pDstData, int* pDstDataSize)
IMGCNV_ConvertToBGR24 = ImageConvertdll.IMGCNV_ConvertToBGR24
# ImageConvert.h => IMGCNV_ConvertToRGB24(unsigned char* pSrcData, IMGCNV_SOpenParam* pOpenParam, unsigned char*
# pDstData, int* pDstDataSize)
IMGCNV_ConvertToRGB24 = ImageConvertdll.IMGCNV_ConvertToRGB24
# ImageConvert.h => IMGCNV_ConvertToMono8(unsigned char* pSrcData, IMGCNV_SOpenParam* pOpenParam, unsigned char*
# pDstData, int* pDstDataSize)
IMGCNV_ConvertToMono8 = ImageConvertdll.IMGCNV_ConvertToMono8