• Advertisement
Sign in to follow this  

Scaling images

This topic is 1777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am working on a game and I have a 16x16 image that I want to make 64x64, is there a way to do this in code that does not use anything but c++ and the SDL library(no extensions)? I don't want to use OpenGL because I am still learning and I do not want to over complicate things with openGL. Thanks.

Share this post


Link to post
Share on other sites
Advertisement

You probably want to look into using the SDL_SoftStretch function. If you have a source 16x16 SDL_Surface* called (for example) image_16square and a destination 64x64 SDL_Surface* called (for example) image_64square you would call it like this:

 

SDL_SoftStretch(image_16square, NULL, image_64square, NULL);

 

Untested. This uses SDL 2.0. If you're using SDL 1.2 you should specify. Basically you'd lock both the 16x16 source surface and the 64x64 destination surface. Then you'd go through every pixel in the 16x16 surface and set the equivalent 4 pixels in the destination surface to the same value as that pixel.

Share this post


Link to post
Share on other sites

If you are doing scaling, or rotating, I would suggest not do anything in SDL as it is all done in software, and will slow down your PC terribly (at least using the released SDL 1.2).  I would suggest looking at SFML as it does all scaling and rotating natively for you in HW.

 

In the long run, you'll be happy you switched IMO (not just for graphics, but for the other interfaces it provides).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement