My output is a grey square with a white rectangle at the top and bottom. What is it fwriting?
// iterate over infile's scanlines (for each row)
for (int i = 0; i < bi.biHeight; i++)
{
//iterate over scale factor for rows
for (int n = 0; n < scale_factor; n++)
{
// iterate over pixels (for each pixel/column)
for (int j = 0; j < bi.biWidth; j++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr); //are you sure it is inptr
//iterate over scale factor (for the scale factor - columns)
for (int m = 0; m < scale_factor; m++)
{
// write RGB triple to outfile
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
} //closes (for the scale factor - columns)
} //closes (for every pixel)
// then add padding to output file.
for (int k = 0; k < outfile_padding; k++)
{
fputc(0x00, outptr); //I think this is getting hit too many times
} // close for outfile padding
//skip padding on input file
} //close for scale_factor loop
fseek(inptr, infile_padding, SEEK_CUR);
} //closes for each row loop
// close infile
fclose(inptr);
// close outfile
fclose(outptr);
// success
return 0;
}
{}
button of the editor, it will add or remove four spaces at the beginning of each line, that's the StackExchange-flavoured markdown for a code block.bi.biHeight
, if it refers to the value in one of the files, should be negative (meaning image is stored top down, positive would be bottom up). And doesbi.biHeight
refer to input height or output height?