0

I don't know exactly where is the problem. Resize gives me a bunch of different colors when n % 4 !=0. Can you guys help me understand what I'm doing wrong?

// iterate over infile's scanlines
{
    // resize vertically.
    {
        // iterate over pixels in scanline
        {
            // temporary storage
            // read RGB triple from infile
            // resize horizontally.
            // write RGB triple to outfile
        }
    }

    // skip over padding, if any

    // then add it back (to demonstrate how)
}

1 Answer 1

2

If I'm reading the code correctly, it looks like a padding issue. When you are scaling up by any number that requires padding, here's what I see happening. You read in a line of pixels, process it, and write it out, and then go back and repeat this "L" times. However, the code that adds the padding is outside the loop that does this, causing the padding to only be added after the last line of each group. For example, say that you're scaling up by 3. You will read a line of pixels in, process it 3 times, exit the loop and add the padding to the end of the third line before going back to process the next line from the input file.

Restructure so that the padding is added to each line that is sent to the output file and it should work (assuming there are no other bugs).

If this answers your question, please accept this answer to remove your question from the unanswered question pool. Let's keep up on forum housekeeping. ;-)

3
  • Thank you very much, Cliff B! It worked. I just had to move the padding to the right place. I was going insane trying to figure out what was wrong. It was something so simple. ;) Commented Jun 13, 2015 at 23:05
  • Well, that's what happens to a lot of programmers. You stare at it so much that you can't see the forest for the trees anymore. It usually takes another set of eyes, or to walk away from it for a day or two. Glad I could help. ;-)
    – Cliff B
    Commented Jun 13, 2015 at 23:17
  • Worked for me too! Thanks so much Commented Jul 12, 2016 at 2:36

You must log in to answer this question.

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