2024-02-21 10:13:38 +00:00
|
|
|
|
#include "mainwindow.h"
|
2024-02-05 01:46:44 +00:00
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include "base/HGUtility.h"
|
|
|
|
|
#include "imgfmt/HGImgFmt.h"
|
|
|
|
|
#include "HGUIGlobal.h"
|
|
|
|
|
#include "HGString.h"
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
|
|
: QMainWindow(parent)
|
|
|
|
|
, ui(new Ui::MainWindow)
|
|
|
|
|
, m_twainDSM(nullptr)
|
|
|
|
|
, m_twainDS(nullptr)
|
|
|
|
|
, m_cacheUuid("")
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
HGChar cacheUuid[256] = { 0 };
|
|
|
|
|
HGBase_GetUuid(cacheUuid, 256);
|
|
|
|
|
m_cacheUuid = cacheUuid;
|
|
|
|
|
|
2024-02-20 10:24:51 +00:00
|
|
|
|
updateUiEnable(false);
|
|
|
|
|
initCapbility();
|
|
|
|
|
|
2024-02-05 01:46:44 +00:00
|
|
|
|
QStringList capTypes = { "TWTY_INT8", "TWTY_UINT8", "TWTY_INT16", "TWTY_UINT16", "TWTY_INT32", "TWTY_UINT32", "TWTY_BOOL","TWTY_FIX32",
|
2024-02-22 09:49:56 +00:00
|
|
|
|
"TWTY_STR32", "TWTY_STR64", "TWTY_STR128", "TWTY_STR255", "UNSUPPORTED" };
|
2024-02-05 01:46:44 +00:00
|
|
|
|
|
|
|
|
|
ui->comboBox_capType->addItems(capTypes);
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(0);
|
|
|
|
|
ui->label_deviceStatus->setText(tr("No device connected"));
|
|
|
|
|
|
|
|
|
|
HGTwain_CreateDSM((HWND)this->winId(), &m_twainDSM);
|
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(newImage(void*)), this, SLOT(on_newImage(void*)), Qt::DirectConnection);
|
|
|
|
|
connect(this, SIGNAL(clearRes()), this, SLOT(on_clearRes()), Qt::QueuedConnection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
|
{
|
|
|
|
|
QString cachePath = getCachePath() + m_cacheUuid + "/";
|
|
|
|
|
QDir dir = QDir(cachePath);
|
|
|
|
|
if (dir.exists())
|
|
|
|
|
dir.removeRecursively();
|
|
|
|
|
|
|
|
|
|
if (m_twainDSM != nullptr)
|
|
|
|
|
{
|
|
|
|
|
HGTwain_DestroyDSM(m_twainDSM);
|
|
|
|
|
m_twainDSM = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_twainDS != nullptr)
|
|
|
|
|
{
|
|
|
|
|
HGTwain_CloseDS(m_twainDS);
|
|
|
|
|
HGTwain_DestroyDS(m_twainDS);
|
|
|
|
|
m_twainDS = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_act_selectDevice_triggered()
|
|
|
|
|
{
|
|
|
|
|
ui->label_deviceStatus->setText(tr("No device connected"));
|
2024-02-20 10:24:51 +00:00
|
|
|
|
updateUiEnable(false);
|
2024-02-05 01:46:44 +00:00
|
|
|
|
|
|
|
|
|
if (m_twainDS != nullptr)
|
|
|
|
|
{
|
|
|
|
|
HGTwain_CloseDS(m_twainDS);
|
|
|
|
|
HGTwain_DestroyDS(m_twainDS);
|
|
|
|
|
m_twainDS = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HGResult ret = HGTwain_CreateSelectedDSEx(m_twainDSM, &m_twainDS);
|
|
|
|
|
if (nullptr != m_twainDS)
|
|
|
|
|
{
|
|
|
|
|
HGResult ret = HGTwain_OpenDS(m_twainDS);
|
|
|
|
|
if (ret == HGBASE_ERR_OK)
|
|
|
|
|
{
|
|
|
|
|
HGTwain_LoginDS(m_twainDS, "user", "huagoscan");
|
|
|
|
|
ui->label_deviceStatus->setText(tr("Device %1 is open").arg(getDeviceName()));
|
2024-02-20 10:24:51 +00:00
|
|
|
|
updateUiEnable(true);
|
2024-02-05 01:46:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (HGTWAIN_ERR_CANCELUI != ret)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::information(this, tr("Prompt"), tr("Device source not found!"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-20 10:24:51 +00:00
|
|
|
|
void MainWindow::on_pushButton_setCap_clicked()
|
2024-02-05 01:46:44 +00:00
|
|
|
|
{
|
2024-02-22 09:49:56 +00:00
|
|
|
|
if (ui->lineEdit_setCapContent->text().isEmpty())
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::information(this, tr("Prompt"), tr("Input cannot be empty!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-20 10:24:51 +00:00
|
|
|
|
QString capCode = ui->comboBox_setCap->currentText();
|
2024-02-05 01:46:44 +00:00
|
|
|
|
bool ok = false;
|
2024-02-20 10:24:51 +00:00
|
|
|
|
HGUShort cap = capCode.left(6).toInt(&ok, 16);
|
2024-02-05 01:46:44 +00:00
|
|
|
|
|
2024-02-20 10:24:51 +00:00
|
|
|
|
HGCapValue value = getHGCapValue();
|
2024-02-05 01:46:44 +00:00
|
|
|
|
|
|
|
|
|
HGResult ret = HGTwain_SetCapbility(m_twainDS, cap, &value, ui->checkBox_resetCap->isChecked());
|
|
|
|
|
if (ret == HGBASE_ERR_OK)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::information(this, tr("Prompt"), tr("Set successfully"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::information(this, tr("Prompt"), tr("Set failed"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-20 10:24:51 +00:00
|
|
|
|
void MainWindow::on_pushButton_getCap_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString capCode = ui->comboBox_setCap->currentText();
|
|
|
|
|
bool ok = false;
|
|
|
|
|
HGUShort cap = capCode.left(6).toInt(&ok, 16);
|
|
|
|
|
|
|
|
|
|
HGCapValue value;
|
|
|
|
|
HGResult ret = HGTwain_GetCapbility(m_twainDS, cap, &value);
|
|
|
|
|
if (ret != HGBASE_ERR_OK)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::information(this, tr("Prompt"), tr("Get failed"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value.type == HGCAPVALUE_TYPE_CHAR)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(QString(value.valueChar));
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_BYTE)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(QString(value.valueByte));
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_SHORT)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(QString::number(value.valueShort));
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_USHORT)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(QString::number(value.valueUShort));
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_INT)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(QString::number(value.valueInt));
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_UINT)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(QString::number(value.valueUInt));
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_BOOL)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(value.valueBool ? QString("true") : QString("false"));
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_FLOAT)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(QString::number(value.valueFloat, 'f', 4));
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_STR32)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(QString::fromLocal8Bit(value.valueStr32));
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_STR64)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(QString::fromLocal8Bit(value.valueStr64));
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_STR128)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(QString::fromLocal8Bit(value.valueStr128));
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_STR255)
|
|
|
|
|
{
|
|
|
|
|
ui->lineEdit_getCapContent->setText(QString::fromLocal8Bit(value.valueStr255));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-22 09:49:56 +00:00
|
|
|
|
void MainWindow::on_pushButton_showUI_clicked()
|
|
|
|
|
{
|
|
|
|
|
HGTwain_EnableDSUIOnly(m_twainDS, (HWND)this->winId(), DSEventFunc, this);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-05 01:46:44 +00:00
|
|
|
|
void MainWindow::on_pushButton_scan_clicked()
|
|
|
|
|
{
|
2024-02-20 10:24:51 +00:00
|
|
|
|
HGTwain_EnableDS(m_twainDS, HGFALSE, (HWND)this->winId(), DSEventFunc, this, DSImageFunc, this);
|
2024-02-05 01:46:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-22 09:49:56 +00:00
|
|
|
|
void MainWindow::on_comboBox_setCap_currentTextChanged(const QString &arg1)
|
|
|
|
|
{
|
|
|
|
|
bool ok = false;
|
|
|
|
|
HGUShort cap = arg1.left(6).toInt(&ok, 16);
|
|
|
|
|
|
|
|
|
|
HGCapValue value;
|
|
|
|
|
HGResult ret = HGTwain_GetCapbility(m_twainDS, cap, &value);
|
|
|
|
|
if (ret != HGBASE_ERR_OK)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value.type == HGCAPVALUE_TYPE_CHAR)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_INT8")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
} }
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_BYTE)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_UINT8")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
} }
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_SHORT)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_INT16")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
} }
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_USHORT)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_UINT16")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
} }
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_INT)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_INT32")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
} }
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_UINT)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_UINT32")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
} }
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_BOOL)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_BOOL")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
} }
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_FLOAT)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_FIX32")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_STR32)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_STR32")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_STR64)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_STR64")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_STR128)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_STR128")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (value.type == HGCAPVALUE_TYPE_STR255)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "TWTY_STR255")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ui->comboBox_capType->count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ui->comboBox_capType->itemText(i) == "UNSOPPORTED")
|
|
|
|
|
ui->comboBox_capType->setCurrentIndex(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-05 01:46:44 +00:00
|
|
|
|
void MainWindow::on_newImage(void *image)
|
|
|
|
|
{
|
|
|
|
|
HGImage img = nullptr;
|
|
|
|
|
HGBase_CloneImage((HGImage)image, 0, 0, &img);
|
|
|
|
|
QString scanFileName = getCacheFileName((HGImage)image);
|
|
|
|
|
HGImgFmtSaveInfo info;
|
|
|
|
|
info.jpegQuality = 100;
|
|
|
|
|
info.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
|
|
|
|
info.tiffJpegQuality = 0;
|
2024-02-20 10:24:51 +00:00
|
|
|
|
HGImgFmt_SaveImage((HGImage)image, 0, &info, getStdString(scanFileName).c_str());
|
2024-02-05 01:46:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_clearRes()
|
|
|
|
|
{
|
|
|
|
|
HGTwain_DisableDS(m_twainDS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::DSEventFunc(HGTwainDS ds, HGUInt event, HGPointer param)
|
|
|
|
|
{
|
2024-02-20 10:24:51 +00:00
|
|
|
|
(void)ds;
|
2024-02-05 01:46:44 +00:00
|
|
|
|
MainWindow* p = (MainWindow*)param;
|
|
|
|
|
if (HGTWAIN_EVENT_TYPE_SCANFINISHED == event || HGTWAIN_EVENT_TYPE_CLOSEDSREQ == event)
|
|
|
|
|
{
|
|
|
|
|
emit p->clearRes();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HGUInt MainWindow::DSImageFunc(HGTwainDS ds, HGImage image, HGUInt type, HGPointer param)
|
|
|
|
|
{
|
2024-02-20 10:24:51 +00:00
|
|
|
|
(void)ds;
|
|
|
|
|
(void)type;
|
2024-02-05 01:46:44 +00:00
|
|
|
|
MainWindow* p = (MainWindow*)param;
|
|
|
|
|
emit p->newImage(image);
|
|
|
|
|
return HGBASE_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-20 10:24:51 +00:00
|
|
|
|
void MainWindow::initCapbility()
|
|
|
|
|
{
|
|
|
|
|
QStringList cap = {};
|
|
|
|
|
|
2024-02-21 10:13:38 +00:00
|
|
|
|
//标准协议↓↓↓
|
|
|
|
|
cap.append(QString("0x0001") + tr("(CAP_XFERCOUNT)"));
|
|
|
|
|
cap.append(QString("0x0100") + tr("(ICAP_COMPRESSION)"));
|
|
|
|
|
cap.append(QString("0x0101") + tr("(ICAP_PIXELTYPE)"));
|
|
|
|
|
cap.append(QString("0x0102") + tr("(ICAP_UNITS)"));
|
|
|
|
|
cap.append(QString("0x0103") + tr("(ICAP_XFERMECH)"));
|
|
|
|
|
|
|
|
|
|
cap.append(QString("0x1002") + tr("(CAP_FEEDERENABLED)"));
|
|
|
|
|
cap.append(QString("0x1003") + tr("(CAP_FEEDERLOADED)"));
|
|
|
|
|
cap.append(QString("0x1007") + tr("(CAP_AUTOFEED)"));
|
|
|
|
|
cap.append(QString("0x100b") + tr("(CAP_INDICATORS)"));
|
|
|
|
|
cap.append(QString("0x100d") + tr("(CAP_PAPERDETECTABLE)"));
|
|
|
|
|
cap.append(QString("0x100e") + tr("(CAP_UICONTROLLABLE)"));
|
|
|
|
|
cap.append(QString("0x100f") + tr("(CAP_DEVICEONLINE)"));
|
|
|
|
|
cap.append(QString("0x1010") + tr("(CAP_AUTOSCAN)"));
|
|
|
|
|
cap.append(QString("0x1012") + tr("(CAP_DUPLEX)"));
|
|
|
|
|
cap.append(QString("0x1013") + tr("(CAP_DUPLEXENABLED)"));
|
|
|
|
|
cap.append(QString("0x1014") + tr("(CAP_ENABLEDSUIONLY)"));
|
|
|
|
|
cap.append(QString("0x1015") + tr("(CAP_CUSTOMDSDATA)"));
|
|
|
|
|
cap.append(QString("0x1024") + tr("(CAP_SERIALNUMBER)"));
|
|
|
|
|
cap.append(QString("0x1101") + tr("(ICAP_BRIGHTNESS)"));
|
|
|
|
|
cap.append(QString("0x1103") + tr("(ICAP_CONTRAST)"));
|
|
|
|
|
cap.append(QString("0x1106") + tr("(ICAP_FILTER)"));
|
|
|
|
|
cap.append(QString("0x1108") + tr("(ICAP_GAMMA)"));
|
|
|
|
|
cap.append(QString("0x110c") + tr("(ICAP_IMAGEFILEFORMAT)"));
|
|
|
|
|
cap.append(QString("0x1110") + tr("(ICAP_ORIENTATION)"));
|
|
|
|
|
cap.append(QString("0x1111") + tr("(ICAP_PHYSICALWIDTH)"));
|
|
|
|
|
cap.append(QString("0x1112") + tr("(ICAP_PHYSICALHEIGHT)"));
|
|
|
|
|
cap.append(QString("0x1116") + tr("(ICAP_XNATIVERESOLUTION)"));
|
|
|
|
|
cap.append(QString("0x1117") + tr("(ICAP_YNATIVERESOLUTION)"));
|
|
|
|
|
cap.append(QString("0x1118") + tr("(ICAP_XRESOLUTION)"));
|
|
|
|
|
cap.append(QString("0x1119") + tr("(ICAP_YRESOLUTION)"));
|
|
|
|
|
cap.append(QString("0x111c") + tr("(ICAP_BITORDER)"));
|
|
|
|
|
cap.append(QString("0x111f") + tr("(ICAP_PIXELFLAVOR)"));
|
|
|
|
|
cap.append(QString("0x1120") + tr("(ICAP_PLANARCHUNKY)"));
|
|
|
|
|
cap.append(QString("0x1121") + tr("(ICAP_ROTATION)"));
|
|
|
|
|
cap.append(QString("0x1122") + tr("(ICAP_SUPPORTEDSIZES)"));
|
|
|
|
|
cap.append(QString("0x112b") + tr("(ICAP_BITDEPTH)"));
|
|
|
|
|
cap.append(QString("0x1134") + tr("(ICAP_AUTODISCARDBLANKPAGES)"));
|
|
|
|
|
cap.append(QString("0x1150") + tr("(ICAP_AUTOMATICBORDERDETECTION)"));
|
|
|
|
|
cap.append(QString("0x1151") + tr("(ICAP_AUTOMATICDESKEW)"));
|
|
|
|
|
cap.append(QString("0x1152") + tr("(ICAP_AUTOMATICROTATE)"));
|
|
|
|
|
cap.append(QString("0x1153") + tr("(ICAP_JpegQuality)"));
|
|
|
|
|
cap.append(QString("0x1156") + tr("(ICAP_AutoSize)"));
|
|
|
|
|
cap.append(QString("0x1157") + tr("(ICAP_AutomaticCropUsesFrame)"));
|
|
|
|
|
cap.append(QString("0x1159") + tr("(ICAP_AutomaticColorEnabled)"));
|
|
|
|
|
cap.append(QString("0x1151") + tr("(ICAP_AutomaticColorNonColorPixelType)"));
|
|
|
|
|
cap.append(QString("0x115e") + tr("(ICAP_SupportedExtImageInfo)"));
|
|
|
|
|
|
|
|
|
|
//扩展协议↓↓↓
|
2024-02-20 10:24:51 +00:00
|
|
|
|
cap.append(QString("0x8004") + tr("(FillBackground)"));
|
|
|
|
|
cap.append(QString("0x8005") + tr("(BackRotate180)"));
|
|
|
|
|
cap.append(QString("0x8006") + tr("(ScrewDetectEnable)"));
|
|
|
|
|
cap.append(QString("0x8007") + tr("(EnhanceColor)"));
|
|
|
|
|
cap.append(QString("0x8016") + tr("(DARK_SAMPLE)"));
|
|
|
|
|
cap.append(QString("0x8018") + tr("(FillHole)"));
|
|
|
|
|
cap.append(QString("0x8021") + tr("(ScrewLevel)"));
|
|
|
|
|
cap.append(QString("0x8022") + tr("(Sharpen)"));
|
|
|
|
|
cap.append(QString("0x8025") + tr("(HardwareVersion)"));
|
|
|
|
|
cap.append(QString("0x8026") + tr("(MultiOutputRed)"));
|
|
|
|
|
cap.append(QString("0x8037") + tr("(EnFold)"));
|
|
|
|
|
|
|
|
|
|
cap.append(QString("0x8090") + tr("(StableDetectEnable)"));
|
|
|
|
|
cap.append(QString("0x8091") + tr("(DiscardBlankVince)"));
|
|
|
|
|
cap.append(QString("0x8092") + tr("(FillHoleRatio)"));
|
|
|
|
|
cap.append(QString("0x8094") + tr("(SwitchFrontBack)"));
|
|
|
|
|
cap.append(QString("0x8095") + tr("(HsvCorrect)"));
|
|
|
|
|
cap.append(QString("0x8096") + tr("(DogEarDelection)"));
|
|
|
|
|
cap.append(QString("0x8097") + tr("(FillBackgroundMode)"));
|
|
|
|
|
cap.append(QString("0x8098") + tr("(CroporDesaskewIndent)"));
|
|
|
|
|
cap.append(QString("0x8099") + tr("(CropNoise)"));
|
|
|
|
|
cap.append(QString("0x8100") + tr("(CroporDesaskewThreshold)"));
|
|
|
|
|
cap.append(QString("0x8101") + tr("(DetachNoise)"));
|
|
|
|
|
cap.append(QString("0x8102") + tr("(DetachNoiseValue)"));
|
|
|
|
|
cap.append(QString("0x8103") + tr("(SizeDetect)"));
|
|
|
|
|
cap.append(QString("0x8104") + tr("(LowPowerMode)"));
|
|
|
|
|
cap.append(QString("0x8105") + tr("(ENCODE)"));
|
|
|
|
|
cap.append(QString("0x8106") + tr("(CropModel)"));
|
|
|
|
|
cap.append(QString("0x8107") + tr("(DogEarDistance)"));
|
|
|
|
|
cap.append(QString("0x8108") + tr("(ImageSplit)"));
|
|
|
|
|
cap.append(QString("0x8109") + tr("(FadeBackground)"));
|
|
|
|
|
cap.append(QString("0x8110") + tr("(FADE_BKG_VALUE)"));
|
|
|
|
|
cap.append(QString("0x8111") + tr("(TO_BE_SCAN)"));
|
|
|
|
|
cap.append(QString("0x8112") + tr("(MULTI_OUT)"));
|
|
|
|
|
cap.append(QString("0x8113") + tr("(MULTI_OUT_TYPE)"));
|
|
|
|
|
cap.append(QString("0x8114") + tr("(SCAN_WITH_HOLE)"));
|
|
|
|
|
cap.append(QString("0x8200") + tr("(IP)"));
|
|
|
|
|
|
2024-02-21 10:13:38 +00:00
|
|
|
|
cap.append(QString("0x8801") + tr("(is_multiout)"));
|
|
|
|
|
cap.append(QString("0x8802") + tr("(multiout_type)"));
|
|
|
|
|
cap.append(QString("0x8803") + tr("(color_mode)"));
|
|
|
|
|
cap.append(QString("0x8804") + tr("erase_color"));
|
|
|
|
|
cap.append(QString("0x8805") + tr("(erase_multiout_red)"));
|
|
|
|
|
cap.append(QString("0x8806") + tr("(erase_paper_red)"));
|
|
|
|
|
cap.append(QString("0x8807") + tr("(is_erase_background)"));
|
|
|
|
|
cap.append(QString("0x8808") + tr("(background_color_range)"));
|
|
|
|
|
cap.append(QString("0x8809") + tr("(sharpen)"));
|
|
|
|
|
cap.append(QString("0x880A") + tr("(erase_morr)"));
|
|
|
|
|
cap.append(QString("0x880B") + tr("(erase_grids)"));
|
|
|
|
|
cap.append(QString("0x880C") + tr("(error_extend)"));
|
|
|
|
|
cap.append(QString("0x880D") + tr("(is_noise_modify)"));
|
|
|
|
|
cap.append(QString("0x880E") + tr("(noise_threshold)"));
|
|
|
|
|
cap.append(QString("0x880F") + tr("(paper)"));
|
|
|
|
|
cap.append(QString("0x8810") + tr("(is_custom_area)"));
|
|
|
|
|
cap.append(QString("0x8811") + tr("(curstom_area_l)"));
|
|
|
|
|
cap.append(QString("0x8812") + tr("(curstom_area_r)"));
|
|
|
|
|
cap.append(QString("0x8813") + tr("(curstom_area_t)"));
|
|
|
|
|
cap.append(QString("0x8814") + tr("(curstom_area_b)"));
|
|
|
|
|
cap.append(QString("0x8815") + tr("(is_size_check)"));
|
|
|
|
|
cap.append(QString("0x8816") + tr("(page)"));
|
|
|
|
|
cap.append(QString("0x8817") + tr("(blank_page_threshold)"));
|
|
|
|
|
cap.append(QString("0x8818") + tr("(resolution)"));
|
|
|
|
|
cap.append(QString("0x8819") + tr("(image_quality)"));
|
|
|
|
|
cap.append(QString("0x881A") + tr("(is_swap)"));
|
|
|
|
|
cap.append(QString("0x881B") + tr("(is_split)"));
|
|
|
|
|
cap.append(QString("0x881C") + tr("(is_auto_deskew)"));
|
|
|
|
|
cap.append(QString("0x881D") + tr("(is_custom_gamma)"));
|
|
|
|
|
cap.append(QString("0x881E") + tr("(bright)"));
|
|
|
|
|
cap.append(QString("0x881F") + tr("(contrast)"));
|
|
|
|
|
cap.append(QString("0x8820") + tr("(gamma)"));
|
|
|
|
|
cap.append(QString("0x8821") + tr("(is_erase_black_frame)"));
|
|
|
|
|
cap.append(QString("0x8822") + tr("(deep_sample)"));
|
|
|
|
|
cap.append(QString("0x8823") + tr("(threshold)"));
|
|
|
|
|
cap.append(QString("0x8824") + tr("(anti_noise)"));
|
|
|
|
|
cap.append(QString("0x8825") + tr("(margin)"));
|
|
|
|
|
cap.append(QString("0x8826") + tr("(fill_background)"));
|
|
|
|
|
cap.append(QString("0x8827") + tr("(is_anti_permeate)"));
|
|
|
|
|
cap.append(QString("0x8828") + tr("(anti_permeate_level)"));
|
|
|
|
|
cap.append(QString("0x882B") + tr("(is_filling_color)"));
|
|
|
|
|
cap.append(QString("0x882C") + tr("(is_ultrasonic_check)"));
|
|
|
|
|
cap.append(QString("0x882D") + tr("(is_check_staple)"));
|
|
|
|
|
cap.append(QString("0x882E") + tr("(scan_mode)"));
|
|
|
|
|
cap.append(QString("0x882F") + tr("(scan_count)"));
|
|
|
|
|
cap.append(QString("0x8830") + tr("(text_direction)"));
|
|
|
|
|
cap.append(QString("0x8831") + tr("(is_rotate_bkg180)"));
|
|
|
|
|
cap.append(QString("0x8832") + tr("(is_check_dogear)"));
|
|
|
|
|
cap.append(QString("0x8833") + tr("(dogear_size)"));
|
|
|
|
|
cap.append(QString("0x8834") + tr("(is_check_skew)"));
|
|
|
|
|
cap.append(QString("0x8835") + tr("(skew_range)"));
|
|
|
|
|
cap.append(QString("0x8836") + tr("(black_white_threshold)"));
|
|
|
|
|
cap.append(QString("0x8837") + tr("(is_photo_mode)"));
|
|
|
|
|
cap.append(QString("0x8838") + tr("(double_feed_handle)"));
|
|
|
|
|
cap.append(QString("0x8839") + tr("(scan_when_paper_on)"));
|
|
|
|
|
cap.append(QString("0x883A") + tr("(feed_strength)"));
|
|
|
|
|
cap.append(QString("0x883B") + tr("(power_scheme)"));
|
|
|
|
|
cap.append(QString("0x883C") + tr("(is_auto_strength)"));
|
|
|
|
|
cap.append(QString("0x883D") + tr("(feed_strength_value)"));
|
|
|
|
|
cap.append(QString("0x883E") + tr("(is_reverse_bw)"));
|
|
|
|
|
cap.append(QString("0x883F") + tr("(is_erase_hole_l)"));
|
|
|
|
|
cap.append(QString("0x8840") + tr("(search_hole_range_l)"));
|
|
|
|
|
cap.append(QString("0x8841") + tr("(is_erase_hole_r)"));
|
|
|
|
|
cap.append(QString("0x8842") + tr("(search_hole_range_r)"));
|
|
|
|
|
cap.append(QString("0x8843") + tr("(is_erase_hole_t)"));
|
|
|
|
|
cap.append(QString("0x8844") + tr("(search_hole_range_t)"));
|
|
|
|
|
cap.append(QString("0x8845") + tr("(is_erase_hole_b)"));
|
|
|
|
|
cap.append(QString("0x8846") + tr("(search_hole_range_b)"));
|
|
|
|
|
cap.append(QString("0x8847") + tr("(fold_direction)"));
|
|
|
|
|
cap.append(QString("0x8848") + tr("(color_correction)"));
|
|
|
|
|
cap.append(QString("0x8849") + tr("(history_count)"));
|
|
|
|
|
cap.append(QString("0x884A") + tr("(driver_version)"));
|
|
|
|
|
cap.append(QString("0x884B") + tr("(manufacturer)"));
|
|
|
|
|
cap.append(QString("0x884C") + tr("(copyright)"));
|
|
|
|
|
cap.append(QString("0x884D") + tr("(company_url)"));
|
|
|
|
|
cap.append(QString("0x884E") + tr("(company_tel)"));
|
|
|
|
|
cap.append(QString("0x884F") + tr("(company_addr)"));
|
|
|
|
|
cap.append(QString("0x8850") + tr("(gps)"));
|
|
|
|
|
cap.append(QString("0x8851") + tr("(help)"));
|
|
|
|
|
cap.append(QString("0x8852") + tr("(dev_vid)"));
|
|
|
|
|
cap.append(QString("0x8853") + tr("(dev_pid)"));
|
|
|
|
|
cap.append(QString("0x8854") + tr("(dev_name)"));
|
|
|
|
|
cap.append(QString("0x8855") + tr("(dev_family)"));
|
|
|
|
|
cap.append(QString("0x8856") + tr("(Device_sn)"));
|
|
|
|
|
cap.append(QString("0x8857") + tr("(Firm_ver)"));
|
|
|
|
|
cap.append(QString("0x8858") + tr("(IP_addr)"));
|
|
|
|
|
cap.append(QString("0x8859") + tr("(MAC_addr)"));
|
|
|
|
|
cap.append(QString("0x885A") + tr("(CUSTOM_GAMMA)"));
|
|
|
|
|
cap.append(QString("0x885B") + tr("(ROLLER_LIFE)"));
|
|
|
|
|
cap.append(QString("0x885C") + tr("(LANGUAGE)"));
|
|
|
|
|
cap.append(QString("0x885D") + tr("(MOTOR_VER)"));
|
|
|
|
|
cap.append(QString("0x8860") + tr("(PAPER_ON)"));
|
|
|
|
|
cap.append(QString("0x8861") + tr("(GRAY_GAMMA)"));
|
|
|
|
|
cap.append(QString("0x8862") + tr("(COLOR_GAMMA)"));
|
|
|
|
|
cap.append(QString("0x8863") + tr("(RED_GAMMA)"));
|
|
|
|
|
cap.append(QString("0x8864") + tr("(GREEN_GAMMA)"));
|
|
|
|
|
cap.append(QString("0x8865") + tr("(BLUE_GAMMA)"));
|
|
|
|
|
cap.append(QString("0x8866") + tr("(INITIAL_BOOT_TIME)"));
|
|
|
|
|
cap.append(QString("0x8867") + tr("(DISCARDBLANK)"));
|
|
|
|
|
cap.append(QString("0x8868") + tr("(LENS_DIRTY)"));
|
|
|
|
|
|
|
|
|
|
cap.append(QString("0x9900") + tr("(login)"));
|
|
|
|
|
cap.append(QString("0x9901") + tr("(logout)"));
|
|
|
|
|
cap.append(QString("0x9902") + tr("(roller_count)"));
|
|
|
|
|
cap.append(QString("0x9903") + tr("(driver_log)"));
|
|
|
|
|
cap.append(QString("0x9904") + tr("(device_log)"));
|
2024-02-20 10:24:51 +00:00
|
|
|
|
|
|
|
|
|
ui->comboBox_setCap->addItems(cap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HGCapValue MainWindow::getHGCapValue()
|
|
|
|
|
{
|
|
|
|
|
HGCapValue value;
|
|
|
|
|
QString capType = ui->comboBox_capType->currentText();
|
|
|
|
|
if (capType == "TWTY_INT8")
|
|
|
|
|
{
|
|
|
|
|
value.type = HGCAPVALUE_TYPE_CHAR;
|
|
|
|
|
QString text = ui->lineEdit_setCapContent->text();
|
|
|
|
|
if (!text.isEmpty())
|
|
|
|
|
value.valueChar = text.at(0).toLatin1();
|
|
|
|
|
}
|
|
|
|
|
else if (capType == "TWTY_UINT8")
|
|
|
|
|
{
|
|
|
|
|
value.type = HGCAPVALUE_TYPE_BYTE;
|
|
|
|
|
QString text = ui->lineEdit_setCapContent->text();
|
|
|
|
|
if (!text.isEmpty())
|
|
|
|
|
value.valueChar = text.at(0).toLatin1();
|
|
|
|
|
}
|
|
|
|
|
else if (capType == "TWTY_UINT8")
|
|
|
|
|
{
|
|
|
|
|
value.type = HGCAPVALUE_TYPE_SHORT;
|
|
|
|
|
value.valueShort = ui->lineEdit_setCapContent->text().toShort();
|
|
|
|
|
}
|
|
|
|
|
else if (capType == "TWTY_INT16")
|
|
|
|
|
{
|
|
|
|
|
value.type = HGCAPVALUE_TYPE_USHORT;
|
|
|
|
|
value.valueUShort = ui->lineEdit_setCapContent->text().toUShort();
|
|
|
|
|
}
|
|
|
|
|
else if (capType == "TWTY_INT32")
|
|
|
|
|
{
|
|
|
|
|
value.type = HGCAPVALUE_TYPE_INT;
|
|
|
|
|
value.valueInt = ui->lineEdit_setCapContent->text().toInt();
|
|
|
|
|
}
|
|
|
|
|
else if (capType == "TWTY_UINT32")
|
|
|
|
|
{
|
|
|
|
|
value.type = HGCAPVALUE_TYPE_UINT;
|
|
|
|
|
value.valueUInt = ui->lineEdit_setCapContent->text().toUInt();
|
|
|
|
|
}
|
|
|
|
|
else if (capType == "TWTY_BOOL")
|
|
|
|
|
{
|
|
|
|
|
value.type = HGCAPVALUE_TYPE_BOOL;
|
|
|
|
|
value.valueBool = (HGBool)ui->lineEdit_setCapContent->text().toInt();
|
|
|
|
|
}
|
|
|
|
|
else if (capType == "TWTY_FIX32")
|
|
|
|
|
{
|
|
|
|
|
value.type = HGCAPVALUE_TYPE_FLOAT;
|
|
|
|
|
value.valueFloat = ui->lineEdit_setCapContent->text().toFloat();
|
|
|
|
|
}
|
|
|
|
|
else if (capType == "TWTY_STR32")
|
|
|
|
|
{
|
2024-02-22 02:13:42 +00:00
|
|
|
|
value.type = HGCAPVALUE_TYPE_STR32;
|
|
|
|
|
strcpy(value.valueStr32, ui->lineEdit_setCapContent->text().toLocal8Bit().toStdString().c_str());
|
2024-02-20 10:24:51 +00:00
|
|
|
|
}
|
|
|
|
|
else if (capType == "TWTY_STR64")
|
|
|
|
|
{
|
2024-02-22 02:13:42 +00:00
|
|
|
|
value.type = HGCAPVALUE_TYPE_STR64;
|
|
|
|
|
strcpy(value.valueStr64, ui->lineEdit_setCapContent->text().toLocal8Bit().toStdString().c_str());
|
2024-02-20 10:24:51 +00:00
|
|
|
|
}
|
|
|
|
|
else if (capType == "TWTY_STR128")
|
|
|
|
|
{
|
2024-02-22 02:13:42 +00:00
|
|
|
|
value.type = HGCAPVALUE_TYPE_STR128;
|
|
|
|
|
strcpy(value.valueStr128, ui->lineEdit_setCapContent->text().toLocal8Bit().toStdString().c_str());
|
2024-02-20 10:24:51 +00:00
|
|
|
|
}
|
|
|
|
|
else if (capType == "TWTY_STR255")
|
|
|
|
|
{
|
2024-02-22 02:13:42 +00:00
|
|
|
|
value.type = HGCAPVALUE_TYPE_STR255;
|
|
|
|
|
strcpy(value.valueStr255, ui->lineEdit_setCapContent->text().toLocal8Bit().toStdString().c_str());
|
2024-02-20 10:24:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::updateUiEnable(bool enable)
|
|
|
|
|
{
|
|
|
|
|
ui->pushButton_setCap->setEnabled(enable);
|
|
|
|
|
ui->pushButton_getCap->setEnabled(enable);
|
|
|
|
|
ui->pushButton_scan->setEnabled(enable);
|
2024-02-22 09:49:56 +00:00
|
|
|
|
ui->pushButton_showUI->setEnabled(enable);
|
2024-02-20 10:24:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-05 01:46:44 +00:00
|
|
|
|
QString MainWindow::getDeviceName()
|
|
|
|
|
{
|
|
|
|
|
HGChar devName[256] = {0};
|
|
|
|
|
HGTwain_GetDSDeviceName(m_twainDS, devName, 256);
|
|
|
|
|
return QString(devName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MainWindow::getCachePath()
|
|
|
|
|
{
|
|
|
|
|
HGChar cachePath[512];
|
|
|
|
|
HGBase_GetDocumentsPath(cachePath, 512);
|
|
|
|
|
HGChar procName[512];
|
|
|
|
|
HGBase_GetProcessName(procName, 512);
|
|
|
|
|
strcat(cachePath, procName);
|
|
|
|
|
strcat(cachePath, "/Cache/");
|
|
|
|
|
|
|
|
|
|
return getStdFileName(StdStringToUtf8(cachePath).c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MainWindow::getCacheFileName(HGImage img)
|
|
|
|
|
{
|
|
|
|
|
assert(nullptr != img);
|
|
|
|
|
|
|
|
|
|
HGImageInfo imgInfo;
|
|
|
|
|
HGBase_GetImageInfo(img, &imgInfo);
|
|
|
|
|
|
|
|
|
|
QString cachePath = getCachePath() + m_cacheUuid + "/";
|
|
|
|
|
HGBase_CreateDir(getStdString(cachePath).c_str());
|
|
|
|
|
|
|
|
|
|
char uuid[256] = {0};
|
|
|
|
|
HGBase_GetUuid(uuid, 256);
|
|
|
|
|
QString suffix = (HGBASE_IMGTYPE_BINARY == imgInfo.type) ? ".bmp" : ".jpg";
|
|
|
|
|
QString fileName = getStdFileName(cachePath + uuid + suffix);
|
|
|
|
|
return fileName;
|
|
|
|
|
}
|