mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-08 16:05:34 +02:00
Take aspect ratio into account when screenshotting
This commit is contained in:
parent
b5333ed183
commit
2bcdfdb23a
1 changed files with 4 additions and 2 deletions
|
@ -862,7 +862,8 @@ void Graphics::screenshot(const char *filename) {
|
||||||
if (!img)
|
if (!img)
|
||||||
throw new Exception(Exception::SDLError, "%s", SDL_GetError());
|
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
|
#else
|
||||||
SDL_Surface *tmp, *img;
|
SDL_Surface *tmp, *img;
|
||||||
tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, 0, 0, 0, 0);
|
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());
|
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++) {
|
for (int i = 0; i < h; i++) {
|
||||||
memcpy((char *)img->pixels + 4 * w * i,
|
memcpy((char *)img->pixels + 4 * w * i,
|
||||||
|
|
Loading…
Add table
Reference in a new issue