New answers tagged

0

I have had to look at this for a moment to get my head to understand the logic. You have written your feof condition in a way that should work, but it would be much easier to follow if written feof(in)==1 or feof(in) as both of these clearly evaluate to true; you currently have written a statement that reads "not false" which is just awkward to ...


1

Maybe the code should use the while statement to actually read data and use an if statement inside the while loop to look for signatures?


0

I see a couple of issues. First, I see you dividing an int by a double. You need to cast the the whole thing to a double to get decimal values (round((double)(numerator/denominator))). Second, I do not know why your equation has a backslash \ character in it--this is not a C operator that I am familiar with. I would remove the \ and fix the casting and it ...


1

Please note I haven't validated this with testing and have only glanced at your code, but one thing that stands out to me: round((float) (sum_blue / pixel_type)) Remember operator precedence here: the division will be performed first (as it is inside parentheses). At this point both values are integers so integer division will be performed and the remainder ...


1

First, when your program reaches line 74, you already have a file open that has it's location stored in a pointer you named img. When your program goes to write to this, it does not try to reopen it or recalculate where that pointer should be going to using the path that you have laid out. Instead, it reads the location that is stored within img even though ...


0

You appear to be using the exclusive OR operator in the following lines when you might be wanting to square them. blue = bx^2 + by^2; green = gx^2 + gy^2; red = rx^2 + ry^2; Remember, C does not have an exponent operator, so you must do something like bx*bx or use the pow() function from math.h to square it.


0

Didn't see an infinite loop, just no files being created. First, no signatures are being found. There's an error in the signature check: buffer[2] == 1 Next, after the first file, the remaining files are created with incorrect file names. Specifically, there is no file extension on the file names. There may be other issues, but this should get you going.


0

Question: What happens if the very first 512 byte data block does not contain a signature???? ;-) Debugging tips: This might help you out a lot - Do YOU know how to find a seg fault?? Advice to new programmers If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


0

The problem is that the second block of code that processes odd width is dead code. It will never run. The cause is the placement of the first return statement. It is outside of the first if statement code block, so it will ALWAYS be executed. The first return statement should be placed before the closing curly brace just above it. This will put the return ...


0

Looks like a typo on the buffer[1] comparison. It never finds a jpeg signature. I would have expected it to fail at fclose(img);; it likely doesn't because img is never initialized; it just hangs.


0

The problem is the return statement. It's inside the outer for loop, so only the first row gets processed. This is why keeping indentations correct is important when writing code. Perhaps you should spend some quality time with style50? ;-) If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


0

The seg fault happens because no output file is being opened and the code is trying to close the last output file. No files are being opened because no signature is ever found. There's a typo in the if statement that checks for signatures. If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


0

Looks like you have assigned incorrect value for rgbtBlue image[i][j].rgbtBlue = sepiaRedCapped;


Top 50 recent answers are included