c++ - Getting the colour that belongs to the given integer -


i learnt working mechanis of rgba, realised hexadecimal numbers belongs different colours can turned simple integers. means can store colours in integers, though of them quite big.

my question how can colour belongs integer give program?

edit: of course forgot mention use allegro i'm new in it...are there functions of whatever can it?

it sounds using allegro 4 if storing colors integers. provides variety of functions use, check out manual.

// int makecol(int r, int g, int b);  int white = makecol(255, 255, 255); int green = makecol(0, 255, 0); 

or inverse:

int r = getr(color); int g = getg(color); int b = getb(color); 

with allegro 4, ordering depends on graphics card. return value of makecol() can different same color depending if stored rgb or bgr. must use above functions proper color values, , after setting graphics mode.

if using allegro 5 (which highly recommend on allegro 4), use allegro_color struct, hides underlying implementation details , none of above applicable.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -