增加自动校正流程
This commit is contained in:
parent
0e907822ba
commit
626eb1b690
|
@ -71,6 +71,10 @@ void hgscanner::test_callback(const wchar_t* name, test_event ev, void* data, si
|
|||
QString title = QString::fromStdWString(name);
|
||||
emit m_interface->testDistortion(title, data);
|
||||
}
|
||||
else if (ev == TEST_EVENT_FALT_INFO)
|
||||
{
|
||||
std::string str = (char *)data;
|
||||
}
|
||||
else if (ev == TEST_EVENT_HAVE_IMAGE)
|
||||
{
|
||||
SANE_Image *sane_img = (SANE_Image *)data;
|
||||
|
|
|
@ -283,7 +283,7 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigne
|
|||
emit p->sane_dev_remove(sane_dev->name);
|
||||
}
|
||||
|
||||
if (code == SANE_EVENT_IMAGE_OK || code == SANE_EVENT_SCAN_FINISHED || code == SANE_EVENT_ERROR)
|
||||
if (code == SANE_EVENT_IMAGE_OK || code == SANE_EVENT_SCAN_FINISHED || code == SANE_EVENT_ERROR || code == SANE_EVENT_STATUS)
|
||||
{
|
||||
HGBase_EnterLock(p->m_lock);
|
||||
Form_mainInterface* interface = p->FindInterface(hdev);
|
||||
|
|
|
@ -93,6 +93,7 @@ public:
|
|||
TEST_EVENT_RESULT, // test result, data is (wchar_t*)description, flag is (bool)result, true - test pass
|
||||
TEST_EVENT_HAVE_IMAGE, // have image.
|
||||
TEST_EVENT_DISTORTION, // user set a single page,flag is int
|
||||
TEST_EVENT_FALT_INFO, //
|
||||
};
|
||||
virtual void test_callback(const wchar_t* name/*test name*/, test_event ev, void* data, size_t flag)=0 ;
|
||||
|
||||
|
|
|
@ -7,7 +7,21 @@
|
|||
#include "huagao/hgscanner_error.h"
|
||||
|
||||
|
||||
|
||||
static std::string StringToUtf(std::string strValue)
|
||||
{
|
||||
int nwLen = MultiByteToWideChar(CP_UTF8, 0, strValue.c_str(), -1, NULL, 0);
|
||||
wchar_t* pwBuf = new wchar_t[nwLen + 1];//¼ÓÉÏĩβ'\0'
|
||||
memset(pwBuf, 0, nwLen * 2 + 2);
|
||||
MultiByteToWideChar(CP_UTF8, 0, strValue.c_str(), strValue.length(), pwBuf, nwLen);
|
||||
int nLen = WideCharToMultiByte(CP_ACP, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
|
||||
char* pBuf = new char[nLen + 1];
|
||||
memset(pBuf, 0, nLen + 1);
|
||||
WideCharToMultiByte(CP_ACP, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
|
||||
std::string retStr = pBuf;
|
||||
delete[]pBuf;
|
||||
delete[]pwBuf;
|
||||
return retStr;
|
||||
}
|
||||
static int str_to_wchar(std::string str, wchar_t* s, size_t* strlen)
|
||||
{
|
||||
if (str.empty())
|
||||
|
@ -71,6 +85,7 @@ public:
|
|||
std::wstring wstr = L"";
|
||||
size_t l = 0;
|
||||
bool type = true;
|
||||
|
||||
int ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l);
|
||||
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
||||
ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l);
|
||||
|
@ -81,7 +96,7 @@ public:
|
|||
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), type);
|
||||
return -1;
|
||||
}
|
||||
wprintf(L"%s\r\n", wstr.c_str());
|
||||
//std::string str = StringToUtf((char*)data);
|
||||
switch (code)
|
||||
{
|
||||
case SANE_EVENT_SCAN_FINISHED:
|
||||
|
@ -128,6 +143,7 @@ public:
|
|||
else
|
||||
type = true;
|
||||
}
|
||||
|
||||
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), type);
|
||||
}
|
||||
break;
|
||||
|
@ -136,6 +152,15 @@ public:
|
|||
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), false);
|
||||
}
|
||||
break;
|
||||
case SANE_EVENT_STATUS:
|
||||
{
|
||||
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_FLAT_FIELD) == 0)
|
||||
{
|
||||
//std::string str = StringToUtf((char*)data);
|
||||
//h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_FALT_INFO, (void*)&str[0], type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SANE_EVENT_IMAGE_OK:
|
||||
{
|
||||
if ( wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0
|
||||
|
@ -537,7 +562,7 @@ public:
|
|||
/* ×Ô¶¯Æ½³¡Ð£Õý */
|
||||
int test_auto_flat_field(void *data)
|
||||
{
|
||||
return SCANNER_ERR_OK;
|
||||
return helper_->io_control(IO_CTRL_CODE_SET_AUTO_FALT, NULL, NULL);;
|
||||
}
|
||||
/* ÖØÆôÉ豸 */
|
||||
int test_reboot_device(void *data)
|
||||
|
|
Loading…
Reference in New Issue