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 

get GtkColor RGB values as guint8

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
blakemadden



Joined: 28 Nov 2006
Posts: 3

PostPosted: Sat Dec 30, 2006 8:09 pm    Post subject: get GtkColor RGB values as guint8 Reply with quote

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?
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 495
Location: Portland, OR USA

PostPosted: Sat Dec 30, 2006 11:16 pm    Post subject: Reply with quote

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.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming 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