SDL_RenderReadPixels() is restricted to the viewport area.
authorSam Lantinga <slouken@libsdl.org>
Thu, 10 Mar 2011 01:00:43 -0800
changeset 5464bec064e902cf
parent 5463 9cdb6f1d791a
child 5465 46bd121b04a2
SDL_RenderReadPixels() is restricted to the viewport area.
src/render/SDL_render.c
     1.1 --- a/src/render/SDL_render.c	Thu Mar 10 00:58:45 2011 -0800
     1.2 +++ b/src/render/SDL_render.c	Thu Mar 10 01:00:43 2011 -0800
     1.3 @@ -1076,8 +1076,8 @@
     1.4          format = SDL_GetWindowPixelFormat(window);
     1.5      }
     1.6  
     1.7 -    real_rect.x = 0;
     1.8 -    real_rect.y = 0;
     1.9 +    real_rect.x = renderer->viewport.x;
    1.10 +    real_rect.y = renderer->viewport.y;
    1.11      real_rect.w = renderer->viewport.w;
    1.12      real_rect.h = renderer->viewport.h;
    1.13      if (rect) {
    1.14 @@ -1088,7 +1088,7 @@
    1.15              pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
    1.16          }
    1.17          if (real_rect.x > rect->x) {
    1.18 -            int bpp = SDL_BYTESPERPIXEL(SDL_GetWindowPixelFormat(window));
    1.19 +            int bpp = SDL_BYTESPERPIXEL(format);
    1.20              pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
    1.21          }
    1.22      }