SDL_surface that contains several images

Posted by l19 on Stack Overflow See other posts from Stack Overflow or by l19
Published on 2012-11-26T04:11:22Z Indexed on 2012/11/26 5:04 UTC
Read the original article Hit count: 121

Filed under:
|

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);
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about sdl