Do you understand why you have to check for values over 255? You are doing it too late.
A BYTE has 8 bits. That means the maximum value it can hold is 255. You are calculating the new value and storing it directly into image[i][j].rgbtRed for example. At that point, if the calculated value is > 255, it will be truncated when you assign it. So it's ...
Look at the following code:
if(SEPIA[k] > 255)
SEPIA[k] = 255;
What is the value of k? Where is it incremented? Is it possible that some code was forgotten to be added? ;-)
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)
The input file, card.raw is empty now. Look at the following code:
FILE *new_card = fopen(argv, "w");
As soon as you ran this code the first time, the input file card.raw was deleted and a new, empty file of the same name created. You can compare by running this command: ls -al card.raw
You need to remove this section of code from the source ...
Did you actually run the program locally? If you went straight to check50, the code ran on a remote server, so the output file wouldn't have been created locally. You can't open a file that doesn't exist. Also, are you in the same directory where you executed filter and the output file was created?
When you put double quotes around argv, it says use this text as a literal file name, so the program goes looking for a file named argv. Since the file doesn't exist, the fopen() call fails and the file pointer is set to NULL. Then, the code prints that error message.
The seg fault is caused by the next line, fclose(input). Since the input pointer is ...
The code knows how long each structure element is, thanks to the definition in the header file, so it only needs to add the appropriate number of bytes to the starting address to get to anything. The elements are sequentially ordered, and that order never changes, nor are any other data fields placed in the sequence.
For example, BITMAPINFOHEADER.biPlanes is ...
This code has an infinite loop. Look at the last while condition statement:
while (fread(buffer, 512, 1, forensic) <= 1);
What happens when the end of the input file is reached? fread will return 0, so the loop never ends! Instead, it should check for == 1.
Next, notice that every output file is 512 bytes. Remember, once the first signature is found, ...
There are several issues in this code.
First, look at how i is being incremented. Inside the code, it is incremented by 512 in several places, but it's also being incremented by 1 in the for loop setup. That will throw the alignment to 512 byte blocks off.
The test for signatures occurs in 2 places. In the first,
if (buff == 0xff && buff == ...
This doesn't look like a code problem. Since check50 passes, the code is ok.
Most likely (I'll put the odds at over 98%), the file infile.bmp either doesn't exist in the directory where you're running the program, or it is corrupted.
Check to see that the file infile.bmp exists in the current directory and open it to see that it contains an image.
If this ...