From d82449b7368541f7d50a5e3453a0e967087fd74c Mon Sep 17 00:00:00 2001 From: luoliangyi <87842688@qq.com> Date: Mon, 29 Aug 2022 11:11:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=9B=BE=E5=83=8F=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E4=BB=8Eimage=E5=AF=B9=E8=B1=A1=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scanner/mainwindow.cpp | 57 +++++++++++++------------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/app/scanner/mainwindow.cpp b/app/scanner/mainwindow.cpp index 5a63935a..6b6b53ba 100644 --- a/app/scanner/mainwindow.cpp +++ b/app/scanner/mainwindow.cpp @@ -2168,42 +2168,19 @@ void MainWindow::on_act_imageInfo_triggered() assert(!m_currFilePath.isEmpty()); QFileInfo info(m_currFilePath); - HGImgFmtLoadInfo imgInfo; - memset(&imgInfo, 0, sizeof(HGImgFmtLoadInfo)); - - HGPdfReader pdfReader = nullptr; - HGImgFmt_OpenPdfReader(getStdString(m_currFilePath).c_str(), &pdfReader); - if (nullptr != pdfReader) + HGImage image = NULL; + m_view->getImage(&image); + if (nullptr == image) { - HGPdfPageInfo pageInfo = {0, 0}; - HGImgFmt_GetPdfPageInfo(pdfReader, (HGUInt)m_multiIndex, &pageInfo); - - HGUInt width = pageInfo.width; - HGUInt height = pageInfo.height; - - if (width < 1600) - { - width = 1600; - height = pageInfo.height * width / pageInfo.width; - } - - imgInfo.width = width; - imgInfo.height = height; - imgInfo.bpp = pageInfo.bpp; - - HGImgFmt_ClosePdfReader(pdfReader); - } - else - { - HGImgFmtReader imgFmtReader = nullptr; - HGImgFmt_OpenImageReader(getStdString(m_currFilePath).c_str(), 0, &imgFmtReader); - if (nullptr != imgFmtReader) - { - HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)m_multiIndex, &imgInfo, 0, 0, nullptr); - HGImgFmt_CloseImageReader(imgFmtReader); - } + return; } + HGImageInfo imgInfo; + HGBase_GetImageInfo(image, &imgInfo); + + HGUInt xDpi, yDpi; + HGBase_GetImageDpi(image, &xDpi, &yDpi); + QStringList fileKeys; fileKeys << tr("File name") << tr("File path") << tr("File size") << tr("Creation date/time") << tr("Modified date/time") << tr("Accessed date/time"); @@ -2254,14 +2231,20 @@ void MainWindow::on_act_imageInfo_triggered() imageValues.append(QString::number(imgInfo.width));//add image width imageValues.append(QString::number(imgInfo.height));//add image height - int depth = (int)imgInfo.bpp; + int depth = 1; + if (HGBASE_IMGTYPE_GRAY == imgInfo.type) + depth = 8; + else if (HGBASE_IMGTYPE_BGR == imgInfo.type || HGBASE_IMGTYPE_RGB == imgInfo.type) + depth = 24; + else if (HGBASE_IMGTYPE_BGRA == imgInfo.type || HGBASE_IMGTYPE_RGBA == imgInfo.type) + depth = 32; imageValues.append(QString::number(depth));//add image depth imageValues.append(depth == 0 ? tr("None") : (depth == 1 ? tr("Mono") : (depth == 8 ? tr("Gray") : tr("Color"))));//add image color - QString dpi = QString::number(imgInfo.xDpi) + " x " + QString::number(imgInfo.yDpi); + QString dpi = QString::number(xDpi) + " x " + QString::number(yDpi); imageValues.append(dpi);//add image dpi - double cm_x = (0 == imgInfo.xDpi) ? 0 : 2.54 * imgInfo.width / imgInfo.xDpi; - double cm_y = (0 == imgInfo.yDpi) ? 0 : 2.54 * imgInfo.height / imgInfo.yDpi; + double cm_x = (0 == xDpi) ? 0 : 2.54 * imgInfo.width / xDpi; + double cm_y = (0 == yDpi) ? 0 : 2.54 * imgInfo.height / yDpi; QString cm_printsize = QString::number(cm_x, 'f', 2) + " x " + QString::number(cm_y, 'f', 2) + " cm"; double inch_x = cm_x / 2.54; double inch_y = cm_y / 2.54;