[SDL] converting a UINT32 to SDL_Color and viceversa

Roger D. Vargas roger at ehtsc.co.cu
Thu Jan 27 09:26:35 PST 2005


El jue, 27-01-2005 a las 20:33, David Olofson escribió:
> On Thursday 27 January 2005 17.21, Roger D. Vargas wrote:
> > How can i do this?
> 
> Depends on the format of that UINT32... Something like:
> 
>         SDL_Color c;
>         c.r = i >> 16;
>         c.g = i >> 8;
>         c.b = i;
> and
>  i = (c.r << 16) | (c.g << 8) | c.b;
> 
I think that should work, the uin32 is something like 0xff00ff. I knew
it could be solved with shifts, but I didnt knew the correct syntax in C
and if it also requires some specific order.
Thanks a lot.

-- 
Roger D. Vargas
Linux user #180787
ICQ: 117641572
* No hay nada tan importante que no pueda ser olvidado *
Alzheimer





More information about the SDL mailing list