I did read the following related qsns Resize returns correct sized square, only top half is green and white center isn't there HELP!
But they DON'T help my case , Could someone pls look at my code and provide suggestions ?
// change width, height for outfile header
bio.biWidth = bi.biWidth * n;
bio.biHeight = bi.biHeight * n;
// padding new
// determine padding for * infiles * scanlines
int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
// determine padding for oufile
int paddingo = (4 - (bio.biWidth * sizeof(RGBTRIPLE)) % 4) % 4; // paddingo is outfile padding
// change size of outfile header
bio.biSizeImage = (bio.biWidth * sizeof(RGBTRIPLE) + paddingo) * abs(bio.biHeight);
bfo.bfSize = bfo.bfSize - bi.biSizeImage + bio.biSizeImage; // Calculate actual image size
// write outfile's BITMAPFILEHEADER
fwrite(&bfo, sizeof(BITMAPFILEHEADER), 1, outptr);
// write outfile's BITMAPINFOHEADER
fwrite(&bio, sizeof(BITMAPINFOHEADER), 1, outptr);
// I moved the padding line from 79-80 to padding new heading
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
// temporary storage
RGBTRIPLE triple;
for (int p =0; p < n; p++)
{
// iterate over pixels in scanline
for (int j = 0; j < bi.biWidth; j++)
{
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
for (int k = 0; k < n; k++)
{
// write RGB triple to outfile
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
// skip over padding, if any
fseek(inptr, padding, SEEK_CUR);
// Add a new padding
for (int l = 0; l < paddingo; l++)
fputc(0x00, outptr);
if (j < n-1 )
{
fseek(inptr, -((bi.biWidth* sizeof(RGBTRIPLE)*3) + padding), SEEK_CUR);
}
} // braces for pixel j horizontal
} // for p loop n times
} // braces for main loop for Height
// close infile
fclose(inptr);
// close outfile
fclose(outptr);
// that's all folks
return 0;
}