0

Check50 is giving an ok for resizing a 1x1 pixel bmp when n is 1,4, and 5 but not the others. Not sure what's going wrong.

Made this again because I thought I knew what the problem was. For some reason padding was added to the end of each scanline when I didn't correctly implement it. Now that, I think, its fixed check50 still gives errors.

    // changes the biWidth and biHeight to match the new size
    bi.biWidth *= n;
    bi.biHeight *= n;

    // determine padding for scanlines
    // padding for infile
    //int infilepadding = (4 - (bi.biWidth / n * sizeof(RGBTRIPLE)) % 4 ) % 4;
    int infilepadding = (4 - (bi.biWidth / n % 4) ) % 4 * sizeof(RGBTRIPLE);

    // padding for outfile
    //int padding =  (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
    int padding = (4 - (bi.biWidth % 4) ) % 4 * sizeof(RGBTRIPLE);
1

You're on the right track, the problem is the padding. Take a look at your padding calculation.

int infilepadding = (4 - (bi.biWidth / n % 4) ) % 4 * sizeof(RGBTRIPLE);
int padding = (4 - (bi.biWidth % 4) ) % 4 * sizeof(RGBTRIPLE);

You have to have sizeof(RGBTRIPLE) ( 3 bytes ) inside the calculation before you do the modulo calculation. Interestingly, you commented out the correct calculation. This needs to be fixed for both the input and output padding calculations. Once you put the lines that were commented out back, it passes CHECK50. Maybe you edited it at some point and forgot to save before rebuilding?

If this answers your question, please mark it as answered. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

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