GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting the Color of a Pixel as Red , Blue , Green

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Example Code
Author Message
Abhijit Singh
Familiar Face


Joined: 07 Mar 2007
Posts: 12

PostPosted: Mon Apr 02, 2007 11:26 am    Post subject: Getting the Color of a Pixel as Red , Blue , Green Reply with quote

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

PostPosted: Tue Apr 24, 2007 5:48 am    Post subject: Correctness of the values obtained Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Example Code All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP