C# LockBits perfomance (int[,] to byte[])

后端 未结 5 1285
滥情空心
滥情空心 2020-12-21 06:26
Graphics g;
using (var bmp = new Bitmap(_frame, _height, PixelFormat.Format24bppRgb))
{
    var data = bmp.LockBits(new Rectangle(0, 0, _frame, _height), ImageLockMo         


        
5条回答
  •  清酒与你
    2020-12-21 06:27

    You can skip the first Array.Copy where you copy the data from the image to the array, as you will be overwriting all the data in the array anyway.

    That will shave off something like 25% of time, but if you want it faster you will have to use an unsafe code block so that you can use pointers. That way you can get around the range checking when you access arrays, and you can write the data directly into the image data instead of copying it.

提交回复
热议问题