Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
SDL_RenderReadPixels() is restricted to the viewport area.
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Mar 10, 2011
1 parent a6c2882 commit 00b3896
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/render/SDL_render.c
Expand Up @@ -1076,8 +1076,8 @@ SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
format = SDL_GetWindowPixelFormat(window);
}

real_rect.x = 0;
real_rect.y = 0;
real_rect.x = renderer->viewport.x;
real_rect.y = renderer->viewport.y;
real_rect.w = renderer->viewport.w;
real_rect.h = renderer->viewport.h;
if (rect) {
Expand All @@ -1088,7 +1088,7 @@ SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
}
if (real_rect.x > rect->x) {
int bpp = SDL_BYTESPERPIXEL(SDL_GetWindowPixelFormat(window));
int bpp = SDL_BYTESPERPIXEL(format);
pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
}
}
Expand Down

0 comments on commit 00b3896

Please sign in to comment.