扫描至对话框中实现颜色模式子文件夹

This commit is contained in:
luoliangyi 2022-05-14 13:57:49 +08:00
parent 73f8715fe3
commit dc0acb42a7
1 changed files with 21 additions and 9 deletions

View File

@ -690,6 +690,8 @@ void MainWindow::on_new_image(void *img)
HGImage image = (HGImage)img;
HGUInt dpi = 96;
QString colorModeName = QString(OPTION_VALUE_YSMS_24WCS);
SANE_Int num_dev_options = 0;
sane_control_option(cur_dev_.handle(), 0, SANE_ACTION_GET_VALUE, &num_dev_options, nullptr);
for (int i = 1; i < num_dev_options; ++i)
@ -698,21 +700,24 @@ void MainWindow::on_new_image(void *img)
if (nullptr == desp)
continue;
std::string title = Utf8ToStdString(desp->title);
TrimString(title);
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "title=%s", title.c_str());
if (SANE_TYPE_INT == desp->type)
{
SANE_Int value = 0;
sane_control_option(cur_dev_.handle(), i, SANE_ACTION_GET_VALUE, &value, nullptr);
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, " valueType=INT, value=%d", value);
if (0 == strcmp(title.c_str(), "分辨率"))
if (0 == strcmp(desp->title, OPTION_TITLE_FBL))
{
dpi = (HGUInt)value;
}
}
else if (SANE_TYPE_STRING == desp->type)
{
SANE_Char value[256];
sane_control_option(cur_dev_.handle(), i, SANE_ACTION_GET_VALUE, value, nullptr);
if (0 == strcmp(desp->title, OPTION_TITLE_YSMS))
{
colorModeName = QString(value);
}
}
}
HGBase_SetImageDpi(image, dpi, dpi);
@ -790,12 +795,19 @@ void MainWindow::on_new_image(void *img)
{
assert(m_scanFileName.isEmpty());
assert(nullptr == m_scanImgFmtWriter);
HGBase_CreateDir(getStdString(m_aquireIntoSaveParam.m_savePath).c_str());
QString savePath = m_aquireIntoSaveParam.m_savePath;
if (m_aquireIntoSaveParam.m_isUseSubfolderByColor)
{
savePath = getStdFileName(m_aquireIntoSaveParam.m_savePath + colorModeName + "/");
}
HGBase_CreateDir(getStdString(savePath).c_str());
QString scanFileName;
while (1)
{
scanFileName = QString(tr("%1%2%3.%4")).arg(m_aquireIntoSaveParam.m_savePath)
scanFileName = QString(tr("%1%2%3.%4")).arg(savePath)
.arg(m_aquireIntoSaveParam.m_fileNamePrefix)
.arg(m_aquireIntoSaveParam.m_fileNameStartIndex, m_aquireIntoSaveParam.m_fileNameDigits, 10, QLatin1Char('0'))
.arg(m_aquireIntoSaveParam.m_fileNameExt);