Message: 7
SDL-announce)"
Message-ID: <4889DBAA.1070005 at gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowedUse the rotozoom feature of SDL_gfx.
Andre Botelho wrote:
is there a fast way to resize images on SDL?
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Message: 8
SDL-announce)"
Message-ID: <789951.74947.qm at web28607.mail.ukl.yahoo.com>
Content-Type: text/plain; charset=“utf-8”You can also do it by hand copying pixel per pixel …
But you need to know a little bit of direct access to pixels,
algorithmic, and antialiasing for zoom in.To give an idea, if you divide an image size by two, you
simply copy pixels with an even x and y coordinate.
This is a very simply example, it is not so straightforward
when the destination size is not an exact divisor of the original size …
(or only the width, not the height and vice versa).When you make an image bigger, aliasing appear and you need
to apply an antialiasing filter to it (neighbours, gauss, etc.).If you want to play and learn new things, try doing it by hand, else,
as Andre suggested, use a library having this feature implemented for you,
like SDL_gfx.Regards
I’m trying to strech a surface, i’ve tried rotozoom but it doesn’t work and
how I was interested on the scaling thing I tried one code posted on the
tutorial at http://www.sdltutorials.com/sdl-scale-surface/ but it?s sooo
slow that my proc usage goes to 100% in only a 1,2% strech of a 320x240
surface.
Here is the code:
SDL_Surface *ScaleSurface(SDL_Surface *Surface, Uint16 Width, Uint16 Height)
{
if(!Surface || !Width || !Height)
return 0;
SDL_Surface *_ret = SDL_CreateRGBSurface(Surface->flags, Width, Height,
Surface->format->BitsPerPixel,
Surface->format->Rmask, Surface->format->Gmask,
Surface->format->Bmask, Surface->format->Amask);
double _stretch_factor_x = (static_cast<double>(Width) /
static_cast(Surface->w)),
_stretch_factor_y = (static_cast(Height) /
static_cast(Surface->h));
for(Sint32 y = 0; y < Surface->h; y++)
for(Sint32 x = 0; x < Surface->w; x++)
for(Sint32 o_y = 0; o_y < _stretch_factor_y; ++o_y)
for(Sint32 o_x = 0; o_x < _stretch_factor_x; ++o_x)
DrawPixel(_ret, static_cast<Sint32>(_stretch_factor_x *
x) + o_x,
static_cast(_stretch_factor_y * y) + o_y,
ReadPixel(Surface, x, y));
return _ret;
}
Can anyone tell me why is it so slow?
OBS: the prog tries to get 60FPS.> Date: Fri, 25 Jul 2008 08:56:58 -0500
From: Leo Cabrera
Subject: Re: [SDL] Image resize
To: "A list for developers using the SDL library. (includes
Date: Fri, 25 Jul 2008 14:06:48 +0000 (GMT)
From: julien CLEMENT
Subject: [SDL] Re : Image resize
To: "A list for developers using the SDL library. (includes