Re: about GdkColor



Thanks. You explained it clearly.

Jun

 --- Valdis Kletnieks vt edu 的正文:> On Mon, 21 Apr
2003 10:28:29 +0800,
> =?gb2312?q?Jun=20Ma?= <ma_jun1973 yahoo com>  said:
> 
> > As we know a color can be described by RGB. RGB is
> > enough. But, why does GdkColor use the following
> > structure: 
> >   struct GdkColor {
> > 
> >   guint32 pixel;
> >   guint16 red;
> >   guint16 green;
> >   guint16 blue;
> > };
> > 
> > What is the 'pixel' in GdkColor? What is the
> relation
> > between 'pixel' and RGB? How to know the pixel's
> value
> > from RGB?
> > 
> > For example, when the color is red or RGB(65535,
> 0,
> > 0), what will be the 'pixel'?
> 
> It's essentially a "magic cookie".  It has no
> purpose or meaning other
> than "this pixel should be drawn with the same
> colors as the allocate-color
> function that returned this value".  Yes, that's
> round-about, but it's
> done that way for a reason....
> 
> Under some circumstances, it may look like the RGB
> value, but it's basically
> the return value from the underlying function (such
> as XAllocColor() or
> whatever the back-end uses).  As such, it could be
> the index of a colormap
> entry if you're using an 8-bit PseudoColor visual
> (quite often, "white" will be
> pixel value 0 and "black" pixel value 1, or the
> other way around).  If you're
> using more colors than the visual can handle and
> dithering or nearest-color
> matching happens, it could even be that several
> different RGB values are mapped
> to the same "close" pixel value.
> 
> So basically, you pick the RGB, allocate the color,
> and the system gives you
> back a pixel number, and you then use that number
> every time you want that
> color.  It's sort of like an extensible
> paint-by-numbers kit.... ;)
> 

> ATTACHMENT part 2 application/pgp-signature 
 

_________________________________________________________
Do You Yahoo!? 
雅虎邀你参与CCTV-2对话节目调查:移动、联通、灵通,要说爱你不容易
http://rd.yahoo.com/mail_cn/tag/?http://cn.surveys.yahoo.com/cctv_wireless_study



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