We changed our privacy policy. Read more.
2

There are a couple of issues here. First, the for loop nesting is in the wrong sequence. The outermost loop should be based on the height of the image, but that's the innermost loop. In addition, there appears to be an extra loop based on n. Next, the logic is to process a line from the input file, then reprocess it until it's been processed n times. ...


1

I'll give you a big hint. The code is producing 3 extra lines of pixels in each output file, using a resize factor of 1, 2, or 3. Did you actually look at the raw data in the file, or just at the image? When the image is displayed, it looks correct because the actual image part of the file is correct. The header data controls what is displayed from the ...


1

Wouldn't it be more useful to write out the new headers after recalculating all the header values? ;-) If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


1

So close, but I think you might be looking in the wrong place. Have you verified that your header values are all correct in the output file????????? Those values control how the image data is displayed. If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-) [EDIT - now that Nic has found the ...


1

I'd recommend using peek as mentioned in the problem description You would see that your output headers are the same as the input headers. You change cf/ci to match the dimensions of the output image, but write bf/bi to the output file. The rest looks as if your programme should work for positive integer values, as in resize/less, while specification now ...


1

Actually, no, the code doesn't work correctly at all. First, the header data is incorrect. Two fields are not calculated correctly. Second, even at resize of 1, the image output is incorrect. small.bmp is the correct output, s2.bmp is the output from your code above. Note the second line in each file. small.bmp 00000036: 00ff00 00ff00 00ff00 000000 .......


1

Well, that's an unusual way to try and do that. You're writing to the headers in the file! Seems like the hard way to update the headers. Don't you think it would be easy to read the headers into a struct in memory, modify the appropriate values in memory, and then write the header structs out to the output file? Here's an efficiency tip. Making changes ...


Only top voted, non community-wiki answers of a minimum length are eligible