Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8416703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:50:24+00:00 2026-06-10T01:50:24+00:00

I am writing a GTK+ application that is using Pango text attributes to determine

  • 0

I am writing a GTK+ application that is using Pango text attributes to determine the color and other aspects of the text written onto a GtkLabel using something like this:

attributes = pango_attr_list_new();
pango_attr_list_insert(attributes, pango_attr_foreground_new( G_MAXUINT16, G_MAXUINT16, G_MAXUINT16));
pango_attr_list_insert(attributes, pango_attr_size_new (18 * PANGO_SCALE));
pango_attr_list_insert(attributes, pango_attr_weight_new( PANGO_WEIGHT_BOLD ));

lblTotalCredits = gtk_label_new(NULL);
gtk_label_set_text(GTK_LABEL(lblTotalCredits),"0");
gtk_label_set_attributes(GTK_LABEL(lblTotalCredits), attributes);

pango_attr_foreground_new() expects each color component ( R,G,B ) to by 16 bits. Using Photoshop or other image processing tools I can find the color I want to use, but the R,G,B values are displayed as 8 bit R,G,B components.

How do I convert the 8 bit R,G,B values to the equivalent 16 bit R,G,B values so I end up with the same color?

For example, a golden color is specified as RGB ( 229, 202, 115 ) or hex e5ca73. How do I convert that so that each color component is 16 bits for pango functions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:50:25+00:00Added an answer on June 10, 2026 at 1:50 am

    8bit max: 0xFF
    16bit max: 0xFFFF

    convert (I use red as a demo) (untested):

    guint32 colorhex = 0xe5ca73;
    const guint8 red8 = (guint8)((colorhex & 0xFF0000) >> 16);
    //    guint16 red16 = (guint16)(((guint32)(r * 0xFFFF / 0xFF)) & 0xFFFF);
    guint16 red16 = ((guint16)red8 << 8) | red8;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a C++ application using GTK and OpenGL. I have a GTK
i am writing a text editor in gtk 3 using python. in gtk 2
I am writing a text editor using gtk+-2.0 & gtksourceview-2.0. I am having trouble
I am writing a text editor in C using gtk+-2.0 & gtksourceview-2.0. I'm trying
I am writing a simple application and am using glade (gtk) for the UI.
I'm writing an application using gtkmm. I wrote a simple widget class, that I
I am writing application in C# using GTK# GUI framework to make it cross-platform.
I'm writing a text editor in gtk+ 2.0 & gtksourceview 2.0. Currently I'm using
I've got a gtk file chooser button on my application I am writing in
Writing a client application that sends images to a server via a webservice. As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.