Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the correct screen when making a screenshot #3532

Merged
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
5 changes: 3 additions & 2 deletions src/StelMainView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,8 @@ void StelMainView::doScreenshot(void)
// HiDPI screens interfere, and the viewing angle has to be maintained.
// First, image size:
glWidget->makeCurrent();
const auto pixelRatio = QOpenGLContext::currentContext()->screen()->devicePixelRatio();
const auto screen = QOpenGLContext::currentContext()->screen();
const auto pixelRatio = screen->devicePixelRatio();
int physImgWidth = std::lround(stelScene->width() * pixelRatio);
int physImgHeight = std::lround(stelScene->height() * pixelRatio);
bool nightModeWasEnabled=nightModeEffect->isEnabled();
Expand Down Expand Up @@ -1739,7 +1740,7 @@ void StelMainView::doScreenshot(void)
sParams.viewportXywh[3] = virtImgHeight;

// Configure a helper value to allow some modules to tweak their output sizes. Currently used by StarMgr, maybe solve font issues?
customScreenshotMagnification=static_cast<float>(virtImgHeight)/static_cast<float>(qApp->screenAt(QPoint(stelScene->width()*0.5, stelScene->height()*0.5))->geometry().height());
customScreenshotMagnification=static_cast<float>(virtImgHeight)/static_cast<float>(screen->geometry().height());
sParams.viewportCenter.set(0.0+(0.5+pParams.viewportCenterOffset.v[0])*virtImgWidth,
0.0+(0.5+pParams.viewportCenterOffset.v[1])*virtImgHeight);
sParams.viewportFovDiameter = qMin(virtImgWidth,virtImgHeight);
Expand Down
Loading