GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Oct 31, 2014 5:50 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: get GtkColor RGB values as guint8
PostPosted: Sat Dec 30, 2006 8:09 pm 
Offline

Joined: Tue Nov 28, 2006 9:42 pm
Posts: 3
I'm trying to format a GtkColor as an HTML color spec (e.g., "#AF0000"), but to do this you need your RGB values as bytes in the range of 0-255. GtkColor RGB values are uint16s that range from 0-65,000+, so I'm afraid that these values are too big. Is there a way to convert a gint16 into a guint8 correctly?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 30, 2006 11:16 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Divide it by 256 since 65536 is simply 256 * 256.

If there are 256 variations of a color element, and it's represented by a range of 0 - (256*256) then each step of color has a value of 256. So, a value of 0 - 255 is actually 0, 256 - 511 is actually 1, etc.

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


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: Yahoo [Bot] and 4 guests


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