This performs a fast blit from the source surface to the destination surface.
Only the position is used in the dstrect (the width and height are ignored).
If either srcrect or dstrect are nil, the entire surface (src or dst ) is copied.
The final blit rectangle is saved in dstrect after all clipping is performed (srcrect is not modified).
The blit function should not be called on a locked surface.
The results of blitting operations vary greatly depending on whether SDL_SRCAPLHA is set or not. See SDL_SetAlpha for an explaination of how this effects your results. Colorkeying and alpha attributes also interact with surface blitting, as the following pseudo-code should hopefully explain.
if (source surface has SDL_SRCALPHA set) then
if (source surface has alpha channel (that is, format.AMask <> 0)) then
blit using per-pixel alpha, ignoring any colour key
if (source surface has SDL_SRCCOLORKEY set)
blit using the colour key AND the per-surface alpha value
blit using the per-surface alpha value
if (source surface has SDL_SRCCOLORKEY set) then
blit using the colour key
ordinary opaque rectangular blit
If the blit is successful, it returns 0 , otherwise it returns -1.
If either of the surfaces were in video memory, and the blit returns -2, the video memory was lost, so it should be reloaded with artwork and re-blitted:
while ( SDL_BlitSurface( image, imgrect, screen, dstrect ) = -2 ) doThis happens under DirectX 5.0 when the system switches away from your fullscreen application. Locking the surface will also fail until you have access to the video memory again.
while ( SDL_LockSurface( image ) ) < 0 ) do
-- Write image pixels to image->pixels --
SDL_UnlockSurface( image );