From 84ffd4a723fd2cfa690dc013b078ea660d1cce6b Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Tue, 6 Feb 2024 16:15:43 +0100 Subject: Fixed crash when taking a screenshot Wrong format was passed to SDL_RenderReadPixels. Issue introduced in 2c51c98625b225cecfb9628c30d62d4e30f7e3e1. Closes #52 --- src/graphics.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/graphics.cpp b/src/graphics.cpp index 6f488cc1..02144cab 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -319,7 +319,11 @@ SDL_Surface *Graphics::getScreenshot() SDL_Surface *screenshot = SDL_CreateRGBSurface(0, mWidth, mHeight, 24, rmask, gmask, bmask, amask); - SDL_RenderReadPixels(mRenderer, nullptr, SDL_PIXELFORMAT_RGB888, screenshot->pixels, screenshot->pitch); + + SDL_RenderReadPixels(mRenderer, nullptr, + screenshot->format->format, + screenshot->pixels, + screenshot->pitch); return screenshot; } -- cgit v1.2.3-70-g09d2