loading images using SDL

Started by
3 comments, last by Slather 14 years, 10 months ago
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?
Advertisement
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.
So, when game makers draw their sprites and what not, they draw them to scale?
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.
Patrick
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.

This topic is closed to new replies.

Advertisement