first of all
please for my english
:-(
> Message: 24
> Date: Tue, 28 Jan 2003 10:19:06 -0800
> From: "Joby Bednar" <thebigcheese at jobybednar.com>
> To: <sdl at libsdl.org>
> Subject: Re: [SDL] Simple font resize with blend
> Reply-To: sdl at libsdl.org>> It's probably far easier to simply build a font engine that blts letters... but if you want to get crazy:
>>> You might want to try bit manipulation of a one dimensional array of 16 bit integers. Since you're scanning through the arrays looking for a flag or not, a 1 or 0 bit would do the same. I'd use a Uint16 to keep things simple, and use the remaining 6 bits to hold the resized font info. You should then be able to manipulate the integers with bit opperations and can store the new size in the remaining 6 bits. Create another array that will be your fade affect array, and in it just store the pixels that should be shaded. A simple bit shifting to the right and left ANDed together and then the original XORed (cut out... which ever that is... I always get my opperations confused). You should be left with the halo of the fade, effectively. You can then use a routine to scan the two arrays and fill in the correct colors into your surface... though pixel by pixel is a bit slow I would assume.
>> 0000110000000000 = 0x0C00
> 0001111000000000 = 0x1E00
> 0001111000000000 = 0x1E00
> 0011111100000000 = etc...
> 0011111100000000
> 0011001100000000
> 0011001100000000
> 0111001110000000
> 0111111110000000
> 0111111110000000
> 0110000110000000
> 1110000111000000
> 1100000011000000
> 1100000011000000
> 1100000011000000
> 0000000000000000
>> Uint16 a[16]={0x0C00,0x1E00,0x1E00,etc...}
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)
Having a simple small font with 3 color (#=black +=gray ' '=trasparent)
####
####
######
######
## ##
## ##
### ###
########
########
## ##
### ###
## ##
## ##
## ##
In fact,
the output of this program is
#+
+##
###
# #+
####
+# +#
#+ #
# #
with 3 color.
But I have to use a similar script for resize an sdl_surface, if it
isn't too slow.
I can get a determinate pixel of a surface, but how can I get the 3
color of pixel (red, green, blue)?!?
However, the script became slowest because I have to calcolate 3 color
blend for every pixel
>> Then it's just a matter of resizing and creating another array for the fade, which rather than doing the logic like you have, can be done faster by simple bit shifting. I'd do this during startup and simply refer to them later, rather than calculating every time.
I don't understand how i can resize the font using a Uint16...
I have to reconvert 0x0C00 to 0000110000000000, calculating and revert
it to 0x0C00 ?
> Again, bmp image blts of letters is probably easier.
>> - Joby
>http://jobybednar.com> Give someone a program - frustrate them for a day.
> Teach them how to program - frustrate them for a lifetime.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030128/3581637c/attachment-0008.pgp>