开发者

how many color combinations in a 24 bit image

开发者 https://www.devze.com 2022-12-31 02:55 出处:网络
I am reading a book and I am not sure if its a mistake or I am misunderstanding t开发者_开发技巧he quote. It reads...

I am reading a book and I am not sure if its a mistake or I am misunderstanding t开发者_开发技巧he quote. It reads...

Nowadays every PC you can buy has hardware that can render images with at least 16.7 million individual colors. Rather than have an array with thousands of color entries, the images instead contain explicit color values for each pixel. A 24-bit display, of course, uses 24 bits, or 3 bytes per pixel, for color information. This gives 1 byte, or 256 distinct values each, for red, green, and blue. This is generally called true color, because 256^3 (16.7 million)

He says 1 byte is equal to 256 distinct values. 1 byte = 8 bits. 8^2 bits = 64 combinations of colors right ?? It's not adding up right to me. I know it might be something simple to understand, but I don't understand.


The combinations of 8 bits is not 82 (64) but 28 (256). This is because each of the 8 bits can have 2 distinct values. For 1 bit that would give you 2 (21) possibilities, for 2 bits 2*2 (22), for 3 bits 2*2*2 (23)... etc. 3 bytes = 24 bits => 224 = 16.7M possible combinations.


1 byte = 8 bits = 2^8 = 256 combinations :)

24 bit combinations = 2^24 = Three 8 bit colors = 256^3 = 16777216 ~= 16.7 million color combinations


If you have 24 bits for the color information you can display 2^24 colors = 16.7 million!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号