30.09.2010, 20:54
Quote:
you sure it is made by you?...
heres a code that i found on my server pawn Код:
|
Lets take a look at both
Код:
R << 24 G << 16 B << 8 A
Код:
R * 16777216 G * 65536 B * 256 A
Код:
R << 24 = R * 2^24 = R * 16777216 //and G << 16 = G * 2^16 = G * 65536 //and B << 8 = B * 2^8 = 256
Код:
(100 * 16777216) + (0 * 65536) + (255 * 256) + 0 //alpha is out of the picture for now //which equals 1677721600 + 0 + 65280 + 0 //which equals 1677786880 //which is correct
Код:
0b01100100000000000000000000000000 //31,30, and 27 turned on (1677721600) + 0 + 0b00000000000000001111111100000000 //9-16 bits turned on (65280) + 0 = 0b01100100000000001111111100000000 //which is (1677786880)
01100100000000001111111100000000
if you convert those binary values, you'll get the original results (red=100,green=0,blue=255,alpha=0).Thats pretty much all there is to this really. If your wondering "why 8bit?" its because the color depth we are using is 8bit. There are higher options for color depth, but we cant store them all in pawn (work out r=255 g=255 b=255 a=255 and you'll see why).
I can go into a bit more detail, but i think its best to keep it simple (dont want a mile long post here).
Quote:
good but even DracoBlue released a HexToInt function in his DUtils (ofc it contains other useful functions)
But with his function you can insert strings pawn Код:
|