BitmapSource.CopyPixels -what's a good value for stride?

前端 未结 2 1510
面向向阳花
面向向阳花 2020-12-15 23:43

I\'m trying to get the pixel data from a WPF BitmapSource object. As I understand, this can be accomplished by calling its CopyPixels method. This

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 00:12

    var stride = ((bitmapSource.PixelWidth * bitmapSource.Format.BitsPerPixel + 31) / 32) * 4;
    

    or

    var stride = ((bitmapSource.PixelWidth * bitmapSource.Format.BitsPerPixel + 31) >> 5) << 2;
    

提交回复
热议问题