获取图像信息的时候,直接从image对象获取
This commit is contained in:
parent
f2b79dd9cd
commit
d82449b736
|
@ -2168,41 +2168,18 @@ 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;
|
||||
return;
|
||||
}
|
||||
|
||||
imgInfo.width = width;
|
||||
imgInfo.height = height;
|
||||
imgInfo.bpp = pageInfo.bpp;
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(image, &imgInfo);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue