0

I am currently trying to conceptualize the idea of creating the vertical nth copy for resize.c but I don't grasp how the file position indicator can tell when there is a new line. How do I tell C to paste the array of the previous line into a new line beneath the newly created line?

I've created an RGBTRIPLE array named rwColor of size bi.Width * n to store the newly created line.

Also, I've changed the fwrite function to include n:

fwrite(&triple, n * sizeof(RGBTRIPLE), 1, outptr);

is this correct?

Here's my code in semi-pseudocode to prevent violation of any rules

// iterate over infile's scanlines
for each scanline
{

    // temporary array declaration
    RGBTRIPLE rwColor[bi.biWidth * n];

    // iterate over pixels in scanline
    for each pixel in the current scanline
    {
        // temporary storage
        RGBTRIPLE triple;

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

        // write RGB triple to outfile
        fwrite(&triple, n * sizeof(RGBTRIPLE), 1, outptr);

        if n is greater than 1
        {
            //place the pixels in an array
            for each integer in n
            {
                place current value of triple into rwColor;   
            }
        }

    }

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

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

    if (n > 1)
    {
        //place rwColor array beneath original scanline if n > 1
        for (int k = 0; k < rbi.biWidth; k++) // where rbi is new new infoheader with updated info
        {
            // ???? how to tell C to place in new line?
        }
    }

}
0

You should watch Zamyla's tutorial for some assistance with how to logically break this down. You probably want to go with nested for loops, the outer loop controlling height via lines, and the inner controlling the write of each line and it's width.

You must log in to answer this question.

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