0

"If the R, G, and B values of some pixel in a BMP are, say, 0xff, 0x00, and 0x00 in hexadecimal, that pixel is purely red, as 0xff (otherwise known as 255 in decimal) implies "a lot of red," while 0x00 and 0x00 imply "no green" and "no blue," respectively. Given how red Mr. Boddy’s BMP is, it clearly has a lot of pixels with those RGB values. But it also has a few with other values."

I copied the above from pset4's spec. Would like to understand why 0x00 represent both "no green" and "no blue"?

5
  • 1
    I'm not sure that I get what you're asking. Logically speaking, if you have 0 of something, this means that you do not have any of it at all!
    – kzidane
    Commented Jan 12, 2015 at 15:30
  • 3
    Maybe this table would help you rapidtables.com/web/color/RGB_Color.htm
    – wallek876
    Commented Jan 12, 2015 at 15:33
  • 1
    In wallek's table note that 0x00 corresponds to null in hexadecimal
    – lethaljd
    Commented Jan 12, 2015 at 21:10
  • Thanks for the table. Another question, how do I know triple.rgbtBlue accepts a hex or dec?
    – Hang Man
    Commented Jan 13, 2015 at 3:31
  • 1
    All hex values can be represented by dec values. As long as you type 0x in front of the hex digits, the compiler should understand what you mean and accept it the same way as if you typed the dec version (e.g. if (0xff == 255) will always evaluate to true)
    – Michael F
    Commented Jan 15, 2015 at 7:23

1 Answer 1

2

The RGBTRIPLE is a struct that contains 3 bytes:

rgbtRed rgbtGreen rgbtBlue

If the value of any of these triples is 0x00, then that means that color is not in the pixel. Thus, if I had an RGBTRIPLE named triple and the values of its members were as follows:

triple.rgbtRed = 0xff; triple.rgbtGreen = 0x00; triple.rgbtBlue = 0x00;

this would represent a red pixel because there is "no" blue or green and "full" red, so to speak. Colors other than red, green, and blue are created when the values of these three fields are not restricted to being one 255 and the other two 0s.

I hope this helps :D

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .