I’ve had exceptional luck with the Bresenham resize. It gives almost
bicubic quality, and I’ve done 640x480 images in realtime. To me,
realtime
is decoding MPEG-2 in, resizing, and encoding MPEG-4 out. If I remember
correctly, my MPEG-2 in was 720x480 and my MPEG-4 out was 320x240.
A web search will bring up C++ template code for the algorithm.
Gerald
-----Original Message-----
From: sdl-bounces+gbr=majentis.com at libsdl.org
[mailto:sdl-bounces+gbr=majentis.com at libsdl.org] On Behalf Of David Olsen
Sent: Thursday, May 25, 2006 4:08 PM
To: A list for developers using the SDL library. (includesSDL-announce)
Subject: Re: [SDL] Surface scaling again.
Kevin,
I just noticed this post! I’ll tell you what I did, I did lots of digging
around on the net, found no pre-made solutions, and finally came up with
something that works well for me and my situation - loading images and
scaling them all before using them on-screen. It doesn’t work well with
real-time scaling, as it’s a little slow, though for typical sprite-sized
images, it’s pretty quick. What I ended up doing was scrapping the SMS
emulator B-spline implementation(which worked, but didn’t produce as sharp
an image as I would have liked.) and modified a grayscale resizing
function
from “Graphics Gems”, published like back in the mid- or early ninties.
Anyway, allow me to clean up the code just a little bit, and I’ll post a
link to it.
The “library” basically is called by functions where you pass in a
SDL_Surface *, and the new size you want(either in exact x,y sizes, or a
percentage/float), and it returns the new image, optimized for the current
screen format. It actually has several options for quality vs. speed,
different interpolation techniques. I’m happy to say that it gives really
quite good results when shrinking images, which is what I was looking for
back in December. Oh, yeah, it automatically handles alpha, too. I can’t
vouch for the common pixel formats beyond 32-bit, but I think I made it so
that it converts first to 32-bit, does all the calculations, then converts
back to screen format. I know it works just fine with 16 and 32 bit
images -
might have problems with 8-bit, might not.
Okay, off to the IDE for some cleanup of code. I’ll post a link soon.
-David Olsen
----- Original Message -----
From: “Kevin Baragona”
To:
Sent: Tuesday, May 23, 2006 7:04 PM
Subject: [SDL] Surface scaling again.
I have the same problem that David Olsen did here:
libsdl.org/pipermail/sdl/2005-December/071786.html. I need a scaling
function to implement resolution-independent sprites and the obvious
"make things bigger" effect. Right now I have rotozoom statically linked
into my project, but, as he mentioned, it uses ugly integer division
when downscaling. Given that the images will be downscaled on most
screens, I find this unacceptable. So, what I need is basically a
function that will handle at least bilinear scaling, alpha channels, and
hopefully all the common pixel formats.
That thread seems to have left off with him hacking the code from that
Sega emulator to handle more pixel formats and alpha channels. AFAIK he
hasn’t posted the code anywhere for we freeloaders to use and love. With
a 7th grade education under my belt, I’m not quite capable of even
understanding how that function from SMS+SDL operates, much less hack it
to use alpha (which I need). My question is, does anyone here have a
scaling function that 1) handles common pixel formats 2) uses at least
bilinear interpolation even when downscaling 3) handles alpha channels
and 4) that you want to give away?
Thanks,
Me.
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl