Skip to content
Merged
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
23 changes: 15 additions & 8 deletions src/src/videowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,17 +581,24 @@ void videowidget::ReceiveMajorImage(QImage *image, int result)
if (m_openglwidget && m_openglwidget->isVisible())
m_openglwidget->hide();
{
int widgetwidth = this->width();
int widgetheight = this->height();
if ((image->width() * 100 / image->height()) > (widgetwidth * 100 / widgetheight)) {
QImage img = image->scaled(widgetwidth, widgetwidth * image->height() / image->width(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
m_framePixmap = QPixmap::fromImage(img);
const qreal dpr = this->devicePixelRatioF();
const int widgetwidth = qRound(this->width() * dpr);
const int widgetheight = qRound(this->height() * dpr);

int targetWidth, targetHeight;
if (qint64(image->width()) * widgetheight > qint64(widgetwidth) * image->height()) {
targetWidth = widgetwidth;
targetHeight = qMin(qRound(qreal(widgetwidth) * image->height() / image->width()), widgetheight);
} else {
QImage img = image->scaled(widgetheight * image->width() / image->height(), widgetheight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
m_framePixmap = QPixmap::fromImage(img);
targetHeight = widgetheight;
targetWidth = qMin(qRound(qreal(widgetheight) * image->width() / image->height()), widgetwidth);
}

m_pNormalScene->setSceneRect(m_framePixmap.rect());
m_framePixmap = QPixmap::fromImage(image->scaled(targetWidth, targetHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
m_framePixmap.setDevicePixelRatio(dpr);

const QRectF sceneRect(0, 0, qreal(m_framePixmap.width()) / dpr, qreal(m_framePixmap.height()) / dpr);
m_pNormalScene->setSceneRect(sceneRect);
Comment on lines +600 to +601

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (bug_risk): Scene rect now depends on devicePixelRatio; ensure this aligns with how the view interprets logical vs device coordinates.

This change correctly expresses the scene rect in logical coordinates, but it may diverge from any code that still treats the pixmap size as device pixels. Please verify that QGraphicsView configuration and any custom painting/transformations are consistent with logical coordinates to avoid subtle offset or zoom issues.

m_pNormalItem->setPixmap(m_framePixmap);

if (DataManager::instance()->encodeEnv() == FFmpeg_Env) {
Expand Down
Loading