Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.unix.programmer > #1023
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Subject | Re: X11: Get red, green and blue values from a pixel value |
| Date | 2011-07-25 13:20 +0100 |
| Message-Id | <pan.2011.07.25.12.20.28.412000@nowhere.com> |
| Newsgroups | comp.unix.programmer |
| References | <45ec449a-9e02-451b-8d4e-6ad67d13afd0@g16g2000yqg.googlegroups.com> <j0ifob$j50$1@speranza.aioe.org> |
| Organization | Zen Internet |
On Mon, 25 Jul 2011 01:09:31 +0000, Alan Curry wrote:
>>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.
DirectColor is the bastard child of PseudoColor and TrueColor.
Like PseudoColor, it relies upon a palette (Colormap). Like TrueColor,
each pixel value is composed of distinct red, green and blue components.
Each component is used as an index into the palette, and the corresponding
component from the palette entry is used as the intensity for that
component. So the palette is essentially 3 separate intensity ramps, one
for each component.
When faced with a DirectColor visual, most code either gives up or creates
an "identity" palette, e.g.:
Colormap colormap = XCreateColormap(dpy, win, visual, AllocAll);
int n = 1 << visinfo->bits_per_rgb;
for (i = 0; i < n; i++){
XColor color;
color.pixel = i;
color.red = color.green = color.blue = i * 0xFFFF / (n - 1);
color.flags = DoRed | DoGreen | DoBlue; XStoreColor(dpy, colormap,
color);
}
XSetWindowColormap(dpy, win, colormap);
From then on, it can treat DirectColor like TrueColor.
Back to comp.unix.programmer | Previous | Next — Previous in thread | Find similar | Unroll 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