Current Code so far: http://pastebin.com/EA1w9vxZ

So right now I have Horizontal scaling working, however Im a bit confused at vertical scaling.

I've added a loop that should repeat each line of pixels....but I think im not sure I understand how the position of the file is set back to the beginning after each line of pixels is written.

    // skip over padding, if any
    fseek(inptr, padding, SEEK_CUR);

    // then add it back (to demonstrate how)
    for (int k = 0; k < padding; k++)
        fputc(0x00, outptr);

^^ Those lines make sense, as were skipping past the padding on the infile ptr, but then re-adding the padding on the outfile....so that makes sense

But how on the next line are we setting the position back to the beginning of the line? Where would be my next step?

1 Answer 1


Did you watch the video? They give a few ways to do it.

Take a doubling example 4x4


becomes 8x8


Now it's easy to do the horizontal scaling. So how do you write the same row again? They give a few methods, I used an array in my code. Essentially, you need a way to remember what needs to be written again. I'd go back and watch the walkthrough video.

  • What about the padding? I guess it'd be an array of RGBTRIPLES right? with the size of width? But the padding is what confuses me
    – msmith1114
    Feb 10, 2017 at 19:23
  • 1
    So you'll have a function/section of your app building your array and then another writing that array to the file. In the section where you are writing, that's where you need the code for adding padding. They already give you that code (both for how to calculate the amount and how to add it), just make sure you have recomputed the values using your new height and width. Feb 10, 2017 at 19:26
  • Also, remember you can create arrays with x and y values. Feb 11, 2017 at 17:07

You must log in to answer this question.

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