0

I\m really stuck in the formula for horizontal resize.For my new padding if i enter 4 for (n) i get for my new padding answer 1, is that correct?

   fpos_t startline;
   for (int a = 0, biHeight = abs(bi.biHeight); a < biHeight; a++)
    {
       for(s = 0; s < n; s++)
         if s < 0
       fgetpos(inptr, &startline);  
       fsetpos(inptr, &startline);
        // iterate over pixels in scanline
        for (int j = 0; j < bi.biWidth; j++)
        {
            // temporary storage
            RGBTRIPLE triple;

             //verticaly works...
         }

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

        // then add it back (to demonstrate how)

        for (int k = 0; k < newpadding; k++)
        {

            fputc(0x00, outptr);
        }

    }

So it go's from 0 to abs height and if it ends should return me start position and write it, but i've got only 3 lines. Where I make mistake ??

This is what i get from peek check: enter image description here

And when i check with xxd with student version when i resize with 4 i get this: enter image description here

I'm sure that something is skipped, but I can't found my mistake. Thanks!

1 Answer 1

0

This is saying that your header info is wrong for sizeimage and bfsize. Don't forget that you need to recalculate padding values as well, and that changes in padding will affect the overall size of the image.

pseudocode for resize:

//for every row in the source file, if iterations of for loop is less than the multiplier, run again <-you need to add this

 //for every RGB triple in the source file, if iterations of for loop for width is less than the multiplier, run again   <--you have

this entire piece done

what you are currently doing:

source file

> RGBTRIPLE

and if the multiplier is 4 you are outputting:

> RGBTRIPLE RGBTRIPLE RGBTRIPLE RGBTRIPLE 

but you need to output:

> RGBTRIPLE RGBTRIPLE RGBTRIPLE RGBTRIPLE 
> RGBTRIPLE RGBTRIPLE RGBTRIPLE RGBTRIPLE 
> RGBTRIPLE RGBTRIPLE RGBTRIPLE RGBTRIPLE 
> RGBTRIPLE RGBTRIPLE RGBTRIPLE RGBTRIPLE 

4 times the height AND width. You need a for loop for the height, and nested inside of that, a for loop for the width.

9
  • okay , I fix that now everything is green but i still get the second output for the image. I got 3 lines of output , and staff solution is 12 Commented Sep 22, 2014 at 14:57
  • remember that you not only need to resize vertically, but also horizontally+padding. You should have 2 for loops for this, one nested inside the other, the outer loop handles height and the inner loop handles width
    – lethaljd
    Commented Sep 22, 2014 at 15:03
  • I edit my question. Can you tell me from where my issues came? Commented Sep 22, 2014 at 15:17
  • The issues in red in the picture above are due to your header declarations, not your for loops. How are you writing the new header info?
    – lethaljd
    Commented Sep 22, 2014 at 17:44
  • I got these in green now , the numbers in argv[1] and argv[2] are the same. The issue is in vertically resize because as you can see when i resize picture with n = 4, i just got 3 lines with "xxd check", and the staff solution has 12 lines . I messed up something in the for loop, but i dont know what. Commented Sep 23, 2014 at 6:44

You must log in to answer this question.

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