I've been stuck on resize for a while and I think I nearly have it. My outputs are nearly accurate except for the fact that some of the pixels are not being placed properly, and I think this has something to do with the padding.
Looking into their hexadecimals it seems to have something to do with the fact that 0x00's are being padded into the wrong places, but I'm not sure why this is the case.
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
// iterate over pixels in scanline
for (int j = 0; j < old_width; 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 < n; k++) //Does everything n times
{
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
}
// skip over padding, if any
fseek(inptr, old_padding, SEEK_CUR);
// then add it back (to demonstrate how)
for (int k = 0; k < new_padding; k++)
{
fputc(0x00, outptr);
}
//move cursor back to recopy for height
if (i < n - 1)
{
fseek(inptr, -old_width * sizeof(RGBTRIPLE) - old_padding, SEEK_CUR);
}
}