1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| // copie une partie de l'image <imgsrc> dans une nouvelle image de taille (newwidth;newheight).
SDL_Surface* copie_img(SDL_Surface * imgsrc, const Uint16 newwidth, const Uint16 newheight, const Uint16 posx, const Uint16 posy)
{
SDL_Surface *tmp_tile=SDL_CreateRGBSurface(SDL_HWSURFACE, newwidth, newheight, 32, 0, 0, 0, 0);
SDL_Surface *img= NULL;
SDL_SetColorKey(tmp_tile, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB( screen->format, 0, 0, 0) );
img = SDL_DisplayFormat( tmp_tile );
if( img != NULL )
{
SDL_FreeSurface( tmp_tile );
}
else
{
img=tmp_tile;
}
SDL_Rect clip;
clip.x=posx; clip.y=posy; clip.w=newwidth; clip.h=newheight;
apply_surface(0,0,imgsrc,img,&clip);
return img;
} |
Partager