Corruption of Rect in SDL_BlitSurface

Hi I Just noticed that SDL_BlitSurface corrupts the destination rect when
used with negative x and y values, which prevents reuse of the rect. not a
big problem but i would have thought it would not corrupt it.

int SDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
SDL_Rect *dstrect);

At least put it in the docs as it would have saved me a little time to find.

Trish

What exactly do you mean by “corrupts”?

The SDL blitting functions writing the clipped rectangle into the
destination Rect is documented behavior. It has no effect on the x
and y fields as long as they’re inside the destination surface - but
negative coordinates are obviously outside, as are coordinates beyond
the width and height of the destination surface, and these will be
clamped to [0, dest.(w|h) - 1].

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Wednesday 05 July 2006 19:26, Patricia Curtis wrote:

Hi I Just noticed that SDL_BlitSurface corrupts the destination rect
when used with negative x and y values, which prevents reuse of the
rect. not a big problem but i would have thought it would not
corrupt it.

The reason for this, BTW, is so that you can pass the resultant rectangle
to SDL_UpdateRects() with no additional clipping necessary.

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment> On Wednesday 05 July 2006 19:26, Patricia Curtis wrote:

Hi I Just noticed that SDL_BlitSurface corrupts the destination rect
when used with negative x and y values, which prevents reuse of the
rect. not a big problem but i would have thought it would not
corrupt it.

What exactly do you mean by “corrupts”?

The SDL blitting functions writing the clipped rectangle into the
destination Rect is documented behavior. It has no effect on the x
and y fields as long as they’re inside the destination surface - but
negative coordinates are obviously outside, as are coordinates beyond
the width and height of the destination surface, and these will be
clamped to [0, dest.(w|h) - 1].