[SDL] SDL_Surface

Dan G. Lunde danglund at online.no
Mon Jul 22 16:30:01 PDT 2002


From: "Mark D'voo" <line72 at postmark.net>


> ok, i have a large .bmp the i loaded into background and i want to
> just take the part of it and store it in another SDL_Surface called
> tmp.
> how do i do this ? I want to take coordinates starting at (0,0) to
> (50,50)
>

General strategy is to create some rectangles describing what you want
to do, then blit (copy) from one surface to another.

// Rectangle describing top 50 pixels
SDL_Rect topleft50pixels {0, 0, 50, 50};

// Copy top 50 pixels from surface hugebmp to tmp
SDL_BlitSurface(hugebmp, &topleft50pixels, tmp, &topleft50pixels);

For more about smart blitting, have a look at W.Peter van Paasens
excellent "The Demo Effects Collection" found in the demo section on
libsdl.org: http://www.paassen.tmfweb.nl/retrodemo.html

Dan
--






More information about the SDL mailing list