1 00:00:00,000 --> 00:00:00,760 2 00:00:00,760 --> 00:00:12,286 >> [MUSIC PLAYING] 3 00:00:12,286 --> 00:00:13,280 >> ROB BOWDEN: Hi. 4 00:00:13,280 --> 00:00:16,340 I'm Rob, and let's find out who done it. 5 00:00:16,340 --> 00:00:20,070 So, starting with the template that copy.c already gives us, we see that 6 00:00:20,070 --> 00:00:22,380 most of the code is going to be the same. 7 00:00:22,380 --> 00:00:25,110 We are going to check to make sure there's an infile and outfile 8 00:00:25,110 --> 00:00:29,610 specified at the command line, we're going to open the infile for reading, 9 00:00:29,610 --> 00:00:33,490 we're going to open the outfile for writing, and finally, we're going to 10 00:00:33,490 --> 00:00:38,780 read in the infile's headers, check to make sure it's a valid bitmap, write 11 00:00:38,780 --> 00:00:43,210 the headers to the outfile, just as copy.c has done, and we're going to 12 00:00:43,210 --> 00:00:46,080 iterate over the infile scan lines in pixels. 13 00:00:46,080 --> 00:00:49,170 >> And now we see the only change in this file. 14 00:00:49,170 --> 00:00:53,680 So, we read in a triple from the infile as copy.c does, but instead of 15 00:00:53,680 --> 00:00:57,240 immediately writing the triple to the outfile, we're going to change the 16 00:00:57,240 --> 00:00:58,190 pixel data. 17 00:00:58,190 --> 00:01:02,010 So we're going to set the blue data to just 0, we're going to set the green 18 00:01:02,010 --> 00:01:06,150 to 0, leaving us with only the red, and then we're going to write that to 19 00:01:06,150 --> 00:01:07,200 the outfile. 20 00:01:07,200 --> 00:01:11,830 And then the padding is going to be exactly the same as it was in copy.c. 21 00:01:11,830 --> 00:01:14,150 Finally, close the files, return 0. 22 00:01:14,150 --> 00:01:16,070 >> So, let's see what happens. 23 00:01:16,070 --> 00:01:24,280 Let's make whodunit, ./whodunit, clue.bmp, and lets reveal that bitmap. 24 00:01:24,280 --> 00:01:25,530 Let's look at the file. 25 00:01:25,530 --> 00:01:27,900 26 00:01:27,900 --> 00:01:30,360 And we see Milo Banana dun it. 27 00:01:30,360 --> 00:01:31,920 My name is Rob, and this was whodunit. 28 00:01:31,920 --> 00:01:37,451 >> [MUSIC PLAYING]