[SDL] Get pixel value ...more in details

David Olofson david.olofson at reologica.se
Mon Aug 27 13:39:01 PDT 2001


On Monday 27 August 2001 21:28, Rainer Deyke wrote:
> "David Olofson" <david.olofson at reologica.se> wrote in message
> news:mailman.998921405.27562.sdl at libsdl.org...
>
> > Yes it does. A nicer and safer way to write such code would be
> > something
> > like
> >
> > int res;
>
> Should be 'Uint32' (or 'unsigned long'), otherwise it will break on 16
> bit CPUs.
>
> > char r,g,b;
>
> Should be 'Uint8' or 'unsigned char'.  Signed rgb values are
> non-sensical.
>
> > res = (int)r;
> > res |= (int)g << 8;
> > res |= (int)b << 16;
>
> Integer promotion rules make these casts redundant.  Replace 'int' with
> 'Uint32', and they'll be correct and no longer redundant.

Yes, of course. I was somewhere else when I wrote that... *heh*


//David Olofson --- Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
|      Multimedia Application Integration Architecture      |
| A Free/Open Source Plugin API for Professional Multimedia |
`----------------------------> http://www.linuxdj.com/maia -'
.- David Olofson -------------------------------------------.
| Audio Hacker - Open Source Advocate - Singer - Songwriter |
`--------------------------------------> david at linuxdj.com -'




More information about the SDL mailing list