I just finished pset3, so now I'm starting on pset4, and I'm not quite sure how to start whodunit? I think you should copy the clue (I'm not sure where to copy it to though) and iterate over each of the pixels one at a time, and if a pixel is red, turn it into white? I'm also not sure where I am actually supposed to be writing the code and how to start writing it. Thanks


Start with the clue.c code which copies the image from input to output:

Whodunit.c should transform the imput image. Instead of copying each pixel, it should make some modifications.

./whodunit clue.bmp verdict.bmp

Each pixel has Red, Green and Blue values that range from 0x00 to 0xFF. There's no one way to solve the problem - basically just try a few things. For instance, you can remove all of the green from a pixel with:

fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
triple.rgbtGreen = 0;
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);

You can also test pixel colors before changing them:

if (triple.rgbtGreen == ??) {
    triple.rgbtGreen = ??;

This problem requires a bit of guessing and checking. Try different combinations of operations. It may also help to think about what the combinations of Red, Green and Blue actually do.

You must log in to answer this question.

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