 |
GTK+ Forums Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
|
|
|
| Author |
Message |
|
|
Abhijit Singh Familiar Face
Joined: 07 Mar 2007 Posts: 12
|
Posted: Mon Apr 02, 2007 11:26 am Post subject: Getting the Color of a Pixel as Red , Blue , Green |
|
|
GdkImage *Img;
GdkColor result ;
GdkImage *Img;
GdkColormap *CMap;
gulong Pixel;
Img = gdk_drawable_get_image ( drawing_area->window, x,y,wth,ht );
Pixel = gdk_image_get_pixel(Img , 2 , 2 ); // (0,0) to wth-1,ht-1
CMap = gdk_colormap_get_system ();
gdk_colormap_query_color ( CMap, Pixel, &result);
Use result.red, result.blue,result.green. |
|
| Back to top |
|
 |
Abhijit Singh Familiar Face
Joined: 07 Mar 2007 Posts: 12
|
Posted: Tue Apr 24, 2007 5:48 am Post subject: Correctness of the values obtained |
|
|
| The values obtained as result.red , result.green, result.blue are not exact but are very close to exact values. In most cases you will not have to bother about this by using +/- approximation. i.e if exact value of red component is 35000 then result.red will be somewhere around 34882 which i suppose is enough close. |
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group CodeBB 1.0 Beta 2
|