Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions reader/browser/PageRenderThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,13 +814,17 @@ bool PageRenderThread::execNextDocPageThumbnailTask()
return true;
}

QImage image = task.renderer->getImage(task.index, 174, 174);
// 渲染分辨率需匹配显示侧实际尺寸(174 * pixScale * dpr),避免源图像被
// Qt painter 上采样放大导致模糊;pixScale 由 task 从 UI 层传入
int renderSize = static_cast<int>(174 * task.pixScale * dApp->devicePixelRatio());

QImage image = task.renderer->getImage(task.index, renderSize, renderSize);

if (!image.isNull()) {
// 预取图片对象 bbox(夜间/深色蒙版用):在工作线程取,避免 UI 线程与渲染争文档锁;
// 与 getImage 同尺寸(174,174)请求,蒙版与缩略图输出像素一一对齐
// 与 getImage 同尺寸请求,蒙版与缩略图输出像素一一对齐
if (DocSheet::existSheetByUuid(task.uuid) && task.renderer->opened()) {
task.imageRects = task.renderer->getImageObjectRects(task.index, 174, 174);
task.imageRects = task.renderer->getImageObjectRects(task.index, renderSize, renderSize);
}
emit sigDocPageThumbnailTaskFinished(task, QPixmap::fromImage(image));
}
Expand Down
1 change: 1 addition & 0 deletions reader/browser/PageRenderThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct DocPageThumbnailTask {//缩略图
DocSheet *sheet = nullptr;
SideBarImageViewModel *model = nullptr;
int index = -1;
qreal pixScale = 1.0; //侧边栏缩放因子(adaptScale),渲染分辨率 = 174 * pixScale * dpr
QVector<QRectF> imageRects; //图片对象 bbox(夜间/深色蒙版用,与缩略图像素对齐,worker线程预取)
};

Expand Down
2 changes: 2 additions & 0 deletions reader/sidebar/SideBarImageViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ QVariant SideBarImageViewModel::data(const QModelIndex &index, int role) const
task.model = const_cast<SideBarImageViewModel *>(this);
task.renderer = m_sheet ? m_sheet->rendererPtr() : nullptr;
task.uuid = m_sheet ? m_sheet->uuid() : QString();
task.pixScale = m_parent ? m_parent->property("adaptScale").toDouble() : 1.0;
PageRenderThread::appendTask(task);
}

Expand Down Expand Up @@ -204,6 +205,7 @@ void SideBarImageViewModel::onUpdateImage(int index)
task.index = index;
task.model = const_cast<SideBarImageViewModel *>(this);
task.renderer = m_sheet ? m_sheet->rendererPtr() : nullptr;
task.pixScale = m_parent ? m_parent->property("adaptScale").toDouble() : 1.0;
task.uuid = m_sheet ? m_sheet->uuid() : QString();
PageRenderThread::appendTask(task);
qCDebug(appLog) << "Updating image for index:" << index << "end";
Expand Down
Loading