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

  • Home
  • SEARCH
  • 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 8456415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:32:43+00:00 2026-06-10T12:32:43+00:00

I’m writing a project in xlib and have a problem concerning the colors.I use

  • 0

I’m writing a project in xlib and have a problem concerning the colors.I use unsigned long type variables for storing the color values.does anybody know how can i take the red green and blue values of each color?

  • 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-10T12:32:45+00:00Added an answer on June 10, 2026 at 12:32 pm

    Are you saying that the 24 bits of color (8 for each color component) are stored together in one 32 bit integer? If that’s the case you can obtain the values using the logical AND operation to zero the other bits.

    Let’s say you start with

    /*
    alpha? r g b
    00000000 10101010 10101010 10101010 your 32 bit integer might look like this
    & logical AND operator
    00000000 00000000 00000000 11111111 a bit mask
    =
    00000000 00000000 00000000 10101010 the result
    so now your 32 bit integer only has the blue values.
    To do this in code...
    */
    unsigned char B = (unsigned char) (your_integer & 0x000000ff) //000000ff is hex version of the bit mask
    //but now what about the other two colors? you can't just apply a bit mask like 0000ff00 because 00000000000000001010101000000000 is much larger than 255.
    
    //So you have to either divide the result by 256 to shift the bits right, or use >>8 to shift them to the right.
    
    unsigned char G = (unsigned char) ((your_integer & 0x0000ff00) / 256)
    unsigned char R = (unsigned char) ((your_integer & 0x00ff0000) / 256^2)
    //or using the way I've used in the past... shifting before the mask.
    
    unsigned char G = (unsigned char) ((your_integer >> 8) & 0x000000ff)
    unsigned char R = (unsigned char) ((your_integer >> 16) & 0x000000ff)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.