[SDL] Re: Re: Simple font resize with blend

Joby Bednar thebigcheese at jobybednar.com
Wed Jan 29 11:59:02 PST 2003


>This is for reduce the font size?
>It's right, but this is only an example:
>I want to resize an SDL_Surface, add a simple 'blend' for a better
>graphic result.
>Using it for this char resize is only an example,
>I want add a member function on a Image object that can do it for any
>Image (an image object contain a sdl_surface member object)

Any image?  And having your destination rect being a smaller size than your source rect when blitting doesn't cut it?  When I've played around with it, as long as you keep the ratios fairly normal between to two rects, it usually looks pretty sharp to me.  Different ratios for a reduced size do better than others, so try playing around with that and see if it works for you.

Otherwise, yes, the logic you are using will have to be done for RGB values... you just have to remember that color info is stored in different ways so double check your settings and you'll have to manipulate the color by seperately adding each color channel and then combining them to your single Uint that stores the color.  Something like:

If you have RGBs for pixel 1, and RGB for pixel 2... then...

Uint24 R = (R1>>1)+(R2>>1); //bit shift x right 1 == x/2
Uint24 G = (G1>>1)+(R2>>1);
Uint24 B = (B1>>1)+(R2>>1);

RGB = (R<<16)&(G<<8)&(B);  //if color is in 24 bit 0x(R)(G)(B) format

I'd just play around with it and make sure you manipulate the right bits with the right formats, but that should do it... or something like that.

- Joby
http://jobybednar.com
Give someone a program - frustrate them for a day.
Teach them how to program - frustrate them for a lifetime.

 
               




More information about the SDL mailing list