My resize program is having trouble resizing an unless I use 4 for the scale, which resizes the image perfectly. Using a number like 1, 2, 3, or 5, 10, etc. results in a really crazy image. Here is the relevant code, I'm attempting to use the recopy method for vertical resizing.
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
// if height for outfile is not completed, go back to previously set position to continue writing
for (int m = 0; m < scale - 1; m++)
{
// iterate over pixels in infile scanline
for (int n = 0; n < bi.biWidth; n++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
// write RGB triple to outfile
for (int o = 0; o < scale; o++)
{
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
}
// add new padding to outfile
for (int p = 0; p < new_padding; p++)
{
fputc(0x00, outptr);
}
// skip over padding in infile, if any
fseek(inptr, padding, SEEK_CUR);
// seek to beginning of infile scanline's row
fseek(inptr, -((bi.biWidth * sizeof(RGBTRIPLE)) + padding), SEEK_CUR);
}
// 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);
// write RGB triple to outfile
for (int k = 0; k < scale; k++)
{
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
// then add new padding to outfiles
for (int l = 0; l < new_padding; l++)
{
fputc(0x00, outptr);
}
}
// skip over padding in infile, if any
fseek(inptr, padding, SEEK_CUR);
}