Please someone help me with my code. I think that problem is the fseek function. I don't know how to calculate the number of bytes needed to be skipped. I obtained wierd images with distorted collors.
// iterate over infile's scanlines
for (int i = 0, old_biHeight = abs(old_bi.biHeight); i < old_biHeight; i++)
{
for (int j = 0; j < n - 1; j++)
{
// iterate over pixels in scanline
for (int k = 0; k < old_bi.biWidth; k++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
// write RGB triple to infile
for (int z = 0; z < n; z++)
{
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
//padding
for (int z = 0; z < new_padding; z++)
{
fputc(0x00, outptr);
}
//send infile cursor back
fseek(inptr, old_bi.biWidth * sizeof(RGBTRIPLE) + old_padding, SEEK_CUR);
}
}
for (int k = 0; k < old_bi.biWidth; k++)
{
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
for (int z = 0; z < n; z++)
{
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
for (int y = 0; y < new_padding; y++)
{
fputc(0x00, outptr);
}
}
}
n
value of 1?