 |
GTK+ Forums Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
|
|
|
| Author |
Message |
|
|
blakemadden
Joined: 28 Nov 2006 Posts: 3
|
Posted: Sat Dec 30, 2006 8:09 pm Post subject: get GtkColor RGB values as guint8 |
|
|
| 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
|
Posted: Sat Dec 30, 2006 11:16 pm Post subject: |
|
|
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 |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group CodeBB 1.0 Beta 2
|