Welcome fellow students, register yourself and dive into asking questions, giving answers and helping the community learn with you.

pset4 programm resize

0 votes
asked Jun 16, 2018 in Pset4 by aleksandrvaluiskikh (120 points)
My code is partially correct, but I have a couple of issues.

1. It does not work with small.bmp

2. I do not understand how fseek works in this program.

What is wrong, where is the mistake?

 

   // iterate over infile's scanlines
    for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
    {

 

        for (int a = 0; a < scale; a++)
        {
            // iterate over pixels in scanline
            for (int j = 0; j < bi.biWidth; j++)
            {
                // temporary storage
                RGBTRIPLE triple;

                // read RGB triple from infile
                fread(&triple, sizeof(RGBTRIPLE), 1, inptr);

                // write RGB triple to outfile
                for (int b = 0; b < scale; b++)
                {
                    fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
                }
            }

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

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

            fseek(inptr, -(bi.biWidth * 3 + padding ), SEEK_CUR); //DO NOT UDERSTAND THIS LINE

            }
        fseek(inptr, bi.biWidth*3+new_padding, SEEK_CUR); //DO NOT UDERSTAND THIS LINE
        
    }

Please log in or register to answer this question.

Welcome to CS50xHelpers Q&A, where you can ask questions and receive answers from other members of the community.

188 questions

248 answers

217 comments

3,308 users

1 Online
0 Member And 1 Guest
...