I know my paddingOld & paddingNew values are correct. I also know all my header info is correct (checked student vs staff) check 50 passes the cases that do not need padding, but fails the ones that do.

here is my resize loop (in pseudo):

for (int i = 0, while i is less than height; i++)
    if (i modulus of n does not = 0)
        fseek(back a line);

    // iterate over pixels in scanline
    for (int j = 0; while j is less than width; j = j + n)
        // temporary storage <- this is straight from copy.c
        RGBTRIPLE triple; <- this is straight from copy.c

        // read RGB triple from infile <- this is straight from copy.c
        fread(&triple, sizeof(RGBTRIPLE), 1, inptr); 

        // resize horizontally
        for (do n amount of times - standard loop)
            // write RGB triple to outfile <- this is straight from copy.c
            fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);

    // skip over padding, if any <- this is straight from copy.c
    fseek(inptr, paddingOld, SEEK_CUR);

    // then add it back (to demonstrate how) <- this is straight from copy.c except I changed my value to paddingNew
    for (int k = 0; k < paddingNew; k++)
        fputc(0x00, outptr);

Any idea why my padding is not going in?

  • did you find a solution?
    – user1580
    Sep 27 '14 at 17:39
  • The above actually works fine, the problem lay in the header info, I was missing an abs value. Sorry just noticed your comment.
    – aharris
    Oct 21 '14 at 3:19

When i == 0, 0 % n is always 0 for every n, so you start working from the line -1 (the header).

You must log in to answer this question.

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