https://github.com/libsdl-org/Maelstrom/commit/1dae27dacaaa4200ea3acb9070c3d28b104729cd
From 1dae27dacaaa4200ea3acb9070c3d28b104729cd Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 25 Feb 2013 01:45:49 -0800
Subject: [PATCH] Fixed offset for screenshots (uses real window size, not
logical coordinates)
---
screenlib/SDL_FrameBuf.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/screenlib/SDL_FrameBuf.cpp b/screenlib/SDL_FrameBuf.cpp
index 09378b15..bd4d1379 100644
--- a/screenlib/SDL_FrameBuf.cpp
+++ b/screenlib/SDL_FrameBuf.cpp
@@ -341,8 +341,17 @@ FrameBuf::ScreenDump(const char *prefix, int x, int y, int w, int h)
if (!h) {
h = Height();
}
+
+ // Convert to real output coordinates
SDL_RenderGetScale(renderer, &scale_x, &scale_y);
+ x = (x * output.w) / this->rect.w;
+ y = (y * output.h) / this->rect.h;
+ x = (int)((x + output.x) * scale_x);
+ y = (int)((y + output.y) * scale_y);
+
+ w = (w * output.w) / this->rect.w;
+ h = (h * output.h) / this->rect.h;
w = (int)(w * scale_x);
h = (int)(h * scale_y);