Need help, on pset4, whodunit. I am trying to change all instances of red to white, instead of black. When I changed all instances of red to black, I was able to see a bit of the image beneath it , which looked blueish; anyhow when I try to change all instances of red to white, using 'triple.rgbtRed = 0xffffff', it gives me an error message of trying to change an 'int' to a 'byte'. I don't understand why it is giving me this message when I was able to change the color of red to black using 'triple.rgbtRed = 000000'. Even when I changed it to 'triple.rgbtRed = ffffff', I still got an error message. 1st error message

2nd error message

3 Answers 3


Black is represented by all three RGB elemments set to 0 or minimum value, or no color. White is the maximum color. If you want to change a pixel to white, you need to change all 3 elements to 0xff:

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

This is the correct format for these elements.

If this answers your question, please accept this answer to close the question. Let's keep up on forum maintenance. ;-)


Each part of the RGBTRIPLE can be 0xff, 0x00, 0xf0, or 0x0f. They can't be 0x000000- that's for the whole triple.

  • 0x000000 is still 0, so it's not wrong. The wrong part is triple.rgbtRed = 0xffffff, since max value of single color in RGB triple is 0xff (255). Jul 25, 2015 at 17:48

Condition triple.rgbtRed = 0x0000ff isn't wrong, but it checks value of the red part only. It is equal to triple.rgbtRed = 0xff. If you want to check check whole color of pixel, you have to use triple.rgbtBlue and triple.rgbtGreen values too.

triple.rgbtRed = 0xffffff part doesn't work, because you're changing value of single color (rgbtRed) and it cannot be bigger than 0xff (255) in the RGB system. Again, for desirable effect you should use triple.rgbtBlue and triple.rgbtGreen values too.

You must log in to answer this question.

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