I've got my headers working correctly but have been stumped on the resize process for a while now. I understand the pseudocode required to complete the horizontal and vertical resizing, but I can't quite figure out how to implement it correctly. I suspect it's due to my lack of confidence with pointers. Currently, the output image is printing out a bar that is, indeed, n times wider than the original, but none of the pixels are as they should be. Any pointers to get me headed in the right direction?

1 Answer 1


There are a couple of issues. First, you created an array of pointers to RGBTRIPLEs, not an actual array of RGBTRIPLEs. The code then loads actual RGBTRIPLEs into something that is supposed to contain addresses. Maybe you should remove the * from the declaration and just create an array of RGBTRIPLEs?

Next (ignoring the pointer problem), the code reads in a row of pixels into the array in one for loop, and then the next loop writes out n pixels to the output file. More visually, let's say you were working with letters instead of pixels, each line of letters is 10 chars long, and the scaling factor, n, is 3. The code would read in "abcdefghij" and then write out "abc", when it should be writing "aaabbbcccdddeee...." Consider using nested for loops.

There may be other issues, but this will get you started.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Cliff, would it make sense to use multidimensional arrays for this task?
    – klmo8
    Commented Mar 2, 2016 at 18:02
  • Depends on your design. Most people don't use any arrays. They simply process each pixel as they go.
    – Cliff B
    Commented Mar 2, 2016 at 18:08
  • Alright, thanks. I thought the array approach would be simpler to implement but maybe I was wrong!
    – klmo8
    Commented Mar 2, 2016 at 18:16

You must log in to answer this question.

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