[Gtk-sharp-list] Get colour of pixel in Gdk.Pixmap
Dan Winship
danw at novell.com
Fri Jun 24 11:35:41 EDT 2005
On Fri, 2005-06-24 at 17:24 +0200, Thomas Pryds Lauritsen wrote:
> I have a Gdk.Pixmap p from which I need to fetch the colour of certain
> pixels. Something like
>
> Gdk.Color c = p.getColorOfPixel(x, y);
>
> would be preferred, but I haven't been able to find any info on this
> matter. Surely this must be possible, but the question is: how?
The "Pixels" property gives you access to the raw pixel data. However,
it's an unmanaged array, so you'll need to use unsafe code to work with
it.
http://developer.gnome.org/doc/API/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#image-data
gives an example of C code that accesses individual pixels directly. The
unsafe C# code would be similar.
-- Dan
More information about the Gtk-sharp-list
mailing list