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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:12:19+00:00 2026-06-07T19:12:19+00:00

I have 2 bytes representing color in an 8-bit format MSB LSB 01234567 RRGGBB

  • 0

I have 2 bytes representing color in an 8-bit format

MSB  LSB
01234567
  RRGGBB

Bits 0 and 1 are trash.

To blend two colors, should I just average the bits per color?

R1 = ( C1 ^ 00110000B ) >> 4;
G1 = ( C1 ^ 00001100B ) >> 2;
B1 = ( C1 ^ 00000011B );

R2 = ( C2 ^ 00110000B ) >> 4;
G2 = ( C2 ^ 00001100B ) >> 2;
B2 = ( C2 ^ 00000011B );

R3 = avg( R1 , R2 ) << 4;
G3 = avg( G1 , G2 ) << 2;
B3 = avg( B1 , B2 );

C3 = R3 + G3 + B3

Where C1 is the 1st color, C2 is the second, C3 is the blended color, ^ is bitwise AND, >> is bitwise shift right, << is bitwise shift left, xxxxxxxxB is a binary number and avg( a , b ) is the arithmetic mean.

  • 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-07T19:12:23+00:00Added an answer on June 7, 2026 at 7:12 pm

    You can think of colours are points in a 3D space. The definition of “average” depends on what space you use. You will get different results if you average RGB, HSL, or something more “exotic”.

    But if you’re limited to 2 bits per colour then none of that is really going to matter much and what you suggest is fine (except, as noted in the comments, you need &, and not ^, to mask).

    (By “average” I assume you mean add the bits (per colour) and divide by 2 (right shift). Note that if you do this repeatedly (eg avg two images, then avg the result with a third, then avg the result of that with a fourth) then you’ll eventually end up with something black because the right shift rounds down, so you’re slightly biased to lower values).

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

Sidebar

Related Questions

I have two bytes, 8 bit octets, which should be read as: [3 bits][4
I have an array of bytes representing an image in Windows BMP format and
I have two chars = 4 bytes, that representing integer value (geted from stream).
I have a Java BigInteger containing two bytes (ex: 1000000100110111). I would like to
I have a string representing bits, such as: 0000101000010000 I want to convert it
I have the following issue here: I get a block of bytes (uint16_t*) representing
If I have a x-bit value represented as 1s and 0s representing true and
I have an array of ushorts, with each ushort representing a 12-bit word. This
In F#, imagine we have an array of bytes representing pixel data with three
I have a list of hex strings representing bytes, of the form FF. I

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.