这是我的代码。我的输出仅适用于第一行像素。我已经水平正确地拉伸了第一条线,并且填充是正确的。但是对于下一行,填充不正确,并且像素没有垂直正确拉伸。
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(oldHeight); i < biHeight; i++)
{
for (int l = 0; l < factor; l++)
{
// iterate over pixels in scanline
for (int j = 0; j < oldWidth; j++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
for (int k = 0;k < factor;k++)
{
// write RGB triple to outfile
fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);
}
}
// skip over padding, if any
fseek(inptr, oldpadding, SEEK_CUR);
// then add it back
for (int k = 0; k < padding; k++)
{
fputc(0x00, outptr);
}
}
if (i != factor)
{
fseek(inptr, -bi.biWidth-padding, SEEK_CUR);
}
}
//structure of RBG struct
typedef struct
{
BYTE rgbtBlue;
BYTE rgbtGreen;
BYTE rgbtRed;
} __attribute__((__packed__))
RGBTRIPLE;