0

Ok I've been working on this for hours and I'm baffled. The header file all matches the staff implementation having checked it through peek.

But when I run resize 4 on small.bmp I get this:

enter image description here

So that is telling me that there's an issue with the vertical resizing and also that I'm probably messing up the padding somewhere?

But I really can't see where I'm going wrong in the code - any help welcome!

EDITED - code removed

6
  • Your biggest for loop loops through all the rows. Inside that, you have a for loop that loops through n times. This logic may not be wrong, but it is confusing. Also, your code fseek(inptr, 54 + (v * (originalwidth * sizeof(RGBTRIPLE)) + originalpadding), SEEK_SET); is always looping through the same pixels in the input bitmap because you are setting the current position to the same thing every loop. May 29 '16 at 23:14
  • Your goal is to read through every pixel in the input bitmap and stretch it n times, then have the rows stretched n times. You won't get anywhere if you are only reading some of the pixels in the input bitmap. Remember that v can only iterate n times. Hope this was a bit helpful. May 29 '16 at 23:14
  • I see what you mean about it being confusing. I've rejigged the code and now I'm just getting a solid green square. This is a really hard pset! But thanks for your help, I'll keep trying.
    – MelJ79
    May 30 '16 at 9:18
  • Ok I'm still struggling with this. I've got 2 different versions of the code now and they are both failing on the vertical loop somehow, even though they look fine in gdb. First version looks like it's reading in the first line and copying down across the whole vertical space, the second version is reading and copying the first line only, leaving unwritten space below. I know I should be able to figure this out but I can't see the issue with my code - any other tips?
    – MelJ79
    May 30 '16 at 10:25
  • Do you mind sharing your new code now? May 30 '16 at 13:43
0

I finally finished it! This might help others who are stuck.

I started from scratch to make sure I understood how my loops should be nested.

Then I realised I was getting really confused with fseek. Once I realised that I needed to move the inptr back to the beginning during the vertical resizing (except for when all the lines had been written) I was able to sort it out. Yay!

1
  • Since you've figured it out, you should click the checkmark button to signify that the problem is solved. there should be one to the left of this message somewhere. May 31 '16 at 17:55

You must log in to answer this question.

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