Slanted bitmap, stride calculation for RGB565 C#

前端 未结 2 1458
终归单人心
终归单人心 2021-01-22 11:52

Some of my resulting images are slanted, some are not.

Expected Result: (529x22)

Actual Result: (529x22)

Don\'t mind the differen

2条回答
  •  误落风尘
    2021-01-22 12:11

    This expects the stride to correspond to the width, without padding. There can be padding. The padding would "eat" some of the next line, which will therefore appear to shift left.

    Since the padding breaks up the lines, the only real way to deal with it (other than using the same padding everywhere) is copying line by line. You can calculate the starting address of a line with bmpData.Scan0 + y * bmpData.Stride. Copy starting there, for every y.

    // bytes => not using this because it gives error

    Yes, because your array does not have padding. So you were telling it to copy more data than the array held.

提交回复
热议问题