Here is the code for resize.c I am stuck for quite some time now and i am not able to figure out where i am wrong. please help.
bi.biHeight = height*n;
bi.biWidth = width*n;
// determine new padding for scanlines
int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
bi.biSizeImage = (bi.biWidth*sizeof(RGBTRIPLE) + padding)*abs(bi.biHeight);
bf.bfSize = bi.biSizeImage +54;
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
for(int p=0;p<n;p++){
// iterate over pixels in scanline
for (int j = 0; j < width*n; j++){
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
for(int wr = 0; wr<n;wr++){
// write RGB triple to outfile
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 < padding; k++){
fputc(0x00, outptr);
}
}
}
// close infile
fclose(inptr);
// close outfile
fclose(outptr);
// that's all folks
return 0;