views:

232

answers:

3

I am making a game for my CS class and the sprites I have found online are too small. How do you 'stretch' a bitmap... make them bigger using SDL? (I need to increase there size 50%, there all the same size.) A snippet of example code would be appreciated.

A: 

have you tried?

    SDL_Rect src, dest;
    src.x = 0;
    src.y = 0;
    src.w = image->w;
    src.h = image->h;
    dest.x = 100;
    dest.y = 100;
    dest.w = image->w*1.5;
    dest.h = image->h*1.5;
    SDL_BlitSurface(image, &src, screen, &dest);
fazo
I'm sorry but it did not.
Fobia
SDL_BlitSurface doesn't stretch/scale. The the width and height of dest are ignored
Monkeyget
A: 

You're going to get a better looking result using software that is designed for this task. A good option is ImageMagick. It can be used from the command line or programatically.

For example, from the command line you just enter:

convert sprite.bmp -resize 150% bigsprite.bmp

If for some strange reason you want to write your own bilinear resize, this guy looks like he knows what he is doing.

Turtle
Thankyou, I appreciate the help plus the link for futher info.
Fobia
A: 

Use for stretch the undocumented function of SDL: extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);

Like:

SDL_SoftStretch(image, &src, screen, &dest);

Ricleite