1

I have struggled to progress with the whodunit problem for hours: I watched the walkthrough from this year and older; I read various other forum question; and I read various documentation.

The walkthroughs proved valuable and led me to start by running an if function that changed all pixels that do not have a full value (0xff) for green or blue with:

 fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
        if (triple.rgbtGreen ==!0xff | triple.rgbtBlue ==!0xff)  
        {

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

This code ended up turning most of my code white, leaving a sentence in light blue that seems to be the answer. A few questions:

  1. Why did it work? Shouldn't the blue pixels have been converted to white as well since the blue pigments in verdict do not appear to be completely blue and thus should not have triple.rgbtBlue = 0xff? Thus they too should have been converted to white, theoretically.

  2. I tried to see what pixels changed with:

    xxd -c 36 -g 3 -s 54 verdict.bmp
    

and they all appear ffffff, which leads me to wonder how I see the blue print at all?

  1. It feels a bit anti-climatic since I feel I don't have a mastery on much of the code, except for how to change the pixels with an if function....

1 Answer 1

1
  1. Remember that we are dealing with additive color (so, not like you may traditionally think of colors with paint). If you want red, you would have blue and green both set to 00 and red to FF. Your if statement will set all blue/green that isn't FF to FF, essentially turning all red (OOOOFF) to white (FFFFFF). Any pixel that had a red component slightly less than FF (like E0 or F1 or F3) would become a shade of cyan (light blue). Light Cyan, for example, has Red EO Green FF Blue FF. See http://www.colorhexa.com/e0ffff for example.

  2. The image is overwhelmingly white, so you might miss the pixels that are cyan unless you pipe your xxd results to text file and search for E0, for example, to find them.

  3. The point of the Whodunit problem is to become familiar with file i/o and how you can read a file, change some values, and write to a new file. It sounds like you've done just that.

2
  • please, are you explaining that to change the cyan color to darker one, we have to look for the red E0 instead of working with the Blue one ? I was more thinking that we would be doing changes only with the Blue. Can u explain why ?
    – Genevie
    Commented Aug 24, 2017 at 0:12
  • No, I was explaining why, after setting the green & blue to FF, you end up with cyan.
    – curiouskiwi
    Commented Aug 24, 2017 at 0:56

You must log in to answer this question.

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