Skip to content

Commit

Permalink
Base star scaling on screen scale
Browse files Browse the repository at this point in the history
The screenshot magnification was never used anywhere except this, and it
was based on screen rather window size, which resulted in weird
coefficient of magnification.

Generally the screen objects are already scaled according to screen font
size (and high-DPI scaling factor), so stars are one of the last things
to scale this way too.

Now to make properly scaled screenshots, change screen font size
according to the ratio of the screenshot size to the window size, and
you should get a screenshot that looks almost the same as the window,
but in a larger resolution (to scale GUI windows too, change GUI font
similarly).
  • Loading branch information
10110111 committed Jan 22, 2025
1 parent 48ad7a1 commit fb3e222
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/StelMainView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ StelMainView::StelMainView(QSettings* settings)
customScreenshotWidth(1024),
customScreenshotHeight(768),
screenshotDpi(72),
customScreenshotMagnification(1.0f),
screenShotPrefix("stellarium-"),
screenShotFormat("png"),
screenShotFileMask("yyyyMMdd-hhmmssz"),
Expand Down Expand Up @@ -1756,8 +1755,6 @@ void StelMainView::doScreenshot(void)
sParams.viewportXywh[2] = virtImgWidth;
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>(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 Expand Up @@ -1793,7 +1790,6 @@ void StelMainView::doScreenshot(void)
delete fbObj;
// reset viewport and GUI
core->setCurrentStelProjectorParams(pParams);
customScreenshotMagnification=1.0f;
nightModeEffect->setEnabled(nightModeWasEnabled);
stelScene->setSceneRect(0, 0, pParams.viewportXywh[2], pParams.viewportXywh[3]);
rootItem->setSize(QSize(pParams.viewportXywh[2], pParams.viewportXywh[3]));
Expand Down
4 changes: 0 additions & 4 deletions src/StelMainView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ public slots:
int getScreenshotDpi() const {return screenshotDpi;}
//! Set screenshot DPI. This is only an entry in the screenshot image metadata. The raster content is not influenced.
void setScreenshotDpi(int dpi);
//! Get screenshot magnification. This should be used by StarMgr, text drawing and other elements which may
//! want to enlarge their output in screenshots to keep them visible.
float getCustomScreenshotMagnification() const {return customScreenshotMagnification;}
//! Get the state of the mouse cursor timeout flag
bool getFlagCursorTimeout() const {return flagCursorTimeout;}
//! Set the state of the mouse cursor timeout flag
Expand Down Expand Up @@ -334,7 +331,6 @@ private slots:
int customScreenshotWidth; //! used when flagCustomResolutionScreenshots==true
int customScreenshotHeight; //! used when flagCustomResolutionScreenshots==true
int screenshotDpi; //! Image metadata entry for DPI. This does not influence the screenshot raster image content in any way, but some workflows like to have a configurable entry.
float customScreenshotMagnification; //! tracks the magnification factor customScreenshotHeight/NormalWindowHeight
QString screenShotPrefix;
QString screenShotFormat; //! file type like "png" or "jpg".
QString screenShotFileMask;
Expand Down
4 changes: 2 additions & 2 deletions src/core/StelSkyDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ bool StelSkyDrawer::computeRCMag(float mag, RCMag* rcMag) const
{
rcMag->radius = eye->adaptLuminanceScaledLn(pointSourceMagToLnLuminance(mag), static_cast<float>(starRelativeScale)*1.40f*0.5f);
rcMag->radius *=starLinearScale;
rcMag->radius *=StelMainView::getInstance().getCustomScreenshotMagnification();
// Use now statically min_rmag = 0.5, because higher and too small values look bad
if (rcMag->radius < 0.3f)
{
Expand Down Expand Up @@ -419,6 +418,7 @@ bool StelSkyDrawer::computeRCMag(float mag, RCMag* rcMag) const
rcMag->radius=MAX_LINEAR_RADIUS+std::sqrt(1.f+rcMag->radius-MAX_LINEAR_RADIUS)-1.f;
}
}
rcMag->radius *= StelApp::getInstance().getScreenScale();
return true;
}

Expand Down Expand Up @@ -476,7 +476,7 @@ bool StelSkyDrawer::drawPointSource(StelPainter* sPainter, const Vec3d& v, const
if (!(checkInScreen ? sPainter->getProjector()->projectCheck(v, win) : sPainter->getProjector()->project(v, win)))
return false;

const float radius = rcMag.radius * static_cast<float>(sPainter->getProjector()->getDevicePixelsPerPixel());
const float radius = rcMag.radius;
const float frand=StelApp::getInstance().getRandF();

// Random coef for star twinkling. twinkleFactor can introduce height-dependent twinkling.
Expand Down

0 comments on commit fb3e222

Please sign in to comment.