Skip to content

Commit cb111ad

Browse files
authored
Merge pull request #4883 from JeffM2501/highdpi_screenshot
[RCORE] Fix issue with screenshots on HIGHDPI displays
2 parents ab901c5 + 60eb3a1 commit cb111ad

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/rcore.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1879,7 +1879,10 @@ void TakeScreenshot(const char *fileName)
18791879
// Security check to (partially) avoid malicious code
18801880
if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; }
18811881

1882-
Vector2 scale = GetWindowScaleDPI();
1882+
// apply a scale if we are doing HIGHDPI auto-scaling
1883+
Vector2 scale = { 1,1 };
1884+
if (IsWindowState(FLAG_WINDOW_HIGHDPI)) scale = GetWindowScaleDPI();
1885+
18831886
unsigned char *imgData = rlReadScreenPixels((int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y));
18841887
Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
18851888

0 commit comments

Comments
 (0)