From 58e03dbc6cec4d14b2f4299d4df0eacf58fc5d78 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 18 Jul 2026 16:45:28 +0200 Subject: [PATCH] REVIEWED: `TakeScreenshot()` to support absolute paths --- src/rcore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index 80d1cbf11..ec4d8a473 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1804,7 +1804,6 @@ void UnloadRandomSequence(int *sequence) } // Takes a screenshot of current screen -// NOTE: Provided fileName should not contain paths, saving to working directory void TakeScreenshot(const char *fileName) { #if SUPPORT_MODULE_RTEXTURES @@ -1819,7 +1818,8 @@ void TakeScreenshot(const char *fileName) Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; char path[MAX_FILEPATH_LENGTH] = { 0 }; - snprintf(path, MAX_FILEPATH_LENGTH, "%s", TextFormat("%s/%s", CORE.Storage.basePath, fileName)); + if (!IsPathAbsolute(fileName)) snprintf(path, MAX_FILEPATH_LENGTH, "%s", TextFormat("%s/%s", CORE.Storage.basePath, fileName)); + else snprintf(path, MAX_FILEPATH_LENGTH, "%s", fileName); ExportImage(image, path); // WARNING: Module required: rtextures RL_FREE(imgData);