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 625875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:21:28+00:00 2026-05-13T19:21:28+00:00

if there is an integer value, eg. 86 then how can i extraact the

  • 0

if there is an integer value, eg. 86 then how can i extraact the r,g,b components from this integer value….?
I am working on Visual C++ 2008 express edition.
Thanks..

  • 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-05-13T19:21:28+00:00Added an answer on May 13, 2026 at 7:21 pm

    Usually (and I repeat usually, since you don’t specify much in your question) a color is packed in a 4-bytes integer with RGBA components.

    What you need to do is mask and shift, for example:

    int color = 0xRRGGBBAA;
    
    u8 red = (color & 0xFF000000) >> 24;
    u8 green = (color & 0x00FF0000) >> 16;
    u8 blue = (color & 0x0000FF00) >> 8;
    

    This assumes the kind of encoding I specified, but can be modified according to yours.

    EDIT:
    In your example you spoke about a 0-255 value. It is not clear if components are 2bit sized (4 intensity values per component).

    In that case the approach still remains the same but you will have just few colors:

    u8 color = 86;
    
    // so you take 2 bits and multiply by 64 to possibly have intensities: 0, 64, 128, 192
    u8 red = ((color & 0xC0) >> 6) * 64; 
    u8 green = ((color & 0x30) >> 4) * 64;
    u8 blue = ((color & 0x0C) >> 2) * 64;
    

    EDIT2: Maybe your colors are indexed with palette, in that case you should have an array that stores the palette itself and the byte you read from the file should be the index of a color stored somewhere else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.