How to resize a bitmap

后端 未结 1 427
感情败类
感情败类 2021-01-14 04:59
    // determine padding for scanlines
int padding =  (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;

// iterate over infile\'s scanlines
for (int i = 0, biHeight =         


        
相关标签:
1条回答
  • 2021-01-14 06:00

    At the line level you should after single read of a pixel do n writes of it. This is done by adding another inner loop. That copied pixel resides at triple var during the operation.

    At the file level you should repeatedly process single line, reading and writing it multiple times.

    If your input file is on the disk, it should support rewinding. So you can read the line, write it (duplicating pixels inside, as shown above), then rewind the file to the start of the line, read the line again, write it, etc.

    Try to store the file position with ftell before reading the line, and rewind the file position to this point with fseek each time you need to process it.

    0 讨论(0)
提交回复
热议问题