Resize is compiling but the outfile bmp doesn't open. It gives me an error "Not enough memory to load bmp". Does anybody have any idea why that might be happening? Where am I going wrong? Here's my source code..
Thank you so much.
for (int i = 0; i < n; i++)
{
// write outfile's BITMAPFILEHEADER
fwrite(&bf, (n*n*sizeof(BITMAPFILEHEADER)), 1, outptr);
// write outfile's BITMAPINFOHEADER
fwrite(&bi, (n*n*sizeof(BITMAPINFOHEADER)), 1, outptr);
}
// determine padding for scanlines
int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
RGBTRIPLE pic[bi.biHeight][bi.biWidth+padding], imp[n*bi.biHeight][n*(bi.biWidth+padding)];
// temporary storage
RGBTRIPLE triple;
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
// iterate over pixels in scanline
for (int j = 0; j < bi.biWidth; j++)
{
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
pic[i][j]=triple;
}
}
for(int i=0; i<(n*bi.biHeight); i++)
{
for (int j=0; j<(n*(bi.biWidth+padding)); j++)
{
for(int a=0;a<n;a++)
{
for (int b=0;b<n;b++)
{
imp[n*i+a][n*j+b]=pic[i][j];
}
}
}
}
for (int i=0; i<(n*bi.biHeight); i++)
{
for (int j=0; j<(n*bi.biWidth); j++)
{
triple=imp[i][j];
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
}
for (int l = 0; l < padding; l++)
{
fputc(0x00, outptr);
}