Jump to content

  • Log In with Google      Sign In   
  • Create Account

Scaling images


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Crusable   Members   -  Reputation: 594

Like
0Likes
Like

Posted 09 March 2013 - 08:21 PM

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.



Sponsor:

#2 nobodynews   Crossbones+   -  Reputation: 2103

Like
2Likes
Like

Posted 09 March 2013 - 09:24 PM

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.


C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!


#3 Alex_kir   Members   -  Reputation: 314

Like
2Likes
Like

Posted 10 March 2013 - 05:02 PM

http://www.sdltutorials.com/sdl-scale-surface enjoy ;p


Edited by Alex_kir, 10 March 2013 - 05:02 PM.


#4 BeerNutts   Crossbones+   -  Reputation: 2999

Like
0Likes
Like

Posted 11 March 2013 - 03:17 PM

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).


My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS