我正在尝试转换 C 函数以供 python 3.6 使用。
代码如下:
lib = ctypes.WinDLL('ftrScanAPI.dll') # provided by fingerprint scanner
class FTRSCAN_IMAGE_SIZE(ctypes.Structure):
_fields_ = [
("nWidth", ctypes.c_int),
("nHeight", ctypes.c_int),
("nImageSize", ctypes.c_int)
]
print('Open device and get device handle...')
hDevice = lib.ftrScanOpenDevice()
print('handle is', hDevice)
print('Get image size...')
Image_size = FTRSCAN_IMAGE_SIZE(0, 0, 0)
if lib.ftrScanGetImageSize(hDevice, ctypes.byref(Image_size)):
print('Get image size succeed...')
print(' W', Image_size.nWidth)
print(' H', Image_size.nHeight)
print(' Size', Image_size.nImageSize)
else:
print('Get image size failed...')
Run Code Online (Sandbox Code Playgroud)
函数定义:
typedef struct FTR_PACKED __FTRSCAN_IMAGE_SIZE {
int nWidth;
int nHeight;
int nImageSize; …Run Code Online (Sandbox Code Playgroud)