mirror of https://github.com/encounter/SDL.git
Fixed bug 3324 - SDL_RenderReadPixels: Wrong rect coordinates with software renderer
Daniel SDL_RenderReadPixels with SDL_RENDERER_SOFTWARE reads pixels from wrong coordinates. SW_RenderReadPixels adjusts the rect coordinates according to the viewport. But since this is already done by SDL_RenderReadPixels, the final rect has x2 bigger X and Y.
This commit is contained in:
parent
658975f381
commit
6de66e984f
|
@ -833,19 +833,14 @@ SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||||
Uint32 src_format;
|
Uint32 src_format;
|
||||||
void *src_pixels;
|
void *src_pixels;
|
||||||
SDL_Rect final_rect;
|
|
||||||
|
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderer->viewport.x || renderer->viewport.y) {
|
/* NOTE: The rect is already adjusted according to the viewport by
|
||||||
final_rect.x = renderer->viewport.x + rect->x;
|
* SDL_RenderReadPixels.
|
||||||
final_rect.y = renderer->viewport.y + rect->y;
|
*/
|
||||||
final_rect.w = rect->w;
|
|
||||||
final_rect.h = rect->h;
|
|
||||||
rect = &final_rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rect->x < 0 || rect->x+rect->w > surface->w ||
|
if (rect->x < 0 || rect->x+rect->w > surface->w ||
|
||||||
rect->y < 0 || rect->y+rect->h > surface->h) {
|
rect->y < 0 || rect->y+rect->h > surface->h) {
|
||||||
|
|
Loading…
Reference in New Issue