SDL fill screen with image?

closed account (Dy7SLyTq)
so im trying to make a background for a menu, but it is only so big. its not the kind of picture where i can just reapply it. is there a function to make it fill to the screen?
You mean stretch the image to take up more pixels? There is no build in SDL function to do it but you can always write your own, or use a library like SDL_gfx or SPriG.

http://www.ferzkopp.net/joomla/content/view/19/14/
http://code.bluedinosaurs.com/lib/sprig/#Download
closed account (Dy7SLyTq)
how would i write my own?
first off create a surface to fill your screen, lets say

SDL_Surface * newSurface = SDL_CreateRGBSurface(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP,FLAGS);

then run on the pixels of the the new surface and blit to them pixel by pixel, (dunno of a more efficient way, well I do actually but that out of the scope).

1
2
3
4
5
6
for(int i=0; i<HEIGHT; ++i)
   for(int j=0; j<WIDTH; ++j){
      int oldX = ((float)j/WIDTH)*OLD_IMAGE_WIDTH;
      int oldY = ((float)i/HEIGHT)*OLD_IMAGE_HEIGHT;
      newSurface->pixels[i*WIDTH+j] = oldSurface->pixels[oldY*OLD_IMAGE_WIDTH+oldX];
   }
closed account (Dy7SLyTq)
thanks. i figured it out. i found this small header/cpp file combo called SDL_Resize
Topic archived. No new replies allowed.