mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-06 03:18:14 +00:00
REVIEWED: TakeScreenshot()
, potential issues
This commit is contained in:
@@ -1766,7 +1766,8 @@ void UnloadRandomSequence(int *sequence)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Takes a screenshot of current screen (saved a .png)
|
// Takes a screenshot of current screen
|
||||||
|
// NOTE: Provided fileName should not contain paths, saving to working directory
|
||||||
void TakeScreenshot(const char *fileName)
|
void TakeScreenshot(const char *fileName)
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_MODULE_RTEXTURES)
|
#if defined(SUPPORT_MODULE_RTEXTURES)
|
||||||
@@ -1778,12 +1779,13 @@ 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 };
|
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[512] = { 0 };
|
char path[512] = { 0 };
|
||||||
strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, fileName));
|
strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, GetFileName(fileName)));
|
||||||
|
|
||||||
ExportImage(image, path); // WARNING: Module required: rtextures
|
ExportImage(image, path); // WARNING: Module required: rtextures
|
||||||
RL_FREE(imgData);
|
RL_FREE(imgData);
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "SYSTEM: [%s] Screenshot taken successfully", path);
|
if (FileExists(path)) TRACELOG(LOG_INFO, "SYSTEM: [%s] Screenshot taken successfully", path);
|
||||||
|
else TRACELOG(LOG_WARNING, "SYSTEM: [%s] Screenshot could not be saved", path);
|
||||||
#else
|
#else
|
||||||
TRACELOG(LOG_WARNING,"IMAGE: ExportImage() requires module: rtextures");
|
TRACELOG(LOG_WARNING,"IMAGE: ExportImage() requires module: rtextures");
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user