像素编程继续

5 c# arrays image pixels

我有一个BGR顺序的像素字节数组,我想在C#中创建一个图像.有人可以提供代码或建议吗?

use*_*826 1

一些效果(未经测试)


        private Bitmap createImage(int width, int height, byte[] image)
        {
            int index = 0;
            byte r, g, b;
            Bitmap bmp = new Bitmap(width, height);
            for (y as int = 0; y < height; y++)
            {                
                for (x as int = 0; x < width; x++)
                {
                    b = image[y * width + index];
                    g = image[y * width + index + 1];
                    r = image[y * width + index + 2];
                    bmp.SetPixel(x, y, Color.FromArgb(255, r, g, b));
                    index += 3;
                }                
            }
            return bmp;
        }

Run Code Online (Sandbox Code Playgroud)