SDL_surface that contains several images
- by l19
Suppose I have a SDL_Surface that is just one image.
What if I wanted to make that SDL_Surface have three copies of that image, one below the other?
I came up with this function, but it doesn't do anything:
void adjust(SDL_Surface* img)
{
int imageHeight = img->h;
int desiredHeight = 3*imageHeight;
int repetitions = desiredHeight / imageHeight ;
int remainder = desiredHeight % imageHeight ;
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.w = img->w;
rect.h = img->h;
int i = 0;
for (i ; i < repetitions ; i++) {
rect.y = i* imageHeight;
SDL_BlitSurface(img,NULL,img,&rect);
}
rect.y += remainder;
SDL_BlitSurface(img,NULL,img,&rect);
}