2 important questions

  1. 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?

  2. Is it possible to put borders around rects? If so, how can you do this?

Winner of the 2003 Internet Service Providers’ Association awards for Best Unmetered ISP and Best Consumer Application.

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

  1. 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. :wink:

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/

  1. 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 is a very low level drawing API, to make rescaling you must build your
own function or use SDL_rotozoom lib that does all this work you can find it
at http://www.ferzkopp.net/Software/SDL_rotozoom/

  1. Is it possible to put borders around rects? If so, how can you do this?
    Like 1. You must make your own funcs.
  1. 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?

I believe there are no native functions to do that. If that is correct,
you should use a 3rd party library or write the filtering code yourself.

Lic. Gabriel Gambetta
ARTech - GeneXus Development Team
ggambett at artech.com.uy

AFAIK for both tasks you need to use your own code (modify surface->pixels
array) or SDL-based library.On Wed, Jun 25, 2003 at 02:48:14PM +0200, gpa at fsmail.net wrote:

  1. 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?

  2. Is it possible to put borders around rects? If so, how can you do this?


Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from http://decopter.sf.net

Gabriel Gambetta wrote:

  1. 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?

I believe there are no native functions to do that. If that is correct,
you should use a 3rd party library or write the filtering code yourself.

So am I right that there are no image scaling functions whatsoever in SDL?
My problem is that I’m working on a port of an old DOS game (see thread
"malloc problems with SDL_mixer under OS X") and this was designed for
320x200 video mode like most games of that time. In the current SDL port
of the game, when running it in full screen mode you get a tiny game
window inside a 640x480 black screen, because on most platforms the
monitor can’t be set to a lower resolution. I hoped there would be a
simple way to set a scale factor of 2 between the ‘logical’ video buffer
and the actual video buffer. A simple nearest-neighbor interpolation
would be good enough since DOS games looked blocky anyway.

Lex

Lex,

as people say so much its basicly a constant chant on this list, SDL is not
a feature oriented library. It is designed to be the minimum requirements
for people to access video,sound,input etc across different platforms.

Since people make such a wide range of applications using SDL, would it make
sense to put everything you could possibly need all into the core of SDL?
Would you want the overhead of a full 3d rendering/mixing/filtering sound
engine if you were working on a 2d tiled game that only needed simple sound
effects?

So how SDL is designed is theres the core, and then theres lots of add on
libraries so you can add on the functionality you need as you need it
instead of having a huge download and exe.

The library you might be looking for is sdl_rotozoom, check it out here:

http://www.libsdl.org/libraries.php?order=name&category=any&completed=0&os=a
ny&match_name=SDL_rotozoom&perpage=50

hope this helps!> ----- Original Message -----

From: dr_lex@mac.com (Lex)
To:
Sent: Thursday, June 26, 2003 11:48 AM
Subject: [SDL] Full screen mode (was: Re: 2 important questions)

Gabriel Gambetta wrote:

  1. 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?

I believe there are no native functions to do that. If that is correct,
you should use a 3rd party library or write the filtering code yourself.

So am I right that there are no image scaling functions whatsoever in SDL?
My problem is that I’m working on a port of an old DOS game (see thread
"malloc problems with SDL_mixer under OS X") and this was designed for
320x200 video mode like most games of that time. In the current SDL port
of the game, when running it in full screen mode you get a tiny game
window inside a 640x480 black screen, because on most platforms the
monitor can’t be set to a lower resolution. I hoped there would be a
simple way to set a scale factor of 2 between the ‘logical’ video buffer
and the actual video buffer. A simple nearest-neighbor interpolation
would be good enough since DOS games looked blocky anyway.

Lex


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Gabriel Gambetta wrote:

  1. 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?

I believe there are no native functions to do that. If that is correct,
you should use a 3rd party library or write the filtering code yourself.

So am I right that there are no image scaling functions whatsoever in SDL?
My problem is that I’m working on a port of an old DOS game (see thread
"malloc problems with SDL_mixer under OS X") and this was designed for
320x200 video mode like most games of that time. In the current SDL port
of the game, when running it in full screen mode you get a tiny game
window inside a 640x480 black screen, because on most platforms the
monitor can’t be set to a lower resolution. I hoped there would be a
simple way to set a scale factor of 2 between the ‘logical’ video buffer
and the actual video buffer. A simple nearest-neighbor interpolation
would be good enough since DOS games looked blocky anyway.

If this is all being done with software rendering you can use an old DOS
trick to do the scaling. Render into a 320x240 buffer and when you copy
to the display buffer, just copy each pixel twice and each line twice.
Of course, it is as block as the original. If the pixel depth is 8 or 16
you can save some bus bandwidth by packing the duplicate pixels into a
one line buffer and then send the whole buffer using either a full word
copy or if you are lucky by using the hardware. Then you just copy the
line buffer twice.

OR, you can use OpenGL, render into a texture as was discussed earlier
this week, and then texture a rectangle the size of the screen with that
texture. You might even find that it is fast enough to render the screen
in software, sent the pixels to the graphics hardware as a texture, and
then texture the screen with that texture.

These techniques are worth a try…

		Bob PendletonOn Thu, 2003-06-26 at 13:48, Lex wrote:

Lex


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

±----------------------------------+

  • Bob Pendleton: independent writer +
  • and programmer. +
  • email: Bob at Pendleton.com +
    ±----------------------------------+