Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 6666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can someone explain to me about 16 bit? It is very confusing. bits,bytes,megabytes what is that all about?! if it''s 16 bit why is there 565 555 etc?? what is 5 bits of a color?? what''s the 2 on 2^8 = 256??! is each pixel 2 bits?? #define _RGB16BIT565(r,g,b) ((b%32) + ((g%64) <<6) + ((r%32) << 11)) what does that mean?? what''s the % for? what''s shifting bits?? can somebody help me make sense of 16 bit?? Maybe an intro to it?? thx!

Share this post

Link to post
Share on other sites
565 means bits for RED GREEN BLUE. If you are 16 bit, that means of those 16 bites, 5 are used for RED, 6 for green, and 5 for blue.

1 - 2 color shades
2 - 4 color shades
3 - 8 color shades
4 - 16 color shades
5 - 32 color shades
6 - 64 color shades
7 - 128 color shades
8 - 256 color shades

If you are in 24 bit / 32 bit mode, you will have 8 bits for each Red Green Blue, that means you have each shade be between 0-255... In 16 bit, you have between 0-31... And in the case for green (since it is 6), 0-63. When you setup in 555 mode, you are giving 5 bits for all Red Green Blue.

Someone else might be able to tell you exactly what the Macro is doing. My guess is you specify a value in the "RGB" betwee 0-31 for the R and B, and 0-63 for the G and it will return you the 32 bit color but I''m not sure.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
While there are many colors in the light spectrum, the human eye is only capable of seeing red, blue, and green. So TV screens and computer screens can only display these colors; they mix them to get the colors you are familiar with. For example, red and green makes yellow. (This works differently than pigments on paper).
So anyway, a short integer is 16 binary digits, or bits, long. That''s 16 ones and zeros. Binary is a number system like decimal, only it''s in base 2 instead of base 10, in case you don''t know. So 1 is 1, 2 is 10, 3 is 11, and 31 is 11111. You should notice that that''s five bits. Six bits can likewise hold a number from 0-63, which brings us to the next subject, the %.
x % y in C represents the modulus operator, which takes the remainder when you divide x by y. So a number modulus 64 gives a value from 0-63, which is just big enough for 6 bits. This is to check that the number you give isn''t too big.
So, the way the red, green, and blue color values are stored is that they are packed with red in the biggest 5 bits, green in the middle 6, and blue in the least significant 5 bits. All the #define does is tells the compiler that when you type _RGB16BIT565(12,14,15) it should be replaced with ((15%32) + ((14%64) << 6) + ((12%32) << 11). This happens wherever you type that in the code. The reason the shift operators are there is to push those 5 or 6 bits into the correct places in the number.
I hope I helped you a little with this fast introduction to a lot of math. One other thing I can tell you is that this #define will cause 3 divisions to be done on your numbers, and it might be faster to make sure the numbers are in the right range and just put b + (g << 5) + (r << 11). This is what I would do since I am a speed freak. But anyway, I hope I helped.

Share this post

Link to post
Share on other sites
>While there are many colors in the light spectrum, the human eye is only capable of seeing red, blue, and green.

Actually, the human eye can see more than RGB.

White light is actually composed of seven colors.

Red, Orange, Yellow, Green, Blue, Indigo, Violet (Roy G. Biv)

When you look at someting, you are seeing the reflected light mixed with the above colors.

TV and computer video cards only display Red, Green, and Blue.
That is why computers and TV have a hard time with Yellows. Fortunately, the mixture of RGB is close enough to simulate other colors. Look at the yellow on your monitor and then look at the yellow on a real plant like a daisy. Computer cant come close.

Which brings up a neat point...what if videocard makers started making video cards that projected the full spectrum (roygbiv)?

Imagine the colors!!


Rock the cradle of love!
You stupid WANKER!

Edited by - Coleco on July 17, 2000 11:08:34 AM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!