Compare commits
6 Commits
44a16deae0
...
290b75ee1a
Author | SHA1 | Date |
---|---|---|
luoliangyi | 290b75ee1a | |
luoliangyi | 3ac6688940 | |
luoliangyi | 35ca04e7ab | |
luoliangyi | 21f91712ac | |
luoliangyi | 75f47b8f1a | |
luoliangyi | 53e2b7cdf1 |
|
@ -18,7 +18,7 @@ DeviceUserMgr::~DeviceUserMgr()
|
|||
class DeviceUser* DeviceUserMgr::OpenDeviceUser()
|
||||
{
|
||||
HGTwainDS ds = nullptr;
|
||||
HGTwain_OpenSelectedDS(m_twainDSM, &ds);
|
||||
HGTwain_OpenSelectedDSEx(m_twainDSM, &ds);
|
||||
if (nullptr == ds)
|
||||
return nullptr;
|
||||
return new DeviceUser(m_wnd, ds);
|
||||
|
|
|
@ -48,6 +48,8 @@ int main(int argc, char *argv[])
|
|||
lang_set_code_page(cp);
|
||||
|
||||
MainWindow w;
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
w.move((screen->size().width() - w.width()) / 2, (screen->size().height() - w.height()) / 2);
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
@ -5,4 +5,5 @@ EXPORTS
|
|||
show_srclist_ui
|
||||
show_devlist_ui
|
||||
show_setting_ui
|
||||
show_scan_ui
|
||||
show_scan_ui
|
||||
show_twain_srclist_ui
|
|
@ -66,9 +66,14 @@ win32 {
|
|||
SOURCES += ../../../modules/saneui/qmfcapp.cpp
|
||||
SOURCES += ../../../modules/saneui/qwinhost.cpp
|
||||
SOURCES += ../../../modules/saneui/qwinwidget.cpp
|
||||
SOURCES += ../../../modules/saneui/dialog_twain_source_select.cpp
|
||||
|
||||
HEADERS += ../../../modules/saneui/qmfcapp.hpp
|
||||
HEADERS += ../../../modules/saneui/qwinhost.hpp
|
||||
HEADERS += ../../../modules/saneui/qwinwidget.hpp
|
||||
HEADERS += ../../../modules/saneui/dialog_twain_source_select.h
|
||||
|
||||
FORMS += ../../../modules/saneui/dialog_twain_source_select.ui
|
||||
|
||||
MY_OS = windows
|
||||
TARGET = $${OEM_PREFIX}SaneUI
|
||||
|
@ -217,7 +222,8 @@ SOURCES += \
|
|||
../../../modules/saneui/hg_settingdialog.cpp \
|
||||
../../../modules/saneui/setpicclrtool.cpp \
|
||||
../../../modules/saneui/widget.cpp \
|
||||
../../../utility/HGString.cpp
|
||||
../../../utility/HGString.cpp \
|
||||
../../../modules/saneui/dialog_source_select.cpp
|
||||
|
||||
HEADERS += \
|
||||
../../../modules/saneui/HGSaneUI.h \
|
||||
|
@ -226,14 +232,15 @@ HEADERS += \
|
|||
../../../modules/saneui/cutdialog.h \
|
||||
../../../modules/saneui/cutpapertool.h \
|
||||
../../../modules/saneui/device_menu.h \
|
||||
../../../modules/saneui/dialog_device_scan.hpp \
|
||||
../../../modules/saneui/dialog_device_select.hpp \
|
||||
../../../modules/saneui/dialog_device_scan.h \
|
||||
../../../modules/saneui/dialog_device_select.h \
|
||||
../../../modules/saneui/dialog_input.h \
|
||||
../../../modules/saneui/gaosixy.h \
|
||||
../../../modules/saneui/hg_settingdialog.h \
|
||||
../../../modules/saneui/setpicclrtool.h \
|
||||
../../../modules/saneui/widget.h \
|
||||
../../../utility/HGString.h
|
||||
../../../utility/HGString.h \
|
||||
../../../modules/saneui/dialog_source_select.h
|
||||
|
||||
FORMS += \
|
||||
../../../modules/saneui/cutdialog.ui \
|
||||
|
@ -242,7 +249,8 @@ FORMS += \
|
|||
../../../modules/saneui/dialog_device_select.ui \
|
||||
../../../modules/saneui/dialog_input.ui \
|
||||
../../../modules/saneui/setpicclrtool.ui \
|
||||
../../../modules/saneui/widget.ui
|
||||
../../../modules/saneui/widget.ui \
|
||||
../../../modules/saneui/dialog_source_select.ui
|
||||
|
||||
RESOURCES += \
|
||||
../../../modules/saneui/SaneUI_resource.qrc
|
||||
|
|
|
@ -2,78 +2,79 @@ TEMPLATE = subdirs
|
|||
|
||||
SUBDIRS += \
|
||||
HGBase \
|
||||
HGImgFmt \
|
||||
HGImgProc \
|
||||
HGSaneUI \
|
||||
HGSaneUser \
|
||||
HGTwainUser \
|
||||
HGVersion \
|
||||
HGScannerLib \
|
||||
HGUpload \
|
||||
HGWebScan \
|
||||
HGWebService \
|
||||
HGDemo \
|
||||
HGUpgrade \
|
||||
HGFWUpgrade \
|
||||
HGScanner
|
||||
HGImgFmt \
|
||||
HGImgProc \
|
||||
HGSaneUI \
|
||||
HGSaneUser \
|
||||
HGTwainUser \
|
||||
HGVersion \
|
||||
HGScannerLib \
|
||||
HGUpload \
|
||||
HGWebScan \
|
||||
HGWebService \
|
||||
HGDemo \
|
||||
HGUpgrade \
|
||||
HGFWUpgrade \
|
||||
HGScanner
|
||||
|
||||
HGImgFmt.depends = \
|
||||
HGBase
|
||||
|
||||
HGImgProc.depends = \
|
||||
HGBase \
|
||||
HGImgFmt
|
||||
HGImgFmt
|
||||
|
||||
HGSaneUI.depends = \
|
||||
HGBase
|
||||
|
||||
HGSaneUser.depends = \
|
||||
HGBase \
|
||||
HGSaneUI
|
||||
HGSaneUI
|
||||
|
||||
HGTwainUser.depends = \
|
||||
HGBase
|
||||
HGBase \
|
||||
HGSaneUI
|
||||
|
||||
HGVersion.depends = \
|
||||
HGBase
|
||||
|
||||
HGScannerLib.depends = \
|
||||
HGBase \
|
||||
HGImgFmt \
|
||||
HGImgProc
|
||||
HGImgFmt \
|
||||
HGImgProc
|
||||
|
||||
HGUpload.depends = \
|
||||
HGBase
|
||||
|
||||
HGWebScan.depends = \
|
||||
HGBase \
|
||||
HGImgFmt \
|
||||
HGImgProc
|
||||
HGImgFmt \
|
||||
HGImgProc
|
||||
|
||||
HGWebService.depends = \
|
||||
HGBase \
|
||||
HGImgFmt \
|
||||
HGImgProc
|
||||
HGImgFmt \
|
||||
HGImgProc
|
||||
|
||||
HGDemo.depends = \
|
||||
HGBase \
|
||||
HGImgFmt \
|
||||
HGImgProc \
|
||||
HGSaneUser \
|
||||
HGTwainUser
|
||||
HGImgFmt \
|
||||
HGImgProc \
|
||||
HGSaneUser \
|
||||
HGTwainUser
|
||||
|
||||
HGUpgrade.depends = \
|
||||
HGBase \
|
||||
HGVersion
|
||||
HGBase \
|
||||
HGVersion
|
||||
|
||||
HGFWUpgrade.depends = \
|
||||
HGBase \
|
||||
HGImgFmt \
|
||||
HGImgProc \
|
||||
HGVersion
|
||||
HGImgFmt \
|
||||
HGImgProc \
|
||||
HGVersion
|
||||
|
||||
HGScanner.depends = \
|
||||
HGBase \
|
||||
HGImgFmt \
|
||||
HGImgProc \
|
||||
HGVersion
|
||||
HGImgFmt \
|
||||
HGImgProc \
|
||||
HGVersion
|
||||
|
|
|
@ -9,6 +9,7 @@ HGTwain_GetDSNameWithIndex
|
|||
HGTwain_OpenDS
|
||||
HGTwain_OpenDefaultDS
|
||||
HGTwain_OpenSelectedDS
|
||||
HGTwain_OpenSelectedDSEx
|
||||
HGTwain_CloseDS
|
||||
HGTwain_GetDSName
|
||||
HGTwain_EnableDSUIOnly
|
||||
|
|
|
@ -94,7 +94,7 @@ win32 {
|
|||
|
||||
DEF_FILE = HGTwainUser.def
|
||||
LIBS += -lgdi32 -lgdiplus -ldbghelp -luser32
|
||||
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX}Base
|
||||
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX}Base -l$${OEM_PREFIX}SaneUI
|
||||
}
|
||||
|
||||
unix {
|
||||
|
@ -131,11 +131,11 @@ unix {
|
|||
QMAKE_LFLAGS += -z defs -B direct
|
||||
|
||||
LIBS += -lpthread -ldl
|
||||
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX2}Base
|
||||
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX2}Base -l$${OEM_PREFIX2}SaneUI
|
||||
}
|
||||
|
||||
INCLUDEPATH += $$PWD/../../../modules
|
||||
INCLUDEPATH += $$PWD/../../../third_party/twain
|
||||
INCLUDEPATH += $$PWD/../../../../sdk/include
|
||||
|
||||
DESTDIR = $$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}
|
||||
UI_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET}
|
||||
|
|
|
@ -13,6 +13,95 @@ HGSaneManagerImpl::~HGSaneManagerImpl()
|
|||
|
||||
HGResult HGSaneManagerImpl::Create()
|
||||
{
|
||||
std::string archName;
|
||||
FILE *file = popen("arch", "r");
|
||||
if (NULL != file)
|
||||
{
|
||||
char str[256] = {0};
|
||||
if (NULL != fgets(str, 256, file))
|
||||
{
|
||||
char *p = str;
|
||||
while (0 != *p && '\n' != *p)
|
||||
{
|
||||
archName.push_back(*p);
|
||||
++p;
|
||||
}
|
||||
}
|
||||
|
||||
pclose(file);
|
||||
}
|
||||
|
||||
if (archName.empty())
|
||||
{
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
char manuPath[] = "/etc/sane.d/dll.d";
|
||||
|
||||
DIR* dir = opendir(manuPath);
|
||||
if (NULL != dir)
|
||||
{
|
||||
struct dirent* dire = NULL;
|
||||
while (dire = readdir(dir))
|
||||
{
|
||||
if (0 == strcmp(dire->d_name, ".") || 0 == strcmp(dire->d_name, ".."))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
char fileName[256];
|
||||
sprintf(fileName, "%s/%s", manuPath, dire->d_name);
|
||||
|
||||
struct stat filebuf;
|
||||
lstat(fileName, &filebuf);
|
||||
if (S_ISDIR(filebuf.st_mode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string manuName;
|
||||
FILE *file = fopen(fileName, "r");
|
||||
if (NULL != file)
|
||||
{
|
||||
char str[256] = {0};
|
||||
while (NULL != fgets(str, 256, file))
|
||||
{
|
||||
if ('#' == str[0] || '\n' == str[0])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
char *p = str;
|
||||
while (0 != *p && '\n' != *p)
|
||||
{
|
||||
manuName.push_back(*p);
|
||||
++p;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
if (manuName.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::pair<std::string, std::string> pr;
|
||||
pr.first = manuName;
|
||||
|
||||
char sanePath[256];
|
||||
sprintf(sanePath, "/usr/lib/%s-linux-gnu/sane/libsane-%s.so.1", archName.c_str(), manuName.c_str());
|
||||
pr.second = sanePath;
|
||||
|
||||
m_vSource.push_back(pr);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -77,23 +166,36 @@ HGResult HGSaneManagerImpl::OpenSelectedSource(HGWindow parent, class HGSaneSour
|
|||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
const char **manuNames = new const char *[m_vSource.size() + 1];
|
||||
const char **sanePaths = new const char *[m_vSource.size() + 1];
|
||||
for (int i = 0; i < (int)m_vSource.size(); ++i)
|
||||
{
|
||||
manuNames[i] = m_vSource[i].first.c_str();
|
||||
sanePaths[i] = m_vSource[i].second.c_str();
|
||||
}
|
||||
manuNames[m_vSource.size()] = NULL;
|
||||
sanePaths[m_vSource.size()] = NULL;
|
||||
|
||||
HGDll dll = NULL;
|
||||
f_sane_init fInit = NULL;
|
||||
f_sane_exit fExit = NULL;
|
||||
SANEAPI saneAPI;
|
||||
char manuName[256];
|
||||
if (-2 == show_srclist_ui(parent, &dll, &fInit, &fExit, &saneAPI, manuName, 256))
|
||||
if (-2 == show_srclist_ui(manuNames, sanePaths, parent, &dll, &saneAPI, manuName, 256))
|
||||
{
|
||||
delete [] sanePaths;
|
||||
delete [] manuNames;
|
||||
return HGBASE_ERR_NOTSUPPORT;
|
||||
}
|
||||
|
||||
delete [] sanePaths;
|
||||
delete [] manuNames;
|
||||
|
||||
if (NULL == dll)
|
||||
{
|
||||
return HGSANE_ERR_FAIL;
|
||||
}
|
||||
|
||||
HGSaneSourceImpl* newSourceImpl = new HGSaneSourceImpl(this);
|
||||
HGResult ret = newSourceImpl->Init(manuName, dll, fInit, fExit, &saneAPI);
|
||||
HGResult ret = newSourceImpl->Init(manuName, dll, &saneAPI);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
delete newSourceImpl;
|
||||
|
@ -126,8 +228,6 @@ HGSaneSourceImpl::HGSaneSourceImpl(HGSaneManagerImpl *managerImpl)
|
|||
m_managerImpl = managerImpl;
|
||||
m_manuName.clear();
|
||||
m_dll = NULL;
|
||||
m_f_sane_init = NULL;
|
||||
m_f_sane_exit = NULL;
|
||||
memset(&m_saneApi, 0, sizeof(SANEAPI));
|
||||
}
|
||||
|
||||
|
@ -136,11 +236,11 @@ HGSaneSourceImpl::~HGSaneSourceImpl()
|
|||
|
||||
}
|
||||
|
||||
HGResult HGSaneSourceImpl::Init(const HGChar* saneManu, HGDll dll, f_sane_init fInit, f_sane_exit fExit, const SANEAPI *saneAPI)
|
||||
HGResult HGSaneSourceImpl::Init(const HGChar* saneManu, HGDll dll, const SANEAPI *saneAPI)
|
||||
{
|
||||
assert(NULL == m_dll);
|
||||
|
||||
if (NULL == dll || NULL == fInit || NULL == fExit || NULL == saneAPI)
|
||||
if (NULL == saneManu || 0 == *saneManu || NULL == dll || NULL == saneAPI)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
@ -149,21 +249,20 @@ HGResult HGSaneSourceImpl::Init(const HGChar* saneManu, HGDll dll, f_sane_init f
|
|||
|| NULL == saneAPI->sane_start_api || NULL == saneAPI->sane_read_api
|
||||
|| NULL == saneAPI->sane_cancel_api || NULL == saneAPI->sane_get_devices_api
|
||||
|| NULL == saneAPI->sane_get_option_descriptor_api || NULL == saneAPI->sane_control_option_api
|
||||
|| NULL == saneAPI->sane_get_parameters_api || saneAPI->sane_set_io_mode_api
|
||||
|| NULL == saneAPI->sane_strstatus_api || NULL == saneAPI->sane_io_control_api)
|
||||
|| NULL == saneAPI->sane_get_parameters_api || NULL == saneAPI->sane_set_io_mode_api
|
||||
|| NULL == saneAPI->sane_strstatus_api || NULL == saneAPI->sane_io_control_api
|
||||
|| NULL == saneAPI->sane_init_api || NULL == saneAPI->sane_exit_api)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
if (SANE_STATUS_GOOD != fInit(NULL, NULL))
|
||||
if (SANE_STATUS_GOOD != saneAPI->sane_init_api(NULL, NULL))
|
||||
{
|
||||
return HGSANE_ERR_FAIL;
|
||||
}
|
||||
|
||||
m_manuName = saneManu;
|
||||
m_dll = dll;
|
||||
m_f_sane_init = fInit;
|
||||
m_f_sane_exit = fExit;
|
||||
memcpy(&m_saneApi, saneAPI, sizeof(SANEAPI));
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
@ -172,27 +271,28 @@ HGResult HGSaneSourceImpl::Open(const HGChar* saneManu, const HGChar* sanePath)
|
|||
{
|
||||
assert(NULL == m_dll);
|
||||
|
||||
if (NULL == saneManu || 0 == *saneManu
|
||||
|| NULL == sanePath || 0 == *sanePath)
|
||||
if (NULL == saneManu || 0 == *saneManu || NULL == sanePath || 0 == *sanePath)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
HGResult ret = HGBase_CreateDll(sanePath, &m_dll);
|
||||
HGDll dll = NULL;
|
||||
HGResult ret = HGBase_CreateDll(sanePath, &dll);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = FindFunctions(saneManu);
|
||||
SANEAPI saneAPI;
|
||||
ret = FindFunctions(dll, saneManu, &saneAPI);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
HGBase_DestroyDll(m_dll);
|
||||
m_dll = NULL;
|
||||
HGBase_DestroyDll(dll);
|
||||
dll = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (SANE_STATUS_GOOD != m_f_sane_init(NULL, NULL))
|
||||
if (SANE_STATUS_GOOD != saneAPI.sane_init_api(NULL, NULL))
|
||||
{
|
||||
HGBase_DestroyDll(m_dll);
|
||||
m_dll = NULL;
|
||||
|
@ -200,6 +300,8 @@ HGResult HGSaneSourceImpl::Open(const HGChar* saneManu, const HGChar* sanePath)
|
|||
}
|
||||
|
||||
m_manuName = saneManu;
|
||||
m_dll = dll;
|
||||
memcpy(&m_saneApi, &saneAPI, sizeof(SANEAPI));
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -212,7 +314,7 @@ HGResult HGSaneSourceImpl::Close()
|
|||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
m_f_sane_exit();
|
||||
m_saneApi.sane_exit_api();
|
||||
HGBase_DestroyDll(m_dll);
|
||||
m_dll = NULL;
|
||||
m_managerImpl->RemoveSource(this);
|
||||
|
@ -349,7 +451,7 @@ HGResult HGSaneSourceImpl::OpenSelectedDevice(HGWindow parent, class HGSaneDevic
|
|||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGSaneSourceImpl::FindFunctions(const HGChar* saneManu)
|
||||
HGResult HGSaneSourceImpl::FindFunctions(HGDll dll, const HGChar* saneManu, SANEAPI *saneAPI)
|
||||
{
|
||||
HGResult ret = HGBASE_ERR_OK;
|
||||
|
||||
|
@ -358,72 +460,72 @@ HGResult HGSaneSourceImpl::FindFunctions(const HGChar* saneManu)
|
|||
HGChar funcName[256];
|
||||
|
||||
sprintf(funcName, "sane_%s_init", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_f_sane_init);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_init_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_exit", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_f_sane_exit);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_exit_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_get_devices", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_get_devices_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_get_devices_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_open", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_open_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_open_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_close", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_close_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_close_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_start", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_start_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_start_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_read", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_read_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_read_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_cancel", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_cancel_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_cancel_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_set_io_mode", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_set_io_mode_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_set_io_mode_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_strstatus", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_strstatus_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_strstatus_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_get_parameters", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_get_parameters_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_get_parameters_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_get_option_descriptor", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_get_option_descriptor_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_get_option_descriptor_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_control_option", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_control_option_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_control_option_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_io_control", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(m_dll, funcName, (HGPointer*)&m_saneApi.sane_io_control_api);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_io_control_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
HGSaneSourceImpl(HGSaneManagerImpl *managerImpl);
|
||||
~HGSaneSourceImpl();
|
||||
|
||||
HGResult Init(const HGChar* saneManu, HGDll dll, f_sane_init fInit, f_sane_exit fExit, const SANEAPI *saneAPI);
|
||||
HGResult Init(const HGChar* saneManu, HGDll dll, const SANEAPI *saneAPI);
|
||||
HGResult Open(const HGChar* saneManu, const HGChar* sanePath);
|
||||
HGResult Close();
|
||||
HGResult GetName(HGChar* name, HGUInt maxLen);
|
||||
|
@ -51,15 +51,13 @@ public:
|
|||
HGResult OpenSelectedDevice(HGWindow parent, class HGSaneDeviceImpl** deviceImpl);
|
||||
|
||||
private:
|
||||
HGResult FindFunctions(const HGChar* saneManu);
|
||||
static HGResult FindFunctions(HGDll dll, const HGChar* saneManu, SANEAPI *saneAPI);
|
||||
void RemoveDevice(class HGSaneDeviceImpl* deviceImpl);
|
||||
|
||||
private:
|
||||
HGSaneManagerImpl *m_managerImpl;
|
||||
std::string m_manuName;
|
||||
HGDll m_dll;
|
||||
f_sane_init m_f_sane_init;
|
||||
f_sane_exit m_f_sane_exit;
|
||||
SANEAPI m_saneApi;
|
||||
std::list<class HGSaneDeviceImpl*> m_listDeviceImpl;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#include "HGSaneUI.h"
|
||||
#include "dialog_device_select.hpp"
|
||||
#include "dialog_device_scan.hpp"
|
||||
#include "dialog_source_select.h"
|
||||
#include "dialog_device_select.h"
|
||||
#include "dialog_device_scan.h"
|
||||
#ifdef HG_CMP_MSC
|
||||
#include "dialog_twain_source_select.h"
|
||||
#endif
|
||||
#include "hg_settingdialog.h"
|
||||
#include "lang/app_language.h"
|
||||
#include <QMessageBox>
|
||||
|
@ -13,9 +17,48 @@ extern HINSTANCE g_hInst;
|
|||
extern bool g_ownApplication;
|
||||
#endif
|
||||
|
||||
int show_srclist_ui(HGWindow parent, HGDll *dll, f_sane_init *fInit, f_sane_exit *fExit,
|
||||
int show_srclist_ui(const char **manuNames, const char **sanePaths, HGWindow parent, HGDll *dll,
|
||||
SANEAPI* saneApi, char *manuName, unsigned int maxLen)
|
||||
{
|
||||
if (nullptr == manuNames || nullptr == sanePaths || nullptr == dll || nullptr == saneApi)
|
||||
return -1;
|
||||
|
||||
QWidget *qParent = nullptr;
|
||||
#ifdef HG_CMP_MSC
|
||||
if (!g_ownApplication)
|
||||
g_ownApplication = QMfcApp::pluginInstance(g_hInst);
|
||||
QWinWidget win(parent);
|
||||
win.showCentered();
|
||||
qParent = &win;
|
||||
#else
|
||||
qParent = parent;
|
||||
#endif
|
||||
|
||||
QTranslator translator;
|
||||
int cp = lang_get_cur_code_page();
|
||||
if (20127 == cp)
|
||||
translator.load(":translation/SaneUI_zh_EN.qm");
|
||||
else
|
||||
translator.load(":translation/SaneUI_zh_CN.qm");
|
||||
QCoreApplication::installTranslator(&translator);
|
||||
|
||||
*dll = nullptr;
|
||||
memset(saneApi, 0, sizeof(SANEAPI));
|
||||
Dialog_Source_Select dlg(manuNames, sanePaths, qParent);
|
||||
if (dlg.exec())
|
||||
{
|
||||
if (nullptr != manuName)
|
||||
{
|
||||
std::string strManuName = dlg.GetManuName();
|
||||
if (maxLen >= strManuName.size() + 1)
|
||||
strcpy(manuName, strManuName.c_str());
|
||||
}
|
||||
|
||||
*dll = dlg.GetDll();
|
||||
dlg.GetSaneAPI(saneApi);
|
||||
}
|
||||
|
||||
QCoreApplication::removeTranslator(&translator);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -121,3 +164,40 @@ int show_scan_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devName
|
|||
QCoreApplication::removeTranslator(&translator);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
int show_twain_srclist_ui(DSMENTRYPROC dsmProc, const TW_IDENTITY *appId, HGWindow parent, TW_IDENTITY *ds)
|
||||
{
|
||||
if (nullptr == dsmProc || nullptr == appId || nullptr == ds)
|
||||
return -1;
|
||||
|
||||
QWidget *qParent = nullptr;
|
||||
#ifdef HG_CMP_MSC
|
||||
if (!g_ownApplication)
|
||||
g_ownApplication = QMfcApp::pluginInstance(g_hInst);
|
||||
QWinWidget win(parent);
|
||||
win.showCentered();
|
||||
qParent = &win;
|
||||
#else
|
||||
qParent = parent;
|
||||
#endif
|
||||
|
||||
QTranslator translator;
|
||||
int cp = lang_get_cur_code_page();
|
||||
if (20127 == cp)
|
||||
translator.load(":translation/SaneUI_zh_EN.qm");
|
||||
else
|
||||
translator.load(":translation/SaneUI_zh_CN.qm");
|
||||
QCoreApplication::installTranslator(&translator);
|
||||
|
||||
memset(ds, 0, sizeof(TW_IDENTITY));
|
||||
Dialog_Twain_Source_Select dlg(dsmProc, appId, qParent);
|
||||
if (dlg.exec())
|
||||
{
|
||||
dlg.GetIdentify(ds);
|
||||
}
|
||||
|
||||
QCoreApplication::removeTranslator(&translator);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,16 +4,21 @@
|
|||
#include "../base/HGDef.h"
|
||||
#include "../base/HGDll.h"
|
||||
#include "sane/sane_ex.h"
|
||||
#if defined(HG_CMP_MSC)
|
||||
#include "twain/twain.h"
|
||||
#endif
|
||||
|
||||
typedef SANE_Status (*f_sane_init)(SANE_Int* version_code, SANE_Auth_Callback authorize);
|
||||
typedef void (*f_sane_exit)(void);
|
||||
typedef void (*show_scan_ui_image_callback)(const SANE_Parameters *imageFormat, const SANE_Byte *imageData, void * callbackParam);
|
||||
|
||||
HGEXPORT int show_srclist_ui(HGWindow parent, HGDll *dll, f_sane_init *fInit, f_sane_exit *fExit,
|
||||
HGEXPORT int show_srclist_ui(const char **manuNames, const char **sanePaths, HGWindow parent, HGDll *dll,
|
||||
SANEAPI* saneApi, char *manuName, unsigned int maxLen);
|
||||
HGEXPORT int show_devlist_ui(const SANEAPI* saneApi, HGWindow parent, SANE_Handle *handle, char *devName, unsigned int maxLen);
|
||||
HGEXPORT int show_setting_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devName, HGWindow parent);
|
||||
HGEXPORT int show_scan_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devName, HGWindow parent,
|
||||
show_scan_ui_image_callback callback, void *callbackParam);
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
HGEXPORT int show_twain_srclist_ui(DSMENTRYPROC dsmProc, const TW_IDENTITY *appId, HGWindow parent, TW_IDENTITY *ds);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Binary file not shown.
|
@ -398,7 +398,7 @@ Continue to clear?</source>
|
|||
</message>
|
||||
<message>
|
||||
<source>SANE_STATUS_NO_DOCS</source>
|
||||
<translation>无纸</translation>
|
||||
<translation type="vanished">无纸</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_device_scan.ui" line="42"/>
|
||||
|
@ -438,7 +438,7 @@ Continue to clear?</source>
|
|||
<message>
|
||||
<location filename="dialog_device_scan.cpp" line="156"/>
|
||||
<source>Scan complete</source>
|
||||
<translation type="unfinished">扫描完成</translation>
|
||||
<translation>扫描完成</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -1417,6 +1417,58 @@ Please make sure the two passwords are the same.</source>
|
|||
<translation type="vanished">取消</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Dialog_Source_Select</name>
|
||||
<message>
|
||||
<location filename="dialog_source_select.ui" line="14"/>
|
||||
<source>Select source</source>
|
||||
<translation>选择源</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_source_select.ui" line="42"/>
|
||||
<source>OK</source>
|
||||
<translation>确定</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_source_select.ui" line="49"/>
|
||||
<source>Cancel</source>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_source_select.cpp" line="69"/>
|
||||
<location filename="dialog_source_select.cpp" line="79"/>
|
||||
<source>tips</source>
|
||||
<translation>提示</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_source_select.cpp" line="69"/>
|
||||
<source>Load library failed</source>
|
||||
<translation>加载库失败</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_source_select.cpp" line="79"/>
|
||||
<source>Find function failed</source>
|
||||
<translation>查找函数失败</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Dialog_Twain_Source_Select</name>
|
||||
<message>
|
||||
<location filename="dialog_twain_source_select.ui" line="14"/>
|
||||
<source>Select source</source>
|
||||
<translation>选择源</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_twain_source_select.ui" line="42"/>
|
||||
<source>OK</source>
|
||||
<translation>确定</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_twain_source_select.ui" line="49"/>
|
||||
<source>Cancel</source>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Dialog_WriteSettings</name>
|
||||
<message>
|
||||
|
|
Binary file not shown.
|
@ -376,7 +376,7 @@ Continue clearing?</translation>
|
|||
</message>
|
||||
<message>
|
||||
<source>SANE_STATUS_NO_DOCS</source>
|
||||
<translation>No documents</translation>
|
||||
<translation type="vanished">No documents</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_device_scan.ui" line="42"/>
|
||||
|
@ -1294,6 +1294,58 @@ Please make sure the two passwords are the same.</source>
|
|||
<translation type="vanished">Image modified, save changes?</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Dialog_Source_Select</name>
|
||||
<message>
|
||||
<location filename="dialog_source_select.ui" line="14"/>
|
||||
<source>Select source</source>
|
||||
<translation>Select source</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_source_select.ui" line="42"/>
|
||||
<source>OK</source>
|
||||
<translation>OK</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_source_select.ui" line="49"/>
|
||||
<source>Cancel</source>
|
||||
<translation>Cancel</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_source_select.cpp" line="69"/>
|
||||
<location filename="dialog_source_select.cpp" line="79"/>
|
||||
<source>tips</source>
|
||||
<translation>Tips</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_source_select.cpp" line="69"/>
|
||||
<source>Load library failed</source>
|
||||
<translation>Load library failed</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_source_select.cpp" line="79"/>
|
||||
<source>Find function failed</source>
|
||||
<translation>Find function failed</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Dialog_Twain_Source_Select</name>
|
||||
<message>
|
||||
<location filename="dialog_twain_source_select.ui" line="14"/>
|
||||
<source>Select source</source>
|
||||
<translation>Select source</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_twain_source_select.ui" line="42"/>
|
||||
<source>OK</source>
|
||||
<translation>OK</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="dialog_twain_source_select.ui" line="49"/>
|
||||
<source>Cancel</source>
|
||||
<translation>Cancel</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Dialog_WriteSettings</name>
|
||||
<message>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "dialog_device_scan.hpp"
|
||||
#include "dialog_device_scan.h"
|
||||
#include "ui_dialog_device_scan.h"
|
||||
#include "base/HGInc.h"
|
||||
#include <QMessageBox>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "base/HGDef.h"
|
||||
#include "base/HGThread.h"
|
||||
#include "sane/sane_ex.h"
|
||||
#include "HGSaneUI.h"
|
||||
#include <QDialog>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "dialog_device_select.hpp"
|
||||
#include "dialog_device_select.h"
|
||||
#include "ui_dialog_device_select.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#ifndef DIALOG_DEVICE_SELECT_H
|
||||
#define DIALOG_DEVICE_SELECT_H
|
||||
|
||||
#include "base/HGDef.h"
|
||||
#include "sane/sane_ex.h"
|
||||
#include "HGSaneUI.h"
|
||||
#include <QDialog>
|
||||
#include <string>
|
||||
#include <vector>
|
|
@ -0,0 +1,175 @@
|
|||
#include "dialog_source_select.h"
|
||||
#include "ui_dialog_source_select.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
Dialog_Source_Select::Dialog_Source_Select(const char **manuNames, const char **sanePaths, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::Dialog_Source_Select)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_vSource.clear();
|
||||
m_strManuName.clear();
|
||||
m_dll = nullptr;
|
||||
memset(&m_saneApi, 0, sizeof(SANEAPI));
|
||||
|
||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
||||
|
||||
const char **p1 = manuNames;
|
||||
const char **p2 = sanePaths;
|
||||
while (*p1 != NULL && *p2 != NULL)
|
||||
{
|
||||
std::pair<std::string, std::string> pr;
|
||||
pr.first = *p1;
|
||||
pr.second = *p2;
|
||||
m_vSource.push_back(pr);
|
||||
ui->listWidget->addItem(*p1);
|
||||
++p1;
|
||||
++p2;
|
||||
}
|
||||
|
||||
if (!m_vSource.empty())
|
||||
{
|
||||
ui->listWidget->setCurrentRow(0);
|
||||
}
|
||||
}
|
||||
|
||||
Dialog_Source_Select::~Dialog_Source_Select()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
std::string Dialog_Source_Select::GetManuName()
|
||||
{
|
||||
return m_strManuName;
|
||||
}
|
||||
|
||||
HGDll Dialog_Source_Select::GetDll()
|
||||
{
|
||||
return m_dll;
|
||||
}
|
||||
|
||||
void Dialog_Source_Select::GetSaneAPI(SANEAPI *saneAPI)
|
||||
{
|
||||
memcpy(saneAPI, &m_saneApi, sizeof(SANEAPI));
|
||||
}
|
||||
|
||||
void Dialog_Source_Select::on_pushButton_OK_clicked()
|
||||
{
|
||||
int index = ui->listWidget->currentRow();
|
||||
if (index < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HGDll dll = nullptr;
|
||||
HGResult ret = HGBase_CreateDll(m_vSource[index].second.c_str(), &dll);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
QMessageBox::information(this, tr("tips"), tr("Load library failed"));
|
||||
return;
|
||||
}
|
||||
|
||||
SANEAPI saneAPI;
|
||||
ret = FindFunctions(dll, m_vSource[index].first.c_str(), &saneAPI);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
HGBase_DestroyDll(dll);
|
||||
dll = NULL;
|
||||
QMessageBox::information(this, tr("tips"), tr("Find function failed"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_strManuName = m_vSource[index].first;
|
||||
m_dll = dll;
|
||||
memcpy(&m_saneApi, &saneAPI, sizeof(SANEAPI));
|
||||
accept();
|
||||
}
|
||||
|
||||
void Dialog_Source_Select::on_pushButton_Cancel_clicked()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
HGResult Dialog_Source_Select::FindFunctions(HGDll dll, const HGChar* saneManu, SANEAPI *saneAPI)
|
||||
{
|
||||
HGResult ret = HGBASE_ERR_OK;
|
||||
|
||||
do
|
||||
{
|
||||
HGChar funcName[256];
|
||||
|
||||
sprintf(funcName, "sane_%s_init", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_init_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_exit", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_exit_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_get_devices", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_get_devices_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_open", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_open_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_close", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_close_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_start", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_start_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_read", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_read_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_cancel", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_cancel_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_set_io_mode", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_set_io_mode_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_strstatus", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_strstatus_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_get_parameters", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_get_parameters_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_get_option_descriptor", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_get_option_descriptor_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_control_option", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_control_option_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
sprintf(funcName, "sane_%s_io_control", saneManu);
|
||||
ret = HGBase_GetDllProcAddress(dll, funcName, (HGPointer*)&saneAPI->sane_io_control_api);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
break;
|
||||
|
||||
} while (0);
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef DIALOG_SOURCE_SELECT_H
|
||||
#define DIALOG_SOURCE_SELECT_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "HGSaneUI.h"
|
||||
|
||||
namespace Ui {
|
||||
class Dialog_Source_Select;
|
||||
}
|
||||
|
||||
class Dialog_Source_Select : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Dialog_Source_Select(const char **manuNames, const char **sanePaths, QWidget *parent = 0);
|
||||
~Dialog_Source_Select();
|
||||
|
||||
std::string GetManuName();
|
||||
HGDll GetDll();
|
||||
void GetSaneAPI(SANEAPI *saneAPI);
|
||||
|
||||
private slots:
|
||||
void on_pushButton_OK_clicked();
|
||||
|
||||
void on_pushButton_Cancel_clicked();
|
||||
|
||||
private:
|
||||
HGResult FindFunctions(HGDll dll, const HGChar* saneManu, SANEAPI *saneAPI);
|
||||
|
||||
private:
|
||||
Ui::Dialog_Source_Select *ui;
|
||||
std::vector<std::pair<std::string, std::string> > m_vSource;
|
||||
std::string m_strManuName;
|
||||
HGDll m_dll;
|
||||
SANEAPI m_saneApi;
|
||||
};
|
||||
|
||||
#endif // DIALOG_SOURCE_SELECT_H
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog_Source_Select</class>
|
||||
<widget class="QDialog" name="Dialog_Source_Select">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>346</width>
|
||||
<height>207</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Select source</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_OK">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_Cancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -0,0 +1,60 @@
|
|||
#include "dialog_twain_source_select.h"
|
||||
#include "ui_dialog_twain_source_select.h"
|
||||
|
||||
Dialog_Twain_Source_Select::Dialog_Twain_Source_Select(DSMENTRYPROC dsmProc, const TW_IDENTITY *appId, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::Dialog_Twain_Source_Select)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_vSource.clear();
|
||||
m_dsmProc = dsmProc;
|
||||
memcpy(&m_appId, appId, sizeof(TW_IDENTITY));
|
||||
memset(&m_ds, 0, sizeof(TW_IDENTITY));
|
||||
|
||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
||||
|
||||
TW_IDENTITY ds;
|
||||
if (TWRC_SUCCESS == m_dsmProc(&m_appId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETFIRST, &ds))
|
||||
{
|
||||
m_vSource.push_back(ds);
|
||||
ui->listWidget->addItem(ds.ProductName);
|
||||
while (TWRC_SUCCESS == m_dsmProc(&m_appId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETNEXT, &ds))
|
||||
{
|
||||
m_vSource.push_back(ds);
|
||||
ui->listWidget->addItem(ds.ProductName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_vSource.empty())
|
||||
{
|
||||
ui->listWidget->setCurrentRow(0);
|
||||
}
|
||||
}
|
||||
|
||||
Dialog_Twain_Source_Select::~Dialog_Twain_Source_Select()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Dialog_Twain_Source_Select::GetIdentify(TW_IDENTITY *ds)
|
||||
{
|
||||
memcpy(ds, &m_ds, sizeof(TW_IDENTITY));
|
||||
}
|
||||
|
||||
void Dialog_Twain_Source_Select::on_pushButton_OK_clicked()
|
||||
{
|
||||
int index = ui->listWidget->currentRow();
|
||||
if (index < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(&m_ds, &m_vSource[index], sizeof(TW_IDENTITY));
|
||||
accept();
|
||||
}
|
||||
|
||||
void Dialog_Twain_Source_Select::on_pushButton_Cancel_clicked()
|
||||
{
|
||||
reject();
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef DIALOG_TWAIN_SOURCE_SELECT_H
|
||||
#define DIALOG_TWAIN_SOURCE_SELECT_H
|
||||
|
||||
#include "HGSaneUI.h"
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class Dialog_Twain_Source_Select;
|
||||
}
|
||||
|
||||
class Dialog_Twain_Source_Select : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Dialog_Twain_Source_Select(DSMENTRYPROC dsmProc, const TW_IDENTITY *appId, QWidget *parent = nullptr);
|
||||
~Dialog_Twain_Source_Select();
|
||||
|
||||
void GetIdentify(TW_IDENTITY *ds);
|
||||
|
||||
private slots:
|
||||
void on_pushButton_OK_clicked();
|
||||
|
||||
void on_pushButton_Cancel_clicked();
|
||||
|
||||
private:
|
||||
Ui::Dialog_Twain_Source_Select *ui;
|
||||
std::vector<TW_IDENTITY> m_vSource;
|
||||
DSMENTRYPROC m_dsmProc;
|
||||
TW_IDENTITY m_appId;
|
||||
TW_IDENTITY m_ds;
|
||||
};
|
||||
|
||||
#endif // DIALOG_TWAIN_SOURCE_SELECT_H
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog_Twain_Source_Select</class>
|
||||
<widget class="QDialog" name="Dialog_Twain_Source_Select">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>343</width>
|
||||
<height>203</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Select source</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_OK">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_Cancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -117,6 +117,25 @@ HGResult HGAPI HGTwain_OpenSelectedDS(HGTwainDSM dsm, HGTwainDS* ds)
|
|||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGAPI HGTwain_OpenSelectedDSEx(HGTwainDSM dsm, HGTwainDS* ds)
|
||||
{
|
||||
if (NULL == dsm)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
HGTwainDSMImpl* twainDSMImpl = (HGTwainDSMImpl*)dsm;
|
||||
class HGTwainDSImpl* dsImpl = NULL;
|
||||
HGResult ret = twainDSMImpl->OpenSelectedDSEx(&dsImpl);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
*ds = (HGTwainDS)dsImpl;
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGAPI HGTwain_CloseDS(HGTwainDS ds)
|
||||
{
|
||||
if (NULL == ds)
|
||||
|
@ -171,4 +190,4 @@ HGResult HGAPI HGTwain_DisableDS(HGTwainDS ds)
|
|||
|
||||
HGTwainDSImpl* twainDSImpl = (HGTwainDSImpl*)ds;
|
||||
return twainDSImpl->Disable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ HGEXPORT HGResult HGAPI HGTwain_OpenDefaultDS(HGTwainDSM dsm, HGTwainDS* ds);
|
|||
|
||||
HGEXPORT HGResult HGAPI HGTwain_OpenSelectedDS(HGTwainDSM dsm, HGTwainDS* ds);
|
||||
|
||||
HGEXPORT HGResult HGAPI HGTwain_OpenSelectedDSEx(HGTwainDSM dsm, HGTwainDS* ds);
|
||||
|
||||
HGEXPORT HGResult HGAPI HGTwain_CloseDS(HGTwainDS ds);
|
||||
|
||||
HGEXPORT HGResult HGAPI HGTwain_GetDSName(HGTwainDS ds, HGChar* name, HGUInt maxLen);
|
||||
|
@ -39,4 +41,4 @@ HGEXPORT HGResult HGAPI HGTwain_EnableDS(HGTwainDS ds, HGBool showUI, HWND paren
|
|||
|
||||
HGEXPORT HGResult HGAPI HGTwain_DisableDS(HGTwainDS ds);
|
||||
|
||||
#endif /* __HGTWAIN_H__ */
|
||||
#endif /* __HGTWAIN_H__ */
|
||||
|
|
|
@ -235,6 +235,38 @@ HGResult HGTwainDSMImpl::OpenSelectedDS(class HGTwainDSImpl** dsImpl)
|
|||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGTwainDSMImpl::OpenSelectedDSEx(class HGTwainDSImpl** dsImpl)
|
||||
{
|
||||
if (NULL == dsImpl)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
TW_IDENTITY selectDS;
|
||||
memset(&selectDS, 0, sizeof(TW_IDENTITY));
|
||||
if (-2 == show_twain_srclist_ui(m_pDSMProc, &m_AppId, m_hWnd, &selectDS))
|
||||
{
|
||||
return HGBASE_ERR_NOTSUPPORT;
|
||||
}
|
||||
|
||||
if (0 == selectDS.Id)
|
||||
{
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
class HGTwainDSImpl* newDSImpl = new HGTwainDSImpl(this);
|
||||
HGResult ret = newDSImpl->Open(&selectDS);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
delete newDSImpl;
|
||||
return ret;
|
||||
}
|
||||
|
||||
m_listDSImpl.push_back(newDSImpl);
|
||||
*dsImpl = newDSImpl;
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
void HGTwainDSMImpl::RemoveDS(class HGTwainDSImpl* dsImpl)
|
||||
{
|
||||
std::vector<class HGTwainDSImpl*>::iterator iter;
|
||||
|
@ -326,11 +358,12 @@ HGTwainDSImpl::~HGTwainDSImpl()
|
|||
|
||||
}
|
||||
|
||||
HGResult HGTwainDSImpl::Open(const TW_IDENTITY* iden)
|
||||
HGResult HGTwainDSImpl::Open(TW_IDENTITY* iden)
|
||||
{
|
||||
assert(!m_open);
|
||||
assert(NULL != iden);
|
||||
|
||||
USHORT ret = m_dsmImpl->m_pDSMProc(&m_dsmImpl->m_AppId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, &m_iden);
|
||||
USHORT ret = m_dsmImpl->m_pDSMProc(&m_dsmImpl->m_AppId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, iden);
|
||||
if (TWRC_SUCCESS != ret)
|
||||
{
|
||||
return HGTWAIN_ERR_FAIL;
|
||||
|
@ -563,4 +596,4 @@ HGResult HGTwainDSImpl::Reset()
|
|||
}
|
||||
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
#include "HGTwain.h"
|
||||
#include "../base/HGDll.h"
|
||||
#include "twain.h"
|
||||
#include "twain/twain.h"
|
||||
#include "saneui/HGSaneUI.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
@ -21,6 +22,7 @@ public:
|
|||
HGResult OpenDS(HGUInt index, class HGTwainDSImpl** dsImpl);
|
||||
HGResult OpenDefaultDS(class HGTwainDSImpl** dsImpl);
|
||||
HGResult OpenSelectedDS(class HGTwainDSImpl** dsImpl);
|
||||
HGResult OpenSelectedDSEx(class HGTwainDSImpl** dsImpl);
|
||||
|
||||
private:
|
||||
void RemoveDS(class HGTwainDSImpl* dsImpl);
|
||||
|
@ -44,7 +46,7 @@ public:
|
|||
~HGTwainDSImpl();
|
||||
|
||||
public:
|
||||
HGResult Open(const TW_IDENTITY* iden);
|
||||
HGResult Open(TW_IDENTITY* iden);
|
||||
HGResult Close();
|
||||
HGResult GetName(HGChar* name, HGUInt maxLen);
|
||||
HGResult EnableUIOnly(HWND parent, HGDSCloseReqFunc eventFunc, HGPointer eventParam);
|
||||
|
|
|
@ -74,7 +74,7 @@ print(os.path.abspath('.'))
|
|||
if platform.system() == 'Windows':
|
||||
Objdll = ctypes.WinDLL(os.path.abspath('.') + "/CTSScannerLib.dll")
|
||||
elif platform.system() == "Linux":
|
||||
Objdll = cdll.LoadLibrary(os.path.abspath('.') + "/libCTSScannerLib.so")
|
||||
Objdll = cdll.LoadLibrary(os.path.abspath('.') + "/libCtsScannerLib.so")
|
||||
|
||||
#加载图像接口示例
|
||||
HGLib_LoadImage = Objdll.HGLib_LoadImage
|
||||
|
|
|
@ -74,7 +74,7 @@ print(os.path.abspath('.'))
|
|||
if platform.system() == 'Windows':
|
||||
Objdll = ctypes.WinDLL(os.path.abspath('.') + "/HWScannerLib.dll")
|
||||
elif platform.system() == "Linux":
|
||||
Objdll = cdll.LoadLibrary(os.path.abspath('.') + "/libHWScannerLib.so")
|
||||
Objdll = cdll.LoadLibrary(os.path.abspath('.') + "/libHwScannerLib.so")
|
||||
|
||||
#加载图像接口示例
|
||||
HGLib_LoadImage = Objdll.HGLib_LoadImage
|
||||
|
|
|
@ -74,7 +74,7 @@ print(os.path.abspath('.'))
|
|||
if platform.system() == 'Windows':
|
||||
Objdll = ctypes.WinDLL(os.path.abspath('.') + "/LSCScannerLib.dll")
|
||||
elif platform.system() == "Linux":
|
||||
Objdll = cdll.LoadLibrary(os.path.abspath('.') + "/libLSCScannerLib.so")
|
||||
Objdll = cdll.LoadLibrary(os.path.abspath('.') + "/libLscScannerLib.so")
|
||||
|
||||
#加载图像接口示例
|
||||
HGLib_LoadImage = Objdll.HGLib_LoadImage
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
project(testdemo)
|
||||
|
||||
FILE(GLOB SRC "*.cpp" "*.h" "*.c")
|
||||
include_directories(${PROJECT_SOURCE_DIR}/)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SRC})
|
||||
|
||||
target_link_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} HGBase hgdriver HGImgFmt HGImgProc HGScannerLib mupdf pdf sane-hgsane)
|
||||
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/)
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
namespace WindowsFormsApp1
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows 窗体设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(301, 157);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(166, 65);
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "扫描";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button button1;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,281 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Globalization;
|
||||
using System.Timers;
|
||||
using System.Threading;
|
||||
|
||||
namespace WindowsFormsApp1
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
UIntPtr image = HGScannerLib.HGLib_LoadImage(StringToUtf8("1.jpg"));
|
||||
if (UIntPtr.Zero != image)
|
||||
{
|
||||
HGScannerLib.HGLibSaveImageParam saveParam;
|
||||
saveParam.size = (UInt32)Marshal.SizeOf(typeof(HGScannerLib.HGLibSaveImageParam));
|
||||
saveParam.jpegQuality = 80;
|
||||
saveParam.tiffCompression = 4;
|
||||
saveParam.tiffJpegQuality = 80;
|
||||
saveParam.ocr = 0;
|
||||
HGScannerLib.HGLib_SaveImage(image, StringToUtf8("2.jpg"), ref saveParam);
|
||||
HGScannerLib.HGLib_ReleaseImage(image);
|
||||
}
|
||||
|
||||
HGScannerLib.HGLibDeviceHotPlugEventFunc fun = new HGScannerLib.HGLibDeviceHotPlugEventFunc(DeviceHotPlugEventFunc);
|
||||
HGScannerLib.HGLib_InitDevice(fun, this.Handle);
|
||||
Thread.Sleep(500);
|
||||
|
||||
IntPtr deviceNameList = HGScannerLib.HGLib_GetDeviceNameList();
|
||||
if (IntPtr.Zero != deviceNameList)
|
||||
{
|
||||
// 获取设备列表
|
||||
int i = 0;
|
||||
IntPtr deviceName = Marshal.ReadIntPtr(deviceNameList, 0);
|
||||
while (IntPtr.Zero != deviceName)
|
||||
{
|
||||
String deviceNameText = Utf8ToString(deviceName);
|
||||
++i;
|
||||
deviceName = Marshal.ReadIntPtr(deviceNameList, Marshal.SizeOf(typeof(IntPtr)) * i);
|
||||
}
|
||||
|
||||
// 打开第一个设备
|
||||
UIntPtr device = HGScannerLib.HGLib_OpenDevice(Marshal.ReadIntPtr(deviceNameList, 0));
|
||||
if (UIntPtr.Zero != device)
|
||||
{
|
||||
// 获取序列号
|
||||
Byte[] sn = new Byte[60];
|
||||
IntPtr snAddr = Marshal.UnsafeAddrOfPinnedArrayElement(sn, 0);
|
||||
HGScannerLib.HGLib_GetDeviceSN(device, snAddr, 60);
|
||||
String snText = Utf8ToString(snAddr);
|
||||
|
||||
// 获取固件版本号
|
||||
Byte[] fwVer = new Byte[60];
|
||||
IntPtr fwVerAddr = Marshal.UnsafeAddrOfPinnedArrayElement(fwVer, 0);
|
||||
HGScannerLib.HGLib_GetDeviceFWVersion(device, fwVerAddr, 60);
|
||||
String fwVerText = Utf8ToString(fwVerAddr);
|
||||
|
||||
// 设置待纸扫描
|
||||
Int32[] dzsm = new Int32[1];
|
||||
dzsm[0] = 1;
|
||||
Int32 ret1 = HGScannerLib.HGLib_SetDeviceParam(device, 67,
|
||||
Marshal.UnsafeAddrOfPinnedArrayElement(dzsm, 0));
|
||||
|
||||
// 设置旋转90度
|
||||
UInt32[] rotate = new UInt32[1];
|
||||
rotate[0] = 67;
|
||||
Int32 ret2 = HGScannerLib.HGLib_SetDeviceParam(device, 59,
|
||||
Marshal.UnsafeAddrOfPinnedArrayElement(rotate, 0));
|
||||
|
||||
// 设置伽马值
|
||||
Double[] gamma = new Double[1];
|
||||
gamma[0] = 1.0;
|
||||
Int32 ret3 = HGScannerLib.HGLib_SetDeviceParam(device, 35,
|
||||
Marshal.UnsafeAddrOfPinnedArrayElement(gamma, 0));
|
||||
|
||||
// 获取旋转的配置
|
||||
IntPtr rotateParam = HGScannerLib.HGLib_GetDeviceParam(device, 59);
|
||||
if (IntPtr.Zero != rotateParam)
|
||||
{
|
||||
HGScannerLib.HGLibDeviceParam param = (HGScannerLib.HGLibDeviceParam)
|
||||
Marshal.PtrToStructure(rotateParam, typeof(HGScannerLib.HGLibDeviceParam));
|
||||
|
||||
// print param
|
||||
PrintParam(ref param);
|
||||
|
||||
HGScannerLib.HGLib_ReleaseDeviceParam(rotateParam);
|
||||
}
|
||||
|
||||
// 获取所有配置
|
||||
UInt32 groupCount = 0;
|
||||
IntPtr groupParamList = HGScannerLib.HGLib_GetDeviceParamGroupList(device, ref groupCount);
|
||||
if (IntPtr.Zero != groupParamList)
|
||||
{
|
||||
for (int groupIdx = 0; groupIdx < (int)groupCount; ++groupIdx)
|
||||
{
|
||||
HGScannerLib.HGLibDeviceParamGroup group = (HGScannerLib.HGLibDeviceParamGroup)
|
||||
Marshal.PtrToStructure(groupParamList + Marshal.SizeOf(typeof(HGScannerLib.HGLibDeviceParamGroup)) * groupIdx,
|
||||
typeof(HGScannerLib.HGLibDeviceParamGroup));
|
||||
|
||||
// 组名
|
||||
UInt32 groupName = group.group;
|
||||
// 组内配置的数量
|
||||
UInt32 paramCount = group.paramCount;
|
||||
|
||||
for (int paramIdx = 0; paramIdx < group.paramCount; ++paramIdx)
|
||||
{
|
||||
HGScannerLib.HGLibDeviceParam param = (HGScannerLib.HGLibDeviceParam)
|
||||
Marshal.PtrToStructure(group.param + Marshal.SizeOf(typeof(HGScannerLib.HGLibDeviceParam)) * paramIdx,
|
||||
typeof(HGScannerLib.HGLibDeviceParam));
|
||||
|
||||
// print param
|
||||
PrintParam(ref param);
|
||||
}
|
||||
}
|
||||
|
||||
HGScannerLib.HGLib_ReleaseDeviceParamGroupList(groupParamList, groupCount);
|
||||
}
|
||||
|
||||
// 扫描
|
||||
m_break = false;
|
||||
HGScannerLib.HGLibDeviceScanEventFunc eventFunc = new HGScannerLib.HGLibDeviceScanEventFunc(DeviceScanEventFunc);
|
||||
HGScannerLib.HGLibDeviceScanImageFunc imageFunc = new HGScannerLib.HGLibDeviceScanImageFunc(DeviceScanImageFunc);
|
||||
Int32 scanRet = HGScannerLib.HGLib_StartDeviceScan(device, eventFunc, this.Handle, imageFunc, this.Handle);
|
||||
if (0 != scanRet)
|
||||
{
|
||||
while (!m_break)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
HGScannerLib.HGLib_StopDeviceScan(device);
|
||||
}
|
||||
|
||||
HGScannerLib.HGLib_CloseDevice(device);
|
||||
}
|
||||
|
||||
HGScannerLib.HGLib_ReleaseDeviceNameList(deviceNameList);
|
||||
}
|
||||
|
||||
HGScannerLib.HGLib_DeinitDevice();
|
||||
}
|
||||
|
||||
public void DeviceHotPlugEventFunc(UInt32 evt, IntPtr deviceName, IntPtr param)
|
||||
{
|
||||
String devNameText = Utf8ToString(deviceName);
|
||||
}
|
||||
|
||||
public void DeviceScanEventFunc(UIntPtr device, UInt32 evt, Int32 err, IntPtr info, IntPtr param)
|
||||
{
|
||||
if (evt == 2)
|
||||
{
|
||||
m_break = true;
|
||||
}
|
||||
else if (3 == evt)
|
||||
{
|
||||
String infoText = Utf8ToString(info);
|
||||
}
|
||||
}
|
||||
|
||||
public void DeviceScanImageFunc(UIntPtr device, UIntPtr image, IntPtr param)
|
||||
{
|
||||
String fileName = String.Format("Scan_{0}.jpg", m_scanCount);
|
||||
++m_scanCount;
|
||||
|
||||
HGScannerLib.HGLibSaveImageParam saveParam;
|
||||
saveParam.size = (UInt32)Marshal.SizeOf(typeof(HGScannerLib.HGLibSaveImageParam));
|
||||
saveParam.jpegQuality = 80;
|
||||
saveParam.tiffCompression = 4;
|
||||
saveParam.tiffJpegQuality = 80;
|
||||
saveParam.ocr = 0;
|
||||
HGScannerLib.HGLib_SaveImage(image, StringToUtf8(fileName), ref saveParam);
|
||||
}
|
||||
|
||||
public String Utf8ToString(IntPtr str)
|
||||
{
|
||||
if (IntPtr.Zero == str)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
int len = 0;
|
||||
while (0 != Marshal.ReadByte(str, len))
|
||||
{
|
||||
++len;
|
||||
}
|
||||
|
||||
if (0 == len)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
Byte[] utf8 = new Byte[len];
|
||||
Marshal.Copy(str, utf8, 0, len);
|
||||
return Encoding.UTF8.GetString(utf8);
|
||||
}
|
||||
|
||||
public IntPtr StringToUtf8(String str)
|
||||
{
|
||||
if (str.Length == 0)
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
Byte[] src = Encoding.UTF8.GetBytes(str);
|
||||
Byte[] dst = new Byte[src.Length + 1];
|
||||
for (int i = 0; i < src.Length; ++i)
|
||||
dst[i] = src[i];
|
||||
dst[dst.Length - 1] = 0;
|
||||
return Marshal.UnsafeAddrOfPinnedArrayElement(dst, 0);
|
||||
}
|
||||
|
||||
public void PrintParam(ref HGScannerLib.HGLibDeviceParam param)
|
||||
{
|
||||
// 配置名
|
||||
UInt32 option = param.option;
|
||||
|
||||
if (1 == param.type) // 整型
|
||||
{
|
||||
Int32 value = param.typeValue.intValue;
|
||||
}
|
||||
else if (2 == param.type) // 枚举
|
||||
{
|
||||
UInt32 value = param.typeValue.enumValue;
|
||||
}
|
||||
else if (3 == param.type) // 双精度浮点
|
||||
{
|
||||
Double value = param.typeValue.doubleValue;
|
||||
}
|
||||
else if (4 == param.type) // BOOL
|
||||
{
|
||||
Int32 value = param.typeValue.boolValue;
|
||||
}
|
||||
|
||||
if (param.rangeType == 1) // 整型列表
|
||||
{
|
||||
Int32[] intValueList = new Int32[param.rangeTypeValue.intValueList.count];
|
||||
Marshal.Copy(param.rangeTypeValue.intValueList.value, intValueList, 0, (int)param.rangeTypeValue.intValueList.count);
|
||||
}
|
||||
else if (param.rangeType == 2) // 枚举列表
|
||||
{
|
||||
Int32[] enumValueList = new Int32[param.rangeTypeValue.enumValueList.count];
|
||||
Marshal.Copy(param.rangeTypeValue.enumValueList.value, enumValueList, 0, (int)param.rangeTypeValue.enumValueList.count);
|
||||
}
|
||||
else if (param.rangeType == 3) // 双精度浮点列表
|
||||
{
|
||||
Double[] doubleValueList = new Double[param.rangeTypeValue.doubleValueList.count];
|
||||
Marshal.Copy(param.rangeTypeValue.doubleValueList.value, doubleValueList, 0, (int)param.rangeTypeValue.doubleValueList.count);
|
||||
}
|
||||
else if (param.rangeType == 4) // 整型范围
|
||||
{
|
||||
// 最小值
|
||||
Int32 minVal = param.rangeTypeValue.intValueRange.minValue;
|
||||
// 最大值
|
||||
Int32 maxVal = param.rangeTypeValue.intValueRange.maxValue;
|
||||
}
|
||||
else if (param.rangeType == 5) // 双精度浮点范围
|
||||
{
|
||||
// 最小值
|
||||
Double minVal = param.rangeTypeValue.doubleValueRange.minValue;
|
||||
// 最大值
|
||||
Double maxVal = param.rangeTypeValue.doubleValueRange.maxValue;
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 m_scanCount = 1;
|
||||
public Boolean m_break = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,158 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace WindowsFormsApp1
|
||||
{
|
||||
public class HGScannerLib
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct HGLibSaveImageParam
|
||||
{
|
||||
public UInt32 size;
|
||||
public UInt32 jpegQuality;
|
||||
public UInt32 tiffCompression;
|
||||
public UInt32 tiffJpegQuality;
|
||||
public Int32 ocr;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct HGLibDeviceIntValueList
|
||||
{
|
||||
public IntPtr value; // Int32指针
|
||||
public UInt32 count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct HGLibDeviceEnumValueList
|
||||
{
|
||||
public IntPtr value; // UInt32指针
|
||||
public UInt32 count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct HGLibDeviceDoubleValueList
|
||||
{
|
||||
public IntPtr value; // Double指针
|
||||
public UInt32 count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct HGLibDeviceIntValueRange
|
||||
{
|
||||
public Int32 minValue;
|
||||
public Int32 maxValue;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct HGLibDeviceDoubleValueRange
|
||||
{
|
||||
public Double minValue;
|
||||
public Double maxValue;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Pack = 4)]
|
||||
public struct HGLibDeviceParamType
|
||||
{
|
||||
[FieldOffset(0)] public Int32 intValue;
|
||||
[FieldOffset(0)] public UInt32 enumValue;
|
||||
[FieldOffset(0)] public Double doubleValue;
|
||||
[FieldOffset(0)] public Int32 boolValue;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Pack = 4)]
|
||||
public struct HGLibDeviceParamRangeType
|
||||
{
|
||||
[FieldOffset(0)] public HGLibDeviceIntValueList intValueList;
|
||||
[FieldOffset(0)] public HGLibDeviceEnumValueList enumValueList;
|
||||
[FieldOffset(0)] public HGLibDeviceDoubleValueList doubleValueList;
|
||||
[FieldOffset(0)] public HGLibDeviceIntValueRange intValueRange;
|
||||
[FieldOffset(0)] public HGLibDeviceDoubleValueRange doubleValueRange;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct HGLibDeviceParam
|
||||
{
|
||||
public UInt32 option;
|
||||
public UInt32 type;
|
||||
public HGLibDeviceParamType typeValue;
|
||||
public UInt32 rangeType;
|
||||
public HGLibDeviceParamRangeType rangeTypeValue;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct HGLibDeviceParamGroup
|
||||
{
|
||||
public UInt32 group;
|
||||
public IntPtr param; // HGLibDeviceParam指针
|
||||
public UInt32 paramCount;
|
||||
}
|
||||
|
||||
public delegate void HGLibDeviceHotPlugEventFunc(UInt32 evt, IntPtr deviceName, IntPtr param);
|
||||
public delegate void HGLibDeviceScanEventFunc(UIntPtr device, UInt32 evt, Int32 err, IntPtr info, IntPtr param);
|
||||
public delegate void HGLibDeviceScanImageFunc(UIntPtr device, UIntPtr image, IntPtr param);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_LoadImage")]
|
||||
public static extern UIntPtr HGLib_LoadImage(IntPtr filePath);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_SaveImage")]
|
||||
public static extern Int32 HGLib_SaveImage(UIntPtr image, IntPtr filePath, ref HGLibSaveImageParam saveParam);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_ReleaseImage")]
|
||||
public static extern Int32 HGLib_ReleaseImage(UIntPtr image);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_InitDevice")]
|
||||
public static extern Int32 HGLib_InitDevice(HGLibDeviceHotPlugEventFunc func, IntPtr param);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_DeinitDevice")]
|
||||
public static extern Int32 HGLib_DeinitDevice();
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_GetDeviceNameList")]
|
||||
public static extern IntPtr HGLib_GetDeviceNameList();
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceNameList")]
|
||||
public static extern Int32 HGLib_ReleaseDeviceNameList(IntPtr deviceNameList);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_OpenDevice")]
|
||||
public static extern UIntPtr HGLib_OpenDevice(IntPtr deviceName);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_CloseDevice")]
|
||||
public static extern Int32 HGLib_CloseDevice(UIntPtr device);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_GetDeviceSN")]
|
||||
public static extern Int32 HGLib_GetDeviceSN(UIntPtr device, IntPtr sn, UInt32 maxLen);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_GetDeviceFWVersion")]
|
||||
public static extern Int32 HGLib_GetDeviceFWVersion(UIntPtr device, IntPtr fwVersion, UInt32 maxLen);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_SetDeviceParam")]
|
||||
public static extern Int32 HGLib_SetDeviceParam(UIntPtr device, UInt32 option, IntPtr data);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_GetDeviceParamGroupList")]
|
||||
public static extern IntPtr HGLib_GetDeviceParamGroupList(UIntPtr device, ref UInt32 count);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_GetDeviceParam")]
|
||||
public static extern IntPtr HGLib_GetDeviceParam(UIntPtr device, UInt32 option);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceParamGroupList")]
|
||||
public static extern Int32 HGLib_ReleaseDeviceParamGroupList(IntPtr devParamGroup, UInt32 count);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceParam")]
|
||||
public static extern Int32 HGLib_ReleaseDeviceParam(IntPtr devParam);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_ResetDeviceParam")]
|
||||
public static extern Int32 HGLib_ResetDeviceParam(UIntPtr device);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_DeviceIsPaperOn")]
|
||||
public static extern Int32 HGLib_DeviceIsPaperOn(UIntPtr device);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_StartDeviceScan")]
|
||||
public static extern Int32 HGLib_StartDeviceScan(UIntPtr device, HGLibDeviceScanEventFunc eventFunc, IntPtr eventParam,
|
||||
HGLibDeviceScanImageFunc imageFunc, IntPtr imageParam);
|
||||
|
||||
[DllImport("ZJScannerLib.dll", EntryPoint = "HGLib_StopDeviceScan")]
|
||||
public static extern Int32 HGLib_StopDeviceScan(UIntPtr device);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WindowsFormsApp1
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("WindowsFormsApp1")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("WindowsFormsApp1")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("e364d770-bb5c-400a-902e-213a3dadcbd5")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
70
test/scannerlib/microtek/c#/WindowsFormsApp1/Properties/Resources.Designer.cs
generated
Normal file
70
test/scannerlib/microtek/c#/WindowsFormsApp1/Properties/Resources.Designer.cs
generated
Normal file
|
@ -0,0 +1,70 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本: 4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace WindowsFormsApp1.Properties
|
||||
{
|
||||
/// <summary>
|
||||
/// 强类型资源类,用于查找本地化字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsApp1.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写当前线程的 CurrentUICulture 属性,对
|
||||
/// 使用此强类型资源类的所有资源查找执行重写。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
29
test/scannerlib/microtek/c#/WindowsFormsApp1/Properties/Settings.Designer.cs
generated
Normal file
29
test/scannerlib/microtek/c#/WindowsFormsApp1/Properties/Settings.Designer.cs
generated
Normal file
|
@ -0,0 +1,29 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace WindowsFormsApp1.Properties
|
||||
{
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{E364D770-BB5C-400A-902E-213A3DADCBD5}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>WindowsFormsApp1</RootNamespace>
|
||||
<AssemblyName>WindowsFormsApp1</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="HGScannerLib.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32228.343
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp1", "WindowsFormsApp1.csproj", "{E364D770-BB5C-400A-902E-213A3DADCBD5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E364D770-BB5C-400A-902E-213A3DADCBD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E364D770-BB5C-400A-902E-213A3DADCBD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E364D770-BB5C-400A-902E-213A3DADCBD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E364D770-BB5C-400A-902E-213A3DADCBD5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8B1D5CE6-959A-4477-B3BE-E7DEDDE78BB6}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,176 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <thread>
|
||||
#include "HGScannerLib.h"
|
||||
|
||||
#define DELEAY_MS(x) std::this_thread::sleep_for(std::chrono::milliseconds((x)))
|
||||
using namespace std;
|
||||
|
||||
//有图事件回调
|
||||
static void HGAPI DeviceScanImageFunc(HGLibDevice device, HGLibImage image, HGPointer param)
|
||||
{
|
||||
static int indeximg = 0;
|
||||
string savepath = std::to_string(++indeximg) + ".jpg";
|
||||
cout << "save image : " << savepath << endl;
|
||||
auto ret = HGLib_SaveImage(image, savepath.c_str(), 0);
|
||||
cout << "save image : " << savepath << (ret ? " success" : " failed") << endl;
|
||||
}
|
||||
|
||||
//设备热拔插事件回调
|
||||
static void HGAPI DeviceHotPlugEvent(HGUInt event, const HGChar *deviceName, HGPointer param)
|
||||
{
|
||||
cout << "Devices : " << deviceName << " DeviceHotPlugEvent : " << (event == HGLIB_DEVHOTPLUG_EVENT_ARRIVE ? "HGLIB_DEVHOTPLUG_EVENT_ARRIVE " : "HGLIB_DEVHOTPLUG_EVENT_LEFT") << endl;
|
||||
}
|
||||
|
||||
//扫描状态事件回调
|
||||
static void HGAPI DeviceScanEvent(HGLibDevice device, HGUInt event, HGBool err, const HGChar *info, HGPointer param)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case HGLIB_DEVSCAN_EVENT_BEGIN:
|
||||
cout << "DeviceScanEvent Start Scan" << endl;
|
||||
break;
|
||||
case HGLIB_DEVSCAN_EVENT_END:
|
||||
cout << "DeviceScanEvent Scan stopped" << endl;
|
||||
break;
|
||||
case HGLIB_DEVSCAN_EVENT_INFO:
|
||||
cout << "DeviceScanEvent info : " << info << endl;
|
||||
break;
|
||||
default:
|
||||
cout << "Unkownun DeviceScanEvent " << event << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int main(unsigned char argc, unsigned char *argv[])
|
||||
{
|
||||
std::cout << "*********Enter Scanner SDK Demo *********" << std::endl;
|
||||
HGLib_InitDevice(DeviceHotPlugEvent, 0); //初始化调用模块
|
||||
DELEAY_MS(5000);
|
||||
|
||||
HGChar **devNameList = HGLib_GetDeviceNameList(); //获取已连接的设备列表,已字符数组的形式返回
|
||||
if (devNameList)
|
||||
{
|
||||
HGLibDevice dev = HGLib_OpenDevice(devNameList[0]); //此示例代码中调用设备列表中第一个设备
|
||||
if (dev)
|
||||
{
|
||||
|
||||
HGUInt grpCount = 0;
|
||||
HGLibDeviceParamGroup *groups = HGLib_GetDeviceParamGroupList(dev, &grpCount);
|
||||
if (groups)
|
||||
{
|
||||
//获取sdk支持的功能项及配置项内容
|
||||
for (size_t i = 0; i < grpCount; i++)
|
||||
{
|
||||
cout << "group: " << groups[i].group << endl;
|
||||
for (size_t j = 0; j < groups[i].paramCount; j++)
|
||||
{
|
||||
cout << " option: " << groups[i].param[j].option
|
||||
<< " type: " << groups[i].param[j].type << endl;
|
||||
switch (groups[i].param[j].rangeType)
|
||||
{
|
||||
case HGLIB_OPTION_VALUERANGETYPE_INTLIST:
|
||||
for (size_t k = 0; k < groups[i].param[j].intValueList.count; k++)
|
||||
{
|
||||
cout<<"support value["<<k<<"]="<<groups[i].param[j].intValueList.value[k]<<endl;
|
||||
}
|
||||
break;
|
||||
case HGLIB_OPTION_VALUERANGETYPE_ENUMLIST:
|
||||
for (size_t k = 0; k < groups[i].param[j].enumValueList.count; k++)
|
||||
{
|
||||
cout<<"support value["<<k<<"]="<<groups[i].param[j].enumValueList.value[k]<<endl;
|
||||
}
|
||||
break;
|
||||
case HGLIB_OPTION_VALUERANGETYPE_DOUBLELIST:
|
||||
for (size_t k = 0; k < groups[i].param[j].doubleValueList.count; k++)
|
||||
{
|
||||
cout<<"support value["<<k<<"]="<<groups[i].param[j].doubleValueList.value[k]<<endl;
|
||||
}
|
||||
break;
|
||||
case HGLIB_OPTION_VALUERANGETYPE_INTRANGE:
|
||||
cout<<"support value range min = "<<groups[i].param[j].intValueRange.minValue <<" max = "<<groups[i].param[j].intValueRange.maxValue<<endl;
|
||||
break;
|
||||
case HGLIB_OPTION_VALUERANGETYPE_DOUBLERANGE:
|
||||
cout<<"support value range min = "<<groups[i].param[j].intValueRange.minValue <<" max = "<<groups[i].param[j].intValueRange.maxValue<<endl;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (groups[i].param[j].type)
|
||||
{
|
||||
case HGLIB_OPTION_VALUETYPE_INT:
|
||||
cout << " intValue: " << groups[i].param[j].intValue << endl;
|
||||
break;
|
||||
case HGLIB_OPTION_VALUETYPE_ENUM:
|
||||
cout << " enumValue: " << groups[i].param[j].enumValue << endl;
|
||||
break;
|
||||
case HGLIB_OPTION_VALUETYPE_DOUBLE:
|
||||
cout << " doubleValue: " << groups[i].param[j].doubleValue << endl;
|
||||
break;
|
||||
case HGLIB_OPTION_VALUETYPE_BOOL:
|
||||
cout << " boolValue: " << groups[i].param[j].boolValue << endl;
|
||||
break;
|
||||
default:
|
||||
cout << "unkownun type" << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HGInt intValue;
|
||||
HGUInt enumValue;
|
||||
HGDouble doubleValue;
|
||||
HGBool boolValue;
|
||||
|
||||
//设置颜色模式
|
||||
enumValue = HGLIB_OPTION_ENUMVALUE_YSMS_HB;
|
||||
HGLib_SetDeviceParam(dev,HGLIB_OPTION_NAME_YSMS,&enumValue);
|
||||
|
||||
//设置分辨率
|
||||
intValue = 300;
|
||||
HGLib_SetDeviceParam(dev,HGLIB_OPTION_NAME_FBL,&intValue);
|
||||
|
||||
//设置单双面或跳过空白页
|
||||
enumValue = HGLIB_OPTION_ENUMVALUE_SMYM_DM;
|
||||
HGLib_SetDeviceParam(dev,HGLIB_OPTION_NAME_SMYM,&enumValue);
|
||||
|
||||
|
||||
//设置纸张尺寸 A3 A4 或匹配原始尺寸
|
||||
enumValue = HGLIB_OPTION_ENUMVALUE_ZZCC_PPYSCC;
|
||||
HGLib_SetDeviceParam(dev,HGLIB_OPTION_NAME_ZZCC,&enumValue);
|
||||
|
||||
//设置旋转 90° 180° 270°
|
||||
enumValue = HGLIB_OPTION_ENUMVALUE_WGFX_90;
|
||||
HGLib_SetDeviceParam(dev,HGLIB_OPTION_NAME_WGFX,&enumValue);
|
||||
|
||||
// 扫描指定张数
|
||||
enumValue = HGLIB_OPTION_ENUMVALUE_SMZS_SMZDZS;
|
||||
HGLib_SetDeviceParam(dev,HGLIB_OPTION_NAME_SMZS,&enumValue);
|
||||
intValue = 1;
|
||||
HGLib_SetDeviceParam(dev,HGLIB_OPTION_NAME_SMSL,&intValue);
|
||||
|
||||
if (HGLib_StartDeviceScan(dev, DeviceScanEvent, 0, DeviceScanImageFunc, 0)) //开始启动扫描并注册扫描事件以及图像回调
|
||||
{
|
||||
DELEAY_MS(10000); //实际走纸延时等待处理
|
||||
HGLib_StopDeviceScan(dev);
|
||||
}
|
||||
HGBool ret = HGLib_ReleaseDeviceParamGroupList(groups,grpCount);
|
||||
if(!ret)
|
||||
cout << "HGLib_ReleaseDeviceParamGroupList failed"<<endl;
|
||||
|
||||
HGLib_CloseDevice(dev); //关闭当前打开的设备
|
||||
}
|
||||
else
|
||||
cout << "Open device : " << devNameList[0] << "failed " << endl;
|
||||
|
||||
HGLib_ReleaseDeviceNameList(devNameList); //释放设备列表
|
||||
}
|
||||
else
|
||||
cout << "devices not found" << endl;
|
||||
|
||||
HGLib_DeinitDevice(); //退出扫描模块
|
||||
cout << "*********Exit Scanner SDK Demo *********" << endl;
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,267 @@
|
|||
import ctypes
|
||||
import os
|
||||
from os import system
|
||||
import time
|
||||
import platform
|
||||
from ctypes import *
|
||||
import random
|
||||
|
||||
class HGLibSaveImageParam(Structure):
|
||||
_pack_ = 4
|
||||
_fields_ = [ ("size", c_uint),
|
||||
("jpegQuality", c_uint),
|
||||
("tiffCompression", c_uint),
|
||||
("tiffJpegQuality", c_uint),
|
||||
("ocr", c_int)]
|
||||
|
||||
class HGLibDeviceIntValueList(Structure):
|
||||
_pack_ = 4
|
||||
_fields_ = [ ("value", POINTER(c_int)),
|
||||
("count", c_uint)]
|
||||
|
||||
class HGLibDeviceEnumValueList(Structure):
|
||||
_pack_ = 4
|
||||
_fields_ = [ ("value", POINTER(c_uint)),
|
||||
("count", c_uint)]
|
||||
|
||||
class HGLibDeviceDoubleValueList(Structure):
|
||||
_pack_ = 4
|
||||
_fields_ = [ ("value", POINTER(c_double)),
|
||||
("count", c_uint)]
|
||||
|
||||
class HGLibDeviceIntValueRange(Structure):
|
||||
_pack_ = 4
|
||||
_fields_ = [ ("minValue", c_int),
|
||||
("maxValue", c_int)]
|
||||
|
||||
class HGLibDeviceDoubleValueRange(Structure):
|
||||
_pack_ = 4
|
||||
_fields_ = [ ("minValue", c_double),
|
||||
("maxValue", c_double)]
|
||||
|
||||
class HGLibDeviceParamType(Union):
|
||||
_pack_ = 4
|
||||
_fields_ = [ ("intValue", c_int),
|
||||
("enumValue", c_uint),
|
||||
("doubleValue", c_double),
|
||||
("boolValue", c_int)]
|
||||
|
||||
class HGLibDeviceParamRangeType(Union):
|
||||
_pack_ = 4
|
||||
_fields_ = [ ("intValueList", HGLibDeviceIntValueList),
|
||||
("enumValueList", HGLibDeviceEnumValueList),
|
||||
("doubleValueList", HGLibDeviceDoubleValueList),
|
||||
("intValueRange", HGLibDeviceIntValueRange),
|
||||
("doubleValueRange", HGLibDeviceDoubleValueRange)]
|
||||
|
||||
class HGLibDeviceParam(Structure):
|
||||
_pack_ = 4
|
||||
_fields_ = [ ("option", c_uint),
|
||||
("type", c_uint),
|
||||
("typeValue", HGLibDeviceParamType),
|
||||
("rangeType", c_uint),
|
||||
("rangeTypeValue", HGLibDeviceParamRangeType)]
|
||||
|
||||
class HGLibDeviceParamGroup(Structure):
|
||||
_pack_ = 4
|
||||
_fields_ = [ ("group", c_uint),
|
||||
("param", POINTER(HGLibDeviceParam)),
|
||||
("paramCount", c_uint)]
|
||||
|
||||
print(os.path.abspath('.'))
|
||||
|
||||
#加载动态库 所有依赖库必须在同一运行目录下边
|
||||
if platform.system() == 'Windows':
|
||||
Objdll = ctypes.WinDLL(os.path.abspath('.') + "/ZJScannerLib.dll")
|
||||
elif platform.system() == "Linux":
|
||||
Objdll = cdll.LoadLibrary(os.path.abspath('.') + "/libZjScannerLib.so")
|
||||
|
||||
#加载图像接口示例
|
||||
HGLib_LoadImage = Objdll.HGLib_LoadImage
|
||||
HGLib_LoadImage.argtypes = [ctypes.c_char_p]
|
||||
HGLib_LoadImage.restype = ctypes.c_void_p
|
||||
Image = HGLib_LoadImage(c_char_p(b"1.jpg"))
|
||||
|
||||
#保存图像接口示例
|
||||
HGLib_SaveImage = Objdll.HGLib_SaveImage
|
||||
HGLib_SaveImage.argtypes = [ctypes.c_void_p, ctypes.c_char_p, POINTER(HGLibSaveImageParam)]
|
||||
HGLib_SaveImage.restype = ctypes.c_int
|
||||
ImageParam = HGLibSaveImageParam()
|
||||
ImageParam.size = sizeof(ImageParam)
|
||||
ImageParam.jpegQuality = 80
|
||||
ImageParam.tiffCompression = 4
|
||||
ImageParam.tiffJpegQuality = 80
|
||||
ImageParam.ocr = 0
|
||||
Ret = HGLib_SaveImage(Image, c_char_p(b"2.jpg"), pointer(ImageParam))
|
||||
|
||||
#释放图像资源
|
||||
HGLib_ReleaseImage = Objdll.HGLib_ReleaseImage
|
||||
HGLib_ReleaseImage.argtypes = [ctypes.c_void_p]
|
||||
HGLib_ReleaseImage.restype = ctypes.c_int
|
||||
Ret = HGLib_ReleaseImage(Image)
|
||||
|
||||
#设备热拔插回调事件
|
||||
def HGLibDeviceHotPlugEventFunc(event: c_uint, deviceName: c_char_p, param: c_void_p):
|
||||
print(deviceName)
|
||||
return
|
||||
|
||||
#初始化操作
|
||||
FuncType = CFUNCTYPE(None, c_uint, c_char_p, c_void_p)
|
||||
cb = FuncType(HGLibDeviceHotPlugEventFunc)
|
||||
HGLib_InitDevice = Objdll.HGLib_InitDevice
|
||||
HGLib_InitDevice.argtypes = [FuncType, c_void_p]
|
||||
HGLib_InitDevice.restype = ctypes.c_int
|
||||
Ret = HGLib_InitDevice(cb, 0)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
#获取设备列表
|
||||
HGLib_GetDeviceNameList = Objdll.HGLib_GetDeviceNameList
|
||||
HGLib_GetDeviceNameList.argtypes = []
|
||||
HGLib_GetDeviceNameList.restype = POINTER(ctypes.c_char_p)
|
||||
DeviceNameList = HGLib_GetDeviceNameList()
|
||||
|
||||
#打开指定设备
|
||||
HGLib_OpenDevice = Objdll.HGLib_OpenDevice
|
||||
HGLib_OpenDevice.argtypes = [ctypes.c_char_p]
|
||||
HGLib_OpenDevice.restype = ctypes.c_void_p
|
||||
Device = HGLib_OpenDevice(DeviceNameList[0])
|
||||
|
||||
#获取设备所有参数
|
||||
HGLib_GetDeviceParamGroupList = Objdll.HGLib_GetDeviceParamGroupList
|
||||
HGLib_GetDeviceParamGroupList.argtypes = [ctypes.c_void_p, POINTER(c_uint)]
|
||||
HGLib_GetDeviceParamGroupList.restype = POINTER(HGLibDeviceParamGroup)
|
||||
DevParamCount = ctypes.c_uint()
|
||||
DevParamGroup = HGLib_GetDeviceParamGroupList(Device, pointer(DevParamCount))
|
||||
|
||||
GroupList = ['None', 'BaseSetting', 'Brightness', 'ImageProc', 'PaperFeeding']
|
||||
ValueTypeList = ['None', 'Int', 'Enum', 'Double', 'Bool']
|
||||
ValueRangeTypeList = ['None', 'IntList', 'EnumList', 'DoubleList', 'IntRange', 'DoubleRange']
|
||||
|
||||
i = 0
|
||||
while i < int(DevParamCount.value):
|
||||
print("group" + str(i) + ":" + GroupList[DevParamGroup[i].group])
|
||||
print(" paramCount:" + str(DevParamGroup[i].paramCount))
|
||||
j = 0
|
||||
while (j < int(DevParamGroup[i].paramCount)):
|
||||
print(" paramOption:" + str(DevParamGroup[i].param[j].option))
|
||||
print(" paramValueType:" + ValueTypeList[DevParamGroup[i].param[j].type])
|
||||
print(" paramValueRangeType:" + ValueRangeTypeList[DevParamGroup[i].param[j].rangeType])
|
||||
j += 1
|
||||
i += 1
|
||||
|
||||
#销毁
|
||||
HGLib_ReleaseDeviceParamGroupList = Objdll.HGLib_ReleaseDeviceParamGroupList
|
||||
HGLib_ReleaseDeviceParamGroupList.argtypes = [POINTER(HGLibDeviceParamGroup), c_uint]
|
||||
HGLib_ReleaseDeviceParamGroupList.restype = ctypes.c_int
|
||||
Ret = HGLib_ReleaseDeviceParamGroupList(DevParamGroup, DevParamCount)
|
||||
|
||||
#设置扫描参数
|
||||
HGLib_SetDeviceParam = Objdll.HGLib_SetDeviceParam
|
||||
HGLib_SetDeviceParam.argtypes = [ctypes.c_void_p, ctypes.c_uint, ctypes.c_void_p]
|
||||
HGLib_SetDeviceParam.restype = ctypes.c_int
|
||||
DevParam = ctypes.c_int(1) #HGLIB_OPTION_ENUMVALUE_DLSCLX_W -> 不进行多流输出类型
|
||||
Ret = HGLib_SetDeviceParam(Device, 1, byref(DevParam)) #见HGLib_SetDeviceParam 头文件接口说明 1 -> HGLIB_OPTION_NAME_DLSC 多流输出
|
||||
|
||||
DevParam = ctypes.c_int(300)
|
||||
Ret = HGLib_SetDeviceParam(Device, 27, byref(DevParam)) #HGLIB_OPTION_NAME_FBL 分辨率
|
||||
|
||||
DevParam = ctypes.c_int(1)
|
||||
Ret = HGLib_SetDeviceParam(Device, 37, byref(DevParam)) #HGLIB_OPTION_NAME_XCHK 消除黑框
|
||||
|
||||
DevParam = ctypes.c_int(54) #HGLIB_OPTION_ENUMVALUE_BJTCFS_ADBX 凸多边形
|
||||
Ret = HGLib_SetDeviceParam(Device, 42, byref(DevParam)) #HGLIB_OPTION_NAME_BJTCFS 背景填充方式
|
||||
|
||||
DevParam = ctypes.c_int(1)
|
||||
Ret = HGLib_SetDeviceParam(Device, 45, byref(DevParam))
|
||||
|
||||
DevParam = ctypes.c_double(0.1)
|
||||
Ret = HGLib_SetDeviceParam(Device, 46, byref(DevParam))
|
||||
|
||||
DevParam = ctypes.c_int(1)
|
||||
Ret = HGLib_SetDeviceParam(Device, 47, byref(DevParam))
|
||||
|
||||
DevParam = ctypes.c_double(0.1)
|
||||
Ret = HGLib_SetDeviceParam(Device, 48, byref(DevParam))
|
||||
|
||||
DevParam = ctypes.c_int(1)
|
||||
Ret = HGLib_SetDeviceParam(Device, 49, byref(DevParam))
|
||||
|
||||
DevParam = ctypes.c_double(0.1)
|
||||
Ret = HGLib_SetDeviceParam(Device, 50, byref(DevParam))
|
||||
|
||||
DevParam = ctypes.c_int(1)
|
||||
Ret = HGLib_SetDeviceParam(Device, 51, byref(DevParam))
|
||||
|
||||
DevParam = ctypes.c_double(0.1)
|
||||
Ret = HGLib_SetDeviceParam(Device, 52, byref(DevParam))
|
||||
|
||||
|
||||
#扫描事件回调
|
||||
def HGLibDeviceScanEventFunc(device: c_void_p, event: c_uint, err: c_int, info: c_char_p, param: c_void_p):
|
||||
s_info=info
|
||||
global bStop
|
||||
print("event code",event," event info:",s_info)
|
||||
if event == 2:#HGLIB_DEVSCAN_EVENT_END 扫描停止
|
||||
bStop=True
|
||||
print("bStop true")
|
||||
elif event == 1:
|
||||
bStop=False
|
||||
print("bStop false")
|
||||
return
|
||||
imgindex=0
|
||||
#扫描图像事件回调
|
||||
def HGLibDeviceScanImageFunc(device: c_void_p, image: c_void_p, param: c_void_p):
|
||||
global imgindex
|
||||
ImageParam = HGLibSaveImageParam()
|
||||
ImageParam.size = sizeof(ImageParam)
|
||||
ImageParam.jpegQuality = 80
|
||||
ImageParam.tiffCompression = 4
|
||||
ImageParam.tiffJpegQuality = 80
|
||||
ImageParam.ocr = 0
|
||||
print("image call back!!")
|
||||
imgindex+=1
|
||||
t_index=imgindex
|
||||
imgname=str(t_index) + '_scanned.jpg'
|
||||
print(imgname)
|
||||
b_imagename=imgname.encode('utf-8')
|
||||
pchar=c_char_p(b_imagename)
|
||||
Ret = HGLib_SaveImage(image, pchar, pointer(ImageParam))
|
||||
return
|
||||
|
||||
#注册扫描相关事件并启动扫描
|
||||
FuncType1 = CFUNCTYPE(None, c_void_p, c_uint, c_int, c_char_p, c_void_p)
|
||||
cb1 = FuncType1(HGLibDeviceScanEventFunc)
|
||||
FuncType2 = CFUNCTYPE(None, c_void_p, c_void_p, c_void_p)
|
||||
cb2 = FuncType2(HGLibDeviceScanImageFunc)
|
||||
HGLib_StartDeviceScan = Objdll.HGLib_StartDeviceScan
|
||||
HGLib_StartDeviceScan.argtypes = [c_void_p, FuncType1, c_void_p, FuncType2, c_void_p]
|
||||
HGLib_StartDeviceScan.restyped = ctypes.c_int
|
||||
print("start scan")
|
||||
Ret = HGLib_StartDeviceScan(Device, cb1, 0, cb2, 0)
|
||||
|
||||
#模拟扫描持续应等待扫描事件回调返回扫描停止才结束本次扫描流程
|
||||
while(not bStop):
|
||||
time.sleep(1)
|
||||
print("scanning...")
|
||||
|
||||
|
||||
print("scan done!!!")
|
||||
|
||||
#关闭当前打开的设备
|
||||
HGLib_CloseDevice=Objdll.HGLib_CloseDevice
|
||||
HGLib_CloseDevice.argtypes = [c_void_p]
|
||||
HGLib_CloseDevice.restype = ctypes.c_int
|
||||
HGLib_CloseDevice(Device)
|
||||
print("Close Devices")
|
||||
|
||||
#释放设备列表资源
|
||||
HGLib_ReleaseDeviceNameList=Objdll.HGLib_ReleaseDeviceNameList
|
||||
HGLib_ReleaseDeviceNameList.argtypes=[POINTER(ctypes.c_char_p)]
|
||||
HGLib_ReleaseDeviceNameList.restype = ctypes.c_int
|
||||
HGLib_ReleaseDeviceNameList(DeviceNameList)
|
||||
print("ReleaseDeviceNameList done")
|
||||
|
||||
print("exit test")
|
||||
|
||||
|
Loading…
Reference in New Issue