Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.unix.programmer > #1017

Re: X11: Get red, green and blue values from a pixel value

From pacman@kosh.dhis.org (Alan Curry)
Newsgroups comp.unix.programmer
Subject Re: X11: Get red, green and blue values from a pixel value
Date 2011-07-25 01:09 +0000
Organization Aioe.org NNTP Server
Message-ID <j0ifob$j50$1@speranza.aioe.org> (permalink)
References <45ec449a-9e02-451b-8d4e-6ad67d13afd0@g16g2000yqg.googlegroups.com>

Show all headers | View raw


In article <45ec449a-9e02-451b-8d4e-6ad67d13afd0@g16g2000yqg.googlegroups.com>,
tm  <thomas.mertes@gmx.at> wrote:
>Hello,
>
>after retrieving a pixel from a window with XGetImage and
>XGetPixel (I know of the bad performance, of getting single
>pixels), I need to get the red, green and blue values of that
>pixel. In other words: I want to define the function:
>
>  void drwPixelToRgb (long int pixel, unsigned int *red_val,
>      unsigned int *green_val, unsigned int *blue_val);
>
[...]
>
>In case of a TrueColor system I use a strategy based on
>red_mask, green_mask and blue_mask of the default_visual
>to determine red_value, green_value and blue_value.
>
>But I have no idea to get red_value, green_value and
>blue_value for other color systems.

The mask fields that you're using with TrueColor also apply to DirectColor.
With DirectColor there is an extra layer of indirection but I'm not sure how
to use it or whether anyone ever does. All the code I've found treats it
exactly the same as TrueColor.

For the others, use XQueryColor. XQueryColors if you need a lot of them in a
single burst.

-- 
Alan Curry

Back to comp.unix.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

X11: Get red, green and blue values from a pixel value tm <thomas.mertes@gmx.at> - 2011-07-24 13:02 -0700
  Re: X11: Get red, green and blue values from a pixel value pacman@kosh.dhis.org (Alan Curry) - 2011-07-25 01:09 +0000
    Re: X11: Get red, green and blue values from a pixel value Nobody <nobody@nowhere.com> - 2011-07-25 13:20 +0100

csiph-web