Take aspect ratio into account when screenshotting

This commit is contained in:
Roza 2020-02-26 17:34:54 -05:00
parent b5333ed183
commit 2bcdfdb23a

View file

@ -862,7 +862,8 @@ void Graphics::screenshot(const char *filename) {
if (!img)
throw new Exception(Exception::SDLError, "%s", SDL_GetError());
glReadPixels(0, 0, w, h, GL_BGRA, GL_UNSIGNED_BYTE, img->pixels);
glReadPixels(p->scOffset.x, p->scOffset.y, w, h, GL_BGRA, GL_UNSIGNED_BYTE,
img->pixels);
#else
SDL_Surface *tmp, *img;
tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, 0, 0, 0, 0);
@ -875,7 +876,8 @@ void Graphics::screenshot(const char *filename) {
throw Exception(Exception::SDLError, "%s", SDL_GetError());
}
glReadPixels(0, 0, w, h, GL_BGRA, GL_UNSIGNED_BYTE, tmp->pixels);
glReadPixels(p->scOffset.x, p->scOffset.y, w, h, GL_BGRA, GL_UNSIGNED_BYTE,
tmp->pixels);
for (int i = 0; i < h; i++) {
memcpy((char *)img->pixels + 4 * w * i,