0

I have been trying to debug my code for days now with little success. The enlarged image seems shifted when I open it. The white pixels in the middle are skewed off center, though my file is the same length as the staff's. Any help would be GREATLY appreciated.

// Iterate over the infile scanlines (height)
    // Repeat for vertical copy
        // Iterate over each infile's rgb triple
            // store the triple after reading
            // write the triple n times
            // write the spacing that's required
        // seek to the beginning of the line you just read (width+padding)
    // skip over infiles padding and continue to read next line
//close infile

//close outfile

EDIT

    for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
    {
        for (int m = 0; m < n; m++)
        {
            for (int j = 0; j < bi.biWidth; j++)
            {
                RGBTRIPLE triple;
                fread(&triple, sizeof(RGBTRIPLE), 1, inptr);

                for (int l = 0; l < n; l++)
                {
                    fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
                }
            }

            for (int k = 0; k < padding2; k++)
            {
                fputc(0x00, outptr);
            }

            fseek(outptr, -(bi2.biWidth + padding2), SEEK_CUR);
        }
        fseek(inptr, padding, SEEK_CUR);
    }

EDIT

    for (int i = 0, biHeight = abs(bitmp.biHeight); i < biHeight; i++)
{
    // Repeat for vertical spacing output
    for (int m = 0; m < n; m++)
    {
        // Iterate over pixels in infile's scanlines
        for (int j = 0; j < bitmp.biWidth; j++)
        {
            // temporary storage
            RGBTRIPLE triple;

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

            // write RGB triple to outfile n times
            for (int l = 0; l < n; l++)
            {
                fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
            }
        }
        // skip over padding, if any and move to the next line        
        fseek(inptr, padding, SEEK_CUR);

        // add padding
        for (int k = 0; k < padding2; k++)
        {
            fputc(0x00, outptr);
        }

        // seek to the beginning of the scan line and repeat
        fseek(inptr, -(bitmp.biWidth+padding)*sizeof(RGBTRIPLE), SEEK_CUR);
    }
}
3
  • Your pseudocode looks fine. It's hard to tell without some code because the logic is alright but there may be some errors in your code. Try to pinpoint the potential area and post that.
    – Lucas
    Dec 8 '14 at 9:47
  • Your last fseek just uses the standard padding gotten from the input file, without compensating for the resized height and width. Figure out how to compensate for that. Also try skipping over the infile padding, before writing it to the outfile. Dec 8 '14 at 15:17
  • A few things that are wonky for me: in my vert spacing loop m < n+1 not just n, the image is two lines longer than the staffs, the white center of the large.bmp is smaller than it should be. I have added fseek above by padding2 output and then modified the last fseek to include width and padding. I'm completely stuck...
    – user2137
    Dec 9 '14 at 22:47

You must log in to answer this question.