C# Byte[,,] в Image

есть массив где первый индекс отвечает за цвет 0=Red 1=Green 2=Blue, второй за ширину и третий за высоту. Как из байтов собрать картинку используя LockBits?

byte[,,] picture = BitmapToByteRgbQ(new Bitmap(ms)); 

я получаю 3-х мерный массив

public unsafe static byte[,,] BitmapToByteRgbQ(Bitmap bmp)
    { 
        int width = bmp.Width,
            height = bmp.Height;
        byte[,,] res = new byte[3, height, width];
        BitmapData bd = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly,
            PixelFormat.Format24bppRgb);
        try
        {
            byte* curpos;
            fixed (byte* _res = res)
            {
                byte* _r = _res, _g = _res + width * height, _b = _res + 2 * width * height;
                for (int h = 0; h < height; h++)
                {
                    curpos = ((byte*)bd.Scan0) + h * bd.Stride;
                    for (int w = 0; w < width; w++)
                    {
                        *_b = *(curpos++); ++_b;
                        *_g = *(curpos++); ++_g;
                        *_r = *(curpos++); ++_r;
                    }
                }
            }
        }
        finally
        {
            bmp.UnlockBits(bd);
        }
        return res;
    }

Ответы (0 шт):