Converting a UINT32 to SDL_Color and viceversa

How can i do this?–
Roger D. Vargas
Linux user #180787
ICQ: 117641572

  • No hay nada tan importante que no pueda ser olvidado *
    Alzheimer

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;

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Thursday 27 January 2005 17.21, Roger D. Vargas wrote:

How can i do this?

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