- How do I scale a 2D image that I loaded using the SDL_LoadBMP function? I think it should have something to do with the SDL_Rect structure, maybe it has two values like width and height but I can’t figure it out. How do I go about this?
SDL doesn’t do this for you. In the past, I’ve done this on my own
(zoom-in effect of the NBS logo in “Bug Squish”, and the thumbnailer routine
for saved images and Rubber Stamps in Tux Paint).
There are libraries that can do this for you. Rotozoom comes to mind,
but I think SDL_gfx is more up-to-date, or something. Check the SDL
libraries page if you’re interested in using one of those, rather than
writing your own. (It can be a little daunting if you’ve never done it
before.)
- Is it possible to put borders around rects? If so, how can you do this?
Sure :^) A lamely simple way is to call SDL_FillRect() four times. ;^)
/* Top border: */
dest.x = 0;
dest.y = 0;
dest.w = surf->w;
dest.h = 1;
SDL_FillRect(surf, &dest, SDL_MapRGB(surf->format, 0x00, 0x00, 0x00));
… and 3 more times, with various settings in that SDL_Rect variable,
“dest”, for the left, right and bottom sides.
This is, of course, assuming you want a 1-pixel wide border in black.
Otherwise, adjust dest.w/h and the RGB values sent to SDL_MapRGB as
appropriate.
Good luck!
-bill!On Wed, Jun 25, 2003 at 02:48:14PM +0200, gpa at fsmail.net wrote:
–
bill at newbreedsoftware.com Got kids? Get Tux Paint!
http://newbreedsoftware.com/bill/ http://newbreedsoftware.com/tuxpaint/