[SDL] Re: Simple font resize with blend : Uint24 doesn't work.
thebigcheese at jobybednar.com
Thu Jan 30 17:37:01 PST 2003
Looking at it again, I'm sorry to say that I got my bit manipulation mixed up... the opperations should be OR (|) rather than AND (&) when putting it all back together. Ooops, sorry:
New C = (R<<16) | (G<<8) | B;
In your example, I could be wrong, but I thought I read somewhere that SDL.h should be the first include. In any event it looks like it thinks Uint24 is an undeclared function. I'm pretty sure Uint24 is a valid type. Either it isn't and you need to try Uint32, or your SDL library isn't loading properly.
Give someone a program - frustrate them for a day.
Teach them how to program - frustrate them for a lifetime.
---------- Original Message ----------------------------------
From: Riccardo <t1t0 at tiscali.it>
Reply-To: sdl at libsdl.org
Date: 31 Jan 2003 02:13:35 +0100
>> Message: 10
>> Date: Wed, 29 Jan 2003 17:35:29 -0800
>> From: "Joby Bednar" <thebigcheese at jobybednar.com>
>> To: <sdl at libsdl.org>
>> Subject: Re: [SDL] Re: Simple font resize with blend
>> Reply-To: sdl at libsdl.org
>> I'm assuming it is. When working with Color Keys the color format for a 24bit BMP was in RGB format like HTML, so I could do "0xRRGGBB" to knock out the background color when blitting.
>> >Uint8 Red = pixel<<16; // I can't use an Uint8? a single color have only
>> >8 bits? with this shift is Red==000000000000000011111111 ?
>> >I understand?
>> You would think so, but all the variables need to be the same type. If you bit shift an 8 bit number over 16 bits you'll be left with 00000000 since the data will be stored in 8 bits when its all said and done. What you want to do is store the 8 bits of info within 24 bit blocks. To get the RGB values from Uint24 C == 0xFF8844 for example:
>> Uint24 R = C>>16; //R=00000000 00000000 11111111;
>> Uint24 G = (C<<8)>>16; //G=00000000 00000000 10001000;
>> Uint24 B = (C<<16)>>16; //B=00000000 00000000 01000100;
>But I can't declare it:
>a.c: In function `int main()':
>a.c:6: `Uint24' undeclared (first use this function)
>a.c:6: (Each undeclared identifier is reported only once for each
>function it appears in.)
>a.c:6: parse error before `=' token
>a.c:9: `color' undeclared (first use this function)
> using namespace std;
> Uint24 color = 0xFF8844;
> for (int j=1; j<=24; j++)
> cout << j << ": " << (color << j) << "\n";
>(P.s.: how work an Uint32 color?)
>> Then when you put them back together, after you found the new color you need to fill with, you just shift them over again and bit AND them together:
>> R<<16 == 11111111 00000000 00000000;
>> G<<8 == 00000000 10001000 00000000;
>> B == 00000000 00000000 01000100;
>> New C = (R<<16) & (G<<8) & B; //C=11111111 10001000 01000100
>> If you tried to bit AND a 24 bit and an 8 bit, theoretically you are trying to do:
>> 00000000 00000000 11111111
>> & 11111111
>> Which won't work too well. Hopefully that helps... and hopefully I got it right. I personally wouldn't trust me, so try it out and see what happens. ;)
>> - Joby
>> Give someone a program - frustrate them for a day.
>> Teach them how to program - frustrate them for a lifetime.
More information about the SDL