Sign in to follow this  
h0ts0up

loading images using SDL

Recommended Posts

I've been messing around with SDL and blitting surfaces and what not and found out that the function SDL_DisplayFormat() didn't do what I thought it did. I assumed that it changed the dimensions of the image to fit that of a predetermined screen via the SDL_SetVideoMode(). As I played with the functions I discovered that SDL_DisplayFormat() just starts at (0,0) and and cuts off everything not in the specified dimensions. Am I correct? If so, is there any function that will resize my image or will I just have to draw my images so that they are already the right size?

Share this post


Link to post
Share on other sites
The purpose of SDL_DisplayFormat() is to change the format of the surface, to match the display surface. This makes it faster to blit.

You could use SDL_gfx, which has routines for scaling sprites.

Share this post


Link to post
Share on other sites
Quote:
Original post by h0ts0up
So, when game makers draw their sprites and what not, they draw them to scale?


I think you may have misunderstood. :)
SDL_gfx library (an add-on to SDL) includes routines that will stretch or shrink the image to a given size. For example, you could make 64x64 sprite 128x128 or some other arbitrary dimensions.

Share this post


Link to post
Share on other sites
Your follow-up question is a little ambiguous. Pixel artists "draw" sprites in whatever size is appropriate for the window's resolution (which shouldn't vary for a game using pixel art). For a game that uses pixel art and blits sprites directly in 2d, no scaling should be neccesary. Typically, games that have "drawn" sprites use a low resolution for the window. If you want to use a high window resolution or you need to scale your sprites, use a graphics API such as DirectX or OpenGL.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this