Re: Canvas, Ellipses, and RGBA



On Mon, 6 Dec 1999, Ali Abdin wrote:

> [response is down below]
> 
> When do I use << and when do I use >>? What order must they be in?
> 
> Secondly - the RGBA values you gave are confusin - how do I get them from 
> a GnomeColorPicker - do I take the 'gdouble' values, do I take the 
> 'guint8' or the 'guint16'?
> 
> Can you give me an example? Like 
> guint8 R,G,B,A;
> guint32 fill_color = 0;
> 
> fill_color = fill_color << R << G << B << A;
> 
> Will the above work correctly? If not what should I do?
> 

<< and >> are shift operators ("a << n" takes the binary representation of
a and adds n zeros to the end.  "a >> n" removes n digits from the binary
representation of a.  

You want to do something like:
  fill_colour = 
    R << 24 +   /* shift the R value 24 bits to the left */
    G << 16 +
    B << 8 +
    A;

James.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]