mirror of
https://github.com/raysan5/raylib.git
synced 2025-11-03 17:24:25 +00:00
use GetWindowScaleDPI to calculate size for rlReadScreenPixels in screenshot/recording (#2446)
This commit is contained in:
13
src/rcore.c
13
src/rcore.c
@@ -2049,8 +2049,9 @@ void EndDrawing(void)
|
|||||||
{
|
{
|
||||||
// Get image data for the current frame (from backbuffer)
|
// Get image data for the current frame (from backbuffer)
|
||||||
// NOTE: This process is quite slow... :(
|
// NOTE: This process is quite slow... :(
|
||||||
unsigned char *screenData = rlReadScreenPixels(CORE.Window.screen.width, CORE.Window.screen.height);
|
Vector2 scale = GetWindowScaleDPI();
|
||||||
msf_gif_frame(&gifState, screenData, 10, 16, CORE.Window.screen.width*4);
|
unsigned char *screenData = rlReadScreenPixels(CORE.Window.render.width*scale.x, CORE.Window.render.height*scale.y);
|
||||||
|
msf_gif_frame(&gifState, screenData, 10, 16, CORE.Window.render.width*scale.x*4);
|
||||||
|
|
||||||
RL_FREE(screenData); // Free image data
|
RL_FREE(screenData); // Free image data
|
||||||
}
|
}
|
||||||
@@ -2772,8 +2773,9 @@ void SetConfigFlags(unsigned int flags)
|
|||||||
void TakeScreenshot(const char *fileName)
|
void TakeScreenshot(const char *fileName)
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_MODULE_RTEXTURES)
|
#if defined(SUPPORT_MODULE_RTEXTURES)
|
||||||
unsigned char *imgData = rlReadScreenPixels(CORE.Window.render.width, CORE.Window.render.height);
|
Vector2 scale = GetWindowScaleDPI();
|
||||||
Image image = { imgData, CORE.Window.render.width, CORE.Window.render.height, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
|
unsigned char *imgData = rlReadScreenPixels(CORE.Window.render.width*scale.x, CORE.Window.render.height*scale.y);
|
||||||
|
Image image = { imgData, CORE.Window.render.width*scale.x, CORE.Window.render.height*scale.y, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
|
||||||
|
|
||||||
char path[2048] = { 0 };
|
char path[2048] = { 0 };
|
||||||
strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, fileName));
|
strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, fileName));
|
||||||
@@ -5281,7 +5283,8 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
|||||||
gifRecording = true;
|
gifRecording = true;
|
||||||
gifFrameCounter = 0;
|
gifFrameCounter = 0;
|
||||||
|
|
||||||
msf_gif_begin(&gifState, CORE.Window.screen.width, CORE.Window.screen.height);
|
Vector2 scale = GetWindowScaleDPI();
|
||||||
|
msf_gif_begin(&gifState, CORE.Window.render.width*scale.x, CORE.Window.render.height*scale.y);
|
||||||
screenshotCounter++;
|
screenshotCounter++;
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "SYSTEM: Start animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter));
|
TRACELOG(LOG_INFO, "SYSTEM: Start animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter));
|
||||||
|
|||||||
Reference in New Issue
Block a user