Re: Getting the color of a pixel
- From: Owen Taylor <otaylor redhat com>
- To: Bryan Brown <bbrown saltmine radix net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Getting the color of a pixel
- Date: Thu, 28 Nov 2002 20:47:20 -0500 (EST)
Bryan Brown <bbrown saltmine radix net> writes:
How does one get the color of a pixel in a drawing area or a pixmap using
gtk 1.2 on a Linux box?
I'm successfully drawing lines and points in different colors, but I also
need to be able to get the color of a given point that's already been
drawn in another routine.
I'd generally try to avoid doing this, it's going to be inefficient
and not very reliable. (Certainly don't do this for a window; the
point might be obscured by another window or offscreen. It's
a little better for a pixmap.)
For GTK+-1.2 it's also not possible to do without dropping down
to Xlib. GTK+-2.0 adds gdk_colormap_query_color() which you can
use like:
====
image = gdk_drawable_get_image (root_window, x_root, y_root, 1, 1);
pixel = gdk_image_get_pixel (image, 0, 0);
g_object_unref (image);
gdk_colormap_query_color (colormap, pixel, &color);
===
(Code snippet from gtkcolorsel.c's color dropper ... that's about
the only case I would suggest it.)
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]