Browse Source

Merge pull request #4883 from JeffM2501/highdpi_screenshot

[RCORE] Fix issue with screenshots on HIGHDPI displays
pull/4895/head
Ray 1 month ago
committed by GitHub
parent
commit
cb111ad15e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      src/rcore.c

+ 4
- 1
src/rcore.c View File

@ -1879,7 +1879,10 @@ void TakeScreenshot(const char *fileName)
// Security check to (partially) avoid malicious code // Security check to (partially) avoid malicious code
if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; } if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; }
Vector2 scale = GetWindowScaleDPI();
// apply a scale if we are doing HIGHDPI auto-scaling
Vector2 scale = { 1,1 };
if (IsWindowState(FLAG_WINDOW_HIGHDPI)) scale = GetWindowScaleDPI();
unsigned char *imgData = rlReadScreenPixels((int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y)); unsigned char *imgData = rlReadScreenPixels((int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y));
Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };

Loading…
Cancel
Save