1

这是我的代码。我的输出仅对第一行像素是正确的。我已经正确地水平拉伸了第一行,并且填充是正确的。但是对于下一行,填充不正确,并且像素没有被正确地垂直拉伸。

// 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;
4

0 回答 0