I have been working on resize for the last 2 days now, have updated the bitmapfileheader and the bitmapinfoheader and if I do the test mentioned in the specs of resize my headers information matches with the header information of the staff. Now after updating the headers the task was to enlarge vertically and horizontally, I have attached that part of the code here and with this code when I compile it compiles correctly but when I run it gives the mentioned error. Any help would be much appreciated

// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
    //loop to enlarge the image vertically
    for(int k = 0; k < n; k++)
        // 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);

            // loop to enlarge the image horizontally and write each pixel n times horizontally
            for(int l = 0; i < n; l++)
                // write RGB triple to outfile
                fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);

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

        if(newpadding > 0)
            // then add it back (to demonstrate how)
            for (int m = 0; k < padding; m++)
            fputc(0x00, outptr);

    // to bring the pointer back to the begining of the same row
    fseek(inptr, -(bi.biWidth * sizeof(RGBTRIPLE) + padding), SEEK_CUR );


// close infile

// close outfile

// that's all folks
return 0;


1 Answer 1


You have an infinite loop in the third for loop.

for(int l = 0; i < n; l++)

See anything wrong with the test condition????

If this answers your question, please click on the check mark to accept. Let's keep up with forum maintenance. ;-)

You must log in to answer this question.

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