01.10.2010, 10:29
Quote:
Yes i am sure, however i know im not the first by any means. There are tons of implementations floating around. Just so you dont think i am trolling, i will explain it. First, i would like to explain that the RGBAToInt1 is pretty much the same as RGBAToInt2 (all of them are really), the only difference is it doesnt use the binary operators.
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). That has nothing to do with my defines at all lol, i guess you dont get it :\. |
okay bro you command