SDL_RenderReadPixels() is restricted to the viewport area.
authorSam Lantinga <slouken@libsdl.org>
Thu, 10 Mar 2011 01:00:43 -0800
changeset 5464 bec064e902cf
parent 5463 9cdb6f1d791a
child 5465 46bd121b04a2
SDL_RenderReadPixels() is restricted to the viewport area.
src/render/SDL_render.c
--- a/src/render/SDL_render.c	Thu Mar 10 00:58:45 2011 -0800
+++ b/src/render/SDL_render.c	Thu Mar 10 01:00:43 2011 -0800
@@ -1076,8 +1076,8 @@
         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) {
@@ -1088,7 +1088,7 @@
             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);
         }
     }