GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Sep 22, 2014 12:14 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Getting the Color of a Pixel as Red , Blue , Green
PostPosted: Mon Apr 02, 2007 11:26 am 
Offline
Familiar Face

Joined: Wed Mar 07, 2007 6:53 am
Posts: 12
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.


Top
 Profile  
 
 Post subject: Correctness of the values obtained
PostPosted: Tue Apr 24, 2007 5:48 am 
Offline
Familiar Face

Joined: Wed Mar 07, 2007 6:53 am
Posts: 12
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group