修改保存文件流程,提高保存速度
This commit is contained in:
parent
04673e47f2
commit
4c1de12a5c
|
@ -1,6 +1,7 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "imgfmt/HGImgFmt.h"
|
#include "imgfmt/HGImgFmt.h"
|
||||||
|
#include "base/HGTime.h"
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
|
@ -106,8 +107,32 @@ void MainWindow::on_pushButton_selectDev_clicked()
|
||||||
|
|
||||||
void MainWindow::on_pushButton_setting_clicked()
|
void MainWindow::on_pushButton_setting_clicked()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if (nullptr != m_devUser)
|
if (nullptr != m_devUser)
|
||||||
m_devUser->ShowSettingDlg();
|
m_devUser->ShowSettingDlg();
|
||||||
|
#else
|
||||||
|
HGImage img = NULL;
|
||||||
|
HGULonglong t1;
|
||||||
|
HGBase_GetTickCount(&t1);
|
||||||
|
HGImgFmt_LoadImage("D:\\1.bmp", 0, NULL, 0, 0, &img);
|
||||||
|
HGULonglong t2;
|
||||||
|
HGBase_GetTickCount(&t2);
|
||||||
|
HGDouble seconds;
|
||||||
|
HGBase_GetIntervalSeconds(t1, t2, &seconds);
|
||||||
|
qDebug("HGImgFmt_LoadImage seconds=%f", seconds);
|
||||||
|
if (nullptr != img)
|
||||||
|
{
|
||||||
|
HGULonglong t1;
|
||||||
|
HGBase_GetTickCount(&t1);
|
||||||
|
HGImgFmt_SaveImage(img, 0, NULL, "D:\\2.jpg");
|
||||||
|
HGULonglong t2;
|
||||||
|
HGBase_GetTickCount(&t2);
|
||||||
|
HGDouble seconds;
|
||||||
|
HGBase_GetIntervalSeconds(t1, t2, &seconds);
|
||||||
|
qDebug("HGImgFmt_SaveImage seconds=%f", seconds);
|
||||||
|
HGBase_DestroyImage(img);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_pushButton_scan_clicked()
|
void MainWindow::on_pushButton_scan_clicked()
|
||||||
|
|
|
@ -1137,26 +1137,26 @@ HGResult HGImgThumb::getItemCount(int *count)
|
||||||
return HGBASE_ERR_OK;
|
return HGBASE_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGResult HGImgThumb::addItem(const QString &fileName)
|
HGResult HGImgThumb::addItem(const QString &fileName, bool notifyCurrentItem)
|
||||||
{
|
{
|
||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
fileNames.append(fileName);
|
fileNames.append(fileName);
|
||||||
return addItems(fileNames);
|
return addItems(fileNames, notifyCurrentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
HGResult HGImgThumb::addItems(const QStringList &fileNames)
|
HGResult HGImgThumb::addItems(const QStringList &fileNames, bool notifyCurrentItem)
|
||||||
{
|
{
|
||||||
return insertItems(fileNames, (int)m_frontItems.size(), true);
|
return insertItems(fileNames, (int)m_frontItems.size(), true, notifyCurrentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
HGResult HGImgThumb::insertItem(const QString &fileName, int pos)
|
HGResult HGImgThumb::insertItem(const QString &fileName, int pos, bool notifyCurrentItem)
|
||||||
{
|
{
|
||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
fileNames.append(fileName);
|
fileNames.append(fileName);
|
||||||
return insertItems(fileNames, pos);
|
return insertItems(fileNames, pos, false, notifyCurrentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
HGResult HGImgThumb::insertItems(const QStringList &fileNames, int pos, bool append)
|
HGResult HGImgThumb::insertItems(const QStringList &fileNames, int pos, bool append, bool notifyCurrentItem)
|
||||||
{
|
{
|
||||||
if (pos < 0 || pos > (int)m_frontItems.size())
|
if (pos < 0 || pos > (int)m_frontItems.size())
|
||||||
{
|
{
|
||||||
|
@ -1340,9 +1340,12 @@ HGResult HGImgThumb::insertItems(const QStringList &fileNames, int pos, bool app
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos != posEx)
|
if (pos != posEx)
|
||||||
|
{
|
||||||
|
if (notifyCurrentItem)
|
||||||
{
|
{
|
||||||
m_curItemIndex = posEx - 1;
|
m_curItemIndex = posEx - 1;
|
||||||
m_signItemIndex = posEx - 1;
|
m_signItemIndex = posEx - 1;
|
||||||
|
}
|
||||||
|
|
||||||
int showWidth = 0, showHeight = 0;
|
int showWidth = 0, showHeight = 0;
|
||||||
calcShowSize(this->width(), this->height(), m_gapSize, m_scrollSize, m_itemSize, m_itemTextHeight, m_type, (int)m_frontItems.size(),
|
calcShowSize(this->width(), this->height(), m_gapSize, m_scrollSize, m_itemSize, m_itemTextHeight, m_type, (int)m_frontItems.size(),
|
||||||
|
@ -4637,7 +4640,7 @@ QRect HGImgThumb::getNullScrollPos()
|
||||||
|
|
||||||
void HGImgThumb::Show()
|
void HGImgThumb::Show()
|
||||||
{
|
{
|
||||||
repaint();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HGAPI HGImgThumb::ThreadFunc(HGThread thread, HGPointer param)
|
void HGAPI HGImgThumb::ThreadFunc(HGThread thread, HGPointer param)
|
||||||
|
|
|
@ -53,10 +53,10 @@ public:
|
||||||
HGResult zoomOut();
|
HGResult zoomOut();
|
||||||
|
|
||||||
HGResult getItemCount(int *count);
|
HGResult getItemCount(int *count);
|
||||||
HGResult addItem(const QString &fileName);
|
HGResult addItem(const QString &fileName, bool notifyCurrentItem = true);
|
||||||
HGResult addItems(const QStringList &fileNames);
|
HGResult addItems(const QStringList &fileNames, bool notifyCurrentItem = true);
|
||||||
HGResult insertItem(const QString &fileName, int pos);
|
HGResult insertItem(const QString &fileName, int pos, bool notifyCurrentItem = true);
|
||||||
HGResult insertItems(const QStringList &fileNames, int pos, bool append = false);
|
HGResult insertItems(const QStringList &fileNames, int pos, bool append = false, bool notifyCurrentItem = true);
|
||||||
HGResult moveItems(const QStringList &fileNames, int pos);
|
HGResult moveItems(const QStringList &fileNames, int pos);
|
||||||
HGResult moveItemsTo(const QStringList &fileNames, int index);
|
HGResult moveItemsTo(const QStringList &fileNames, int index);
|
||||||
HGResult getItemFileName(int index, QString &fileName);
|
HGResult getItemFileName(int index, QString &fileName);
|
||||||
|
|
|
@ -33,8 +33,6 @@ DeviceUser::DeviceUser(QWidget *wnd, HGTwainDS ds, QString password)
|
||||||
m_wnd = wnd;
|
m_wnd = wnd;
|
||||||
m_twainDS = ds;
|
m_twainDS = ds;
|
||||||
m_password = password;
|
m_password = password;
|
||||||
|
|
||||||
connect(this, SIGNAL(closeReq()), this, SLOT(on_closeReq()), Qt::QueuedConnection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceUser::~DeviceUser()
|
DeviceUser::~DeviceUser()
|
||||||
|
@ -129,18 +127,7 @@ void HGAPI DeviceUser::DSCloseReqFunc(HGTwainDS ds, HGPointer param)
|
||||||
void HGAPI DeviceUser::DSImageFunc(HGTwainDS ds, HGImage image, HGPointer param)
|
void HGAPI DeviceUser::DSImageFunc(HGTwainDS ds, HGImage image, HGPointer param)
|
||||||
{
|
{
|
||||||
DeviceUser* p = (DeviceUser*)param;
|
DeviceUser* p = (DeviceUser*)param;
|
||||||
HGImage image2 = nullptr;
|
emit p->newImage(image);
|
||||||
HGBase_CloneImage(image, 0, 0, &image2);
|
|
||||||
if (nullptr != image2)
|
|
||||||
{
|
|
||||||
emit p->newImage(image2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceUser::on_closeReq()
|
|
||||||
{
|
|
||||||
// std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
||||||
// HGTwain_DisableDS(m_twainDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -289,12 +276,7 @@ HGResult DeviceUser::ClearDeviceLog()
|
||||||
void HGAPI DeviceUser::DeviceImageFunc(HGSaneDevice dev, HGImage image, HGPointer param)
|
void HGAPI DeviceUser::DeviceImageFunc(HGSaneDevice dev, HGImage image, HGPointer param)
|
||||||
{
|
{
|
||||||
DeviceUser* p = (DeviceUser*)param;
|
DeviceUser* p = (DeviceUser*)param;
|
||||||
HGImage image2 = nullptr;
|
emit p->newImage(image);
|
||||||
HGBase_CloneImage(image, 0, 0, &image2);
|
|
||||||
if (nullptr != image2)
|
|
||||||
{
|
|
||||||
emit p->newImage(image2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -56,10 +56,6 @@ private:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void newImage(void *image);
|
void newImage(void *image);
|
||||||
void closeReq();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_closeReq();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_wnd;
|
QWidget *m_wnd;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "dialog_savemessagebox.h"
|
#include "dialog_savemessagebox.h"
|
||||||
#include "base/HGInfo.h"
|
#include "base/HGInfo.h"
|
||||||
#include "huagao/hgscanner_error.h"
|
#include "huagao/hgscanner_error.h"
|
||||||
|
#include "base/HGTime.h"
|
||||||
#include "imgfmt/HGPdf.h"
|
#include "imgfmt/HGPdf.h"
|
||||||
#include "imgfmt/HGTiff.h"
|
#include "imgfmt/HGTiff.h"
|
||||||
#include "imgfmt/HGImgFmt.h"
|
#include "imgfmt/HGImgFmt.h"
|
||||||
|
@ -65,7 +66,6 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent)
|
||||||
, m_singleScan(false)
|
, m_singleScan(false)
|
||||||
, m_scanType(0)
|
, m_scanType(0)
|
||||||
, m_scanInsertPos(-1)
|
, m_scanInsertPos(-1)
|
||||||
, m_saveType(0)
|
|
||||||
, m_scanFileName("")
|
, m_scanFileName("")
|
||||||
, m_scanImgFmtWriter(nullptr)
|
, m_scanImgFmtWriter(nullptr)
|
||||||
, m_isScanning(false)
|
, m_isScanning(false)
|
||||||
|
@ -326,8 +326,7 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent)
|
||||||
|
|
||||||
ui->act_consume->setVisible(false);
|
ui->act_consume->setVisible(false);
|
||||||
|
|
||||||
connect(this, SIGNAL(pre_new_image(void*)), this, SLOT(on_pre_new_image(void*)), Qt::BlockingQueuedConnection);
|
connect(this, SIGNAL(post_new_image(QString)), this, SLOT(on_post_new_image(QString)));
|
||||||
connect(this, SIGNAL(post_new_image(unsigned int)), this, SLOT(on_post_new_image(unsigned int)), Qt::BlockingQueuedConnection);
|
|
||||||
|
|
||||||
m_wndStatusBar->setDeviceStatusInfo(tr("nodevice"), false);
|
m_wndStatusBar->setDeviceStatusInfo(tr("nodevice"), false);
|
||||||
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "%s", getStdString(tr("nodevice")).c_str());
|
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "%s", getStdString(tr("nodevice")).c_str());
|
||||||
|
@ -968,17 +967,55 @@ void MainWindow::on_clearCache()
|
||||||
m_thumb->removeItems(removeItems, HGImgThumb::ThumbRemoveFlag_NULL);
|
m_thumb->removeItems(removeItems, HGImgThumb::ThumbRemoveFlag_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_pre_new_image(void* img)
|
void MainWindow::on_post_new_image(QString fileName)
|
||||||
{
|
{
|
||||||
m_saveType = 0;
|
HGULonglong t1;
|
||||||
|
HGBase_GetTickCount(&t1);
|
||||||
HGImage image = (HGImage)img;
|
qDebug("on_post_new_image start, m_currScanCount=%d", m_currScanCount);
|
||||||
|
|
||||||
if (1 == m_scanType)
|
if (1 == m_scanType)
|
||||||
{
|
{
|
||||||
m_scanFileName = getCacheFileName(image);
|
if (-1 == m_scanInsertPos)
|
||||||
m_saveType = 1;
|
{
|
||||||
return;
|
m_thumb->addItem(fileName, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_thumb->insertItem(fileName, m_scanInsertPos, false);
|
||||||
|
++m_scanInsertPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (2 == m_scanType)
|
||||||
|
{
|
||||||
|
m_thumb->addItem(fileName, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
HGULonglong t2;
|
||||||
|
HGBase_GetTickCount(&t2);
|
||||||
|
HGDouble seconds;
|
||||||
|
HGBase_GetIntervalSeconds(t1, t2, &seconds);
|
||||||
|
qDebug("on_post_new_image end, m_currScanCount=%d, seconds=%f", m_currScanCount, seconds);
|
||||||
|
m_currScanCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_newImage(void *image)
|
||||||
|
{
|
||||||
|
HGULonglong t1;
|
||||||
|
HGBase_GetTickCount(&t1);
|
||||||
|
qDebug("on_newImage start, m_currScanCount=%d", m_currScanCount);
|
||||||
|
|
||||||
|
if (1 == m_scanType)
|
||||||
|
{
|
||||||
|
m_scanFileName = getCacheFileName((HGImage)image);
|
||||||
|
|
||||||
|
HGImgFmtSaveInfo info;
|
||||||
|
info.jpegQuality = 100;
|
||||||
|
info.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
||||||
|
info.tiffJpegQuality = 0;
|
||||||
|
if (HGBASE_ERR_OK == HGImgFmt_SaveImage((HGImage)image, 0, &info, getStdString(m_scanFileName).c_str()))
|
||||||
|
{
|
||||||
|
emit post_new_image(m_scanFileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (2 == m_scanType)
|
else if (2 == m_scanType)
|
||||||
{
|
{
|
||||||
|
@ -991,23 +1028,10 @@ void MainWindow::on_pre_new_image(void* img)
|
||||||
|
|
||||||
if (m_aquireIntoSaveParam.m_isSaveAsMultiPage)
|
if (m_aquireIntoSaveParam.m_isSaveAsMultiPage)
|
||||||
{
|
{
|
||||||
if (1 == m_aquireIntoSaveParam.m_multiPagesType && m_aquireIntoMultiPageCount == m_aquireIntoSaveParam.m_customMultiPages)
|
|
||||||
{
|
|
||||||
if (nullptr != m_scanImgFmtWriter)
|
|
||||||
{
|
|
||||||
HGImgFmt_CloseImageWriter(m_scanImgFmtWriter);
|
|
||||||
m_scanImgFmtWriter = nullptr;
|
|
||||||
m_thumb->addItem(m_scanFileName);
|
|
||||||
m_scanFileName.clear();
|
|
||||||
++m_aquireIntoSaveParam.m_fileNameStartIndex;
|
|
||||||
m_aquireIntoMultiPageCount = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nullptr == m_scanImgFmtWriter)
|
if (nullptr == m_scanImgFmtWriter)
|
||||||
{
|
{
|
||||||
assert(m_scanFileName.isEmpty());
|
assert(m_scanFileName.isEmpty());
|
||||||
HGResult ret = HGBase_CreateDir(getStdString(m_aquireIntoSaveParam.m_savePath).c_str());
|
HGBase_CreateDir(getStdString(m_aquireIntoSaveParam.m_savePath).c_str());
|
||||||
|
|
||||||
QString scanFileName;
|
QString scanFileName;
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -1026,15 +1050,53 @@ void MainWindow::on_pre_new_image(void* img)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = HGImgFmt_OpenImageWriter(getStdString(getStdFileName(scanFileName)).c_str(), 0, &m_scanImgFmtWriter);
|
HGImgFmt_OpenImageWriter(getStdString(getStdFileName(scanFileName)).c_str(), 0, &m_scanImgFmtWriter);
|
||||||
|
|
||||||
if (nullptr != m_scanImgFmtWriter)
|
if (nullptr != m_scanImgFmtWriter)
|
||||||
|
{
|
||||||
m_scanFileName = scanFileName;
|
m_scanFileName = scanFileName;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (nullptr != m_scanImgFmtWriter)
|
if (nullptr != m_scanImgFmtWriter)
|
||||||
{
|
{
|
||||||
m_saveType = 2;
|
HGImgFmtSaveInfo saveInfo;
|
||||||
|
saveInfo.jpegQuality = (HGUInt)m_aquireIntoSaveParam.m_jpegQuality;
|
||||||
|
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE;
|
||||||
|
saveInfo.tiffJpegQuality = (HGUInt)m_aquireIntoSaveParam.m_tiffQuality;
|
||||||
|
|
||||||
|
HGImageInfo imgInfo;
|
||||||
|
HGBase_GetImageInfo((HGImage)image, &imgInfo);
|
||||||
|
if (HGBASE_IMGTYPE_BINARY == imgInfo.type)
|
||||||
|
{
|
||||||
|
if (1 == m_aquireIntoSaveParam.m_tiffCompressionBW)
|
||||||
|
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
||||||
|
else if (2 == m_aquireIntoSaveParam.m_tiffCompressionBW)
|
||||||
|
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_CCITTFAX4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (1 == m_aquireIntoSaveParam.m_tiffCompression)
|
||||||
|
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
||||||
|
else if (2 == m_aquireIntoSaveParam.m_tiffCompression)
|
||||||
|
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HGBASE_ERR_OK == HGImgFmt_SaveImageToWriter(m_scanImgFmtWriter, (HGImage)image, &saveInfo))
|
||||||
|
{
|
||||||
|
if (1 == m_aquireIntoSaveParam.m_multiPagesType && m_aquireIntoMultiPageCount == m_aquireIntoSaveParam.m_customMultiPages)
|
||||||
|
{
|
||||||
|
HGImgFmt_CloseImageWriter(m_scanImgFmtWriter);
|
||||||
|
m_scanImgFmtWriter = nullptr;
|
||||||
|
emit post_new_image(m_scanFileName);
|
||||||
|
m_scanFileName.clear();
|
||||||
|
++m_aquireIntoSaveParam.m_fileNameStartIndex;
|
||||||
|
m_aquireIntoMultiPageCount = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++m_aquireIntoMultiPageCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1045,7 +1107,7 @@ void MainWindow::on_pre_new_image(void* img)
|
||||||
if (m_aquireIntoSaveParam.m_isUseSubfolderByBlankPages)
|
if (m_aquireIntoSaveParam.m_isUseSubfolderByBlankPages)
|
||||||
{
|
{
|
||||||
HGBool isBlank = HGFALSE;
|
HGBool isBlank = HGFALSE;
|
||||||
HGImgProc_ImageBlankCheck(image, nullptr, &isBlank);
|
HGImgProc_ImageBlankCheck((HGImage)image, nullptr, &isBlank);
|
||||||
if (isBlank)
|
if (isBlank)
|
||||||
{
|
{
|
||||||
m_aquireIntoInBlank = true;
|
m_aquireIntoInBlank = true;
|
||||||
|
@ -1069,7 +1131,7 @@ void MainWindow::on_pre_new_image(void* img)
|
||||||
{
|
{
|
||||||
QString colorModeName;
|
QString colorModeName;
|
||||||
HGImageInfo imgInfo;
|
HGImageInfo imgInfo;
|
||||||
HGBase_GetImageInfo(image, &imgInfo);
|
HGBase_GetImageInfo((HGImage)image, &imgInfo);
|
||||||
if (HGBASE_IMGTYPE_BINARY == imgInfo.type)
|
if (HGBASE_IMGTYPE_BINARY == imgInfo.type)
|
||||||
colorModeName = tr("binary");
|
colorModeName = tr("binary");
|
||||||
else if (HGBASE_IMGTYPE_GRAY == imgInfo.type)
|
else if (HGBASE_IMGTYPE_GRAY == imgInfo.type)
|
||||||
|
@ -1080,7 +1142,7 @@ void MainWindow::on_pre_new_image(void* img)
|
||||||
savePath = getStdFileName(savePath + colorModeName + "/");
|
savePath = getStdFileName(savePath + colorModeName + "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
HGResult ret = HGBase_CreateDir(getStdString(savePath).c_str());
|
HGBase_CreateDir(getStdString(savePath).c_str());
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -1098,119 +1160,43 @@ void MainWindow::on_pre_new_image(void* img)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_saveType = 3;
|
HGImgFmtSaveInfo saveInfo;
|
||||||
}
|
saveInfo.jpegQuality = (HGUInt)m_aquireIntoSaveParam.m_jpegQuality;
|
||||||
}
|
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE;
|
||||||
}
|
saveInfo.tiffJpegQuality = (HGUInt)m_aquireIntoSaveParam.m_tiffQuality;
|
||||||
|
|
||||||
void MainWindow::on_post_new_image(unsigned int ret)
|
HGImageInfo imgInfo;
|
||||||
{
|
HGBase_GetImageInfo((HGImage)image, &imgInfo);
|
||||||
if (1 == m_scanType && 1 == m_saveType)
|
if (HGBASE_IMGTYPE_BINARY == imgInfo.type)
|
||||||
{
|
{
|
||||||
if (ret == HGBASE_ERR_OK)
|
if (1 == m_aquireIntoSaveParam.m_tiffCompressionBW)
|
||||||
{
|
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
||||||
if (-1 == m_scanInsertPos)
|
else if (2 == m_aquireIntoSaveParam.m_tiffCompressionBW)
|
||||||
{
|
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_CCITTFAX4;
|
||||||
m_thumb->addItem(m_scanFileName);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_thumb->insertItem(m_scanFileName, m_scanInsertPos);
|
if (1 == m_aquireIntoSaveParam.m_tiffCompression)
|
||||||
++m_scanInsertPos;
|
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
||||||
|
else if (2 == m_aquireIntoSaveParam.m_tiffCompression)
|
||||||
|
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
if (HGBASE_ERR_OK == saveImage((HGImage)image, &saveInfo, m_aquireIntoSaveParam.m_isOcr, 0, getStdString(m_scanFileName).c_str()))
|
||||||
else if (2 == m_scanType)
|
|
||||||
{
|
{
|
||||||
if (m_aquireIntoSaveParam.m_isSaveAsMultiPage && 2 == m_saveType)
|
emit post_new_image(m_scanFileName);
|
||||||
{
|
|
||||||
++m_aquireIntoMultiPageCount;
|
|
||||||
}
|
|
||||||
else if (3 == m_saveType)
|
|
||||||
{
|
|
||||||
if (ret == HGBASE_ERR_OK)
|
|
||||||
{
|
|
||||||
m_thumb->addItem(m_scanFileName);
|
|
||||||
++m_aquireIntoSaveParam.m_fileNameStartIndex;
|
++m_aquireIntoSaveParam.m_fileNameStartIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currScanCount++;
|
HGULonglong t2;
|
||||||
|
HGBase_GetTickCount(&t2);
|
||||||
|
HGDouble seconds;
|
||||||
|
HGBase_GetIntervalSeconds(t1, t2, &seconds);
|
||||||
|
qDebug("on_newImage end, m_currScanCount=%d, seconds=%f", m_currScanCount, seconds);
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
void MainWindow::on_newImage(void *image)
|
|
||||||
{
|
|
||||||
HGImage img = (HGImage)image;
|
|
||||||
|
|
||||||
emit pre_new_image(img);
|
|
||||||
|
|
||||||
HGResult ret = HGBASE_ERR_FAIL;
|
|
||||||
if (1 == m_saveType)
|
|
||||||
{
|
|
||||||
HGImgFmtSaveInfo info;
|
|
||||||
info.jpegQuality = 100;
|
|
||||||
info.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
|
||||||
info.tiffJpegQuality = 0;
|
|
||||||
ret = HGImgFmt_SaveImage(img, 0, &info, getStdString(m_scanFileName).c_str());
|
|
||||||
}
|
|
||||||
else if (2 == m_saveType)
|
|
||||||
{
|
|
||||||
HGImgFmtSaveInfo saveInfo;
|
|
||||||
saveInfo.jpegQuality = (HGUInt)m_aquireIntoSaveParam.m_jpegQuality;
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE;
|
|
||||||
saveInfo.tiffJpegQuality = (HGUInt)m_aquireIntoSaveParam.m_tiffQuality;
|
|
||||||
|
|
||||||
HGImageInfo imgInfo;
|
|
||||||
HGBase_GetImageInfo(img, &imgInfo);
|
|
||||||
if (HGBASE_IMGTYPE_BINARY == imgInfo.type)
|
|
||||||
{
|
|
||||||
if (1 == m_aquireIntoSaveParam.m_tiffCompressionBW)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
|
||||||
else if (2 == m_aquireIntoSaveParam.m_tiffCompressionBW)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_CCITTFAX4;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (1 == m_aquireIntoSaveParam.m_tiffCompression)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
|
||||||
else if (2 == m_aquireIntoSaveParam.m_tiffCompression)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = HGImgFmt_SaveImageToWriter(m_scanImgFmtWriter, img, &saveInfo);
|
|
||||||
}
|
|
||||||
else if (3 == m_saveType)
|
|
||||||
{
|
|
||||||
HGImgFmtSaveInfo saveInfo;
|
|
||||||
saveInfo.jpegQuality = (HGUInt)m_aquireIntoSaveParam.m_jpegQuality;
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE;
|
|
||||||
saveInfo.tiffJpegQuality = (HGUInt)m_aquireIntoSaveParam.m_tiffQuality;
|
|
||||||
|
|
||||||
HGImageInfo imgInfo;
|
|
||||||
HGBase_GetImageInfo(img, &imgInfo);
|
|
||||||
if (HGBASE_IMGTYPE_BINARY == imgInfo.type)
|
|
||||||
{
|
|
||||||
if (1 == m_aquireIntoSaveParam.m_tiffCompressionBW)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
|
||||||
else if (2 == m_aquireIntoSaveParam.m_tiffCompressionBW)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_CCITTFAX4;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (1 == m_aquireIntoSaveParam.m_tiffCompression)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
|
||||||
else if (2 == m_aquireIntoSaveParam.m_tiffCompression)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = saveImage(img, &saveInfo, m_aquireIntoSaveParam.m_isOcr, 0, getStdString(m_scanFileName).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
emit post_new_image(ret);
|
|
||||||
HGBase_DestroyImage(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_wrong_image_decide(dialog_wrong_img* dlg, bool save)
|
void MainWindow::on_wrong_image_decide(dialog_wrong_img* dlg, bool save)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -1242,7 +1228,7 @@ void MainWindow::on_wrong_image_decide(dialog_wrong_img* dlg, bool save)
|
||||||
|
|
||||||
delete dlg;
|
delete dlg;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
void MainWindow::on_m_pbtn_push_clicked()
|
void MainWindow::on_m_pbtn_push_clicked()
|
||||||
{
|
{
|
||||||
int mainWndWidth = this->rect().width();
|
int mainWndWidth = this->rect().width();
|
||||||
|
@ -1383,7 +1369,7 @@ QString MainWindow::getCacheFileName(HGImage img)
|
||||||
|
|
||||||
HGImage MainWindow::createImage()
|
HGImage MainWindow::createImage()
|
||||||
{
|
{
|
||||||
qDebug("createImage");
|
//qDebug("createImage");
|
||||||
|
|
||||||
assert(-1 != m_currIndex && -1 != m_multiIndex);
|
assert(-1 != m_currIndex && -1 != m_multiIndex);
|
||||||
assert(!m_currFilePath.isEmpty());
|
assert(!m_currFilePath.isEmpty());
|
||||||
|
@ -1429,7 +1415,7 @@ int MainWindow::getMultiPageCount()
|
||||||
HGImgFmt_CloseImageReader(imgFmtReader);
|
HGImgFmt_CloseImageReader(imgFmtReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("pageCount=%d", count);
|
//qDebug("pageCount=%d", count);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,7 @@ private slots:
|
||||||
void on_act_autoSave_triggered();
|
void on_act_autoSave_triggered();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pre_new_image(void* img);
|
void post_new_image(QString fileName);
|
||||||
void post_new_image(unsigned int ret);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_AcquireInto2();
|
void on_AcquireInto2();
|
||||||
|
@ -117,10 +116,9 @@ private slots:
|
||||||
void on_dialog_multirotate_refreshImgFile(const QString &fileName);
|
void on_dialog_multirotate_refreshImgFile(const QString &fileName);
|
||||||
void on_multiPageLineEditFinished();
|
void on_multiPageLineEditFinished();
|
||||||
void on_clearCache();
|
void on_clearCache();
|
||||||
void on_pre_new_image(void* img);
|
void on_post_new_image(QString fileName);
|
||||||
void on_post_new_image(unsigned int ret);
|
|
||||||
void on_newImage(void *image);
|
void on_newImage(void *image);
|
||||||
void on_wrong_image_decide(dialog_wrong_img* dlg, bool save);
|
//void on_wrong_image_decide(dialog_wrong_img* dlg, bool save);
|
||||||
void on_m_pbtn_push_clicked();
|
void on_m_pbtn_push_clicked();
|
||||||
void on_dialog_sideBar_applyToImage(HGImage img, int brightness, int contrast, double gamma, bool enhanceText);
|
void on_dialog_sideBar_applyToImage(HGImage img, int brightness, int contrast, double gamma, bool enhanceText);
|
||||||
void on_dialog_sideBar_finish(bool ok);
|
void on_dialog_sideBar_finish(bool ok);
|
||||||
|
@ -299,7 +297,6 @@ private:
|
||||||
bool m_singleScan; // 是否单张扫描
|
bool m_singleScan; // 是否单张扫描
|
||||||
int m_scanType; // 1-扫描到缓存目录,2-扫描到本地目录
|
int m_scanType; // 1-扫描到缓存目录,2-扫描到本地目录
|
||||||
int m_scanInsertPos; // 扫描插入位置,-1表示插入到最后
|
int m_scanInsertPos; // 扫描插入位置,-1表示插入到最后
|
||||||
int m_saveType;
|
|
||||||
QString m_scanFileName;
|
QString m_scanFileName;
|
||||||
HGImgFmtWriter m_scanImgFmtWriter;
|
HGImgFmtWriter m_scanImgFmtWriter;
|
||||||
AquireIntoSaveParam m_aquireIntoSaveParam;
|
AquireIntoSaveParam m_aquireIntoSaveParam;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __HGTIME_H__
|
#ifndef __HGTIME_H__
|
||||||
#define __HGTIME_H__
|
#define __HGTIME_H__
|
||||||
|
|
||||||
#include "HGDef.h"
|
#include "HGDef.h"
|
||||||
|
@ -12,7 +12,7 @@ typedef struct
|
||||||
HGUShort year;
|
HGUShort year;
|
||||||
HGUShort month;
|
HGUShort month;
|
||||||
HGUShort day;
|
HGUShort day;
|
||||||
HGUShort dayOfWeek; /* 0为星期天, 1-6表示星期一到星期六 */
|
HGUShort dayOfWeek; /* 0为星期天, 1-6表示星期一到星期六 */
|
||||||
HGUShort hour;
|
HGUShort hour;
|
||||||
HGUShort minute;
|
HGUShort minute;
|
||||||
HGUShort second;
|
HGUShort second;
|
||||||
|
|
Loading…
Reference in New Issue