I've got a delphi dll which has a deal with camera and stores video frames to 3d byte-array inside this dll. 3d dimention is needed to implement rgb format, and it is a convenient for dll background (as developer said). So, I have to access that array from c# code, build a Bitmap and display its content. But i dont understand how to access the array elements properly. Here is my code:
private unsafe void ByteArray2Bitmap(IntPrt data, int width, int height, int depth, out Bitmap bmp)
{
// create a bitmap and manipulate it
bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
BitmapData bits = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, bmp.PixelFormat);
fixed(byte*** data = (byte***)(m_data.ToPointer()))
{
for (int i = 0; i < height; i++)
{
int* row = (int*)((byte*)bits.Scan0 + (i * bits.Stride));
for (int j = 0; j < width; j++)
{
int pixel = BitConverter.ToInt32(&data[i][j][0], 0);
row[j] = pixel;
}
}
}
bmp.UnlockBits(bits);
}
That line of code got error: The right hand side of a fixed statement assignment may not be a cast expression
fixed(byte*** data = (byte***)(m_data.ToPointer()))
Is the any way to access multi dimentional unmanaged arrays without copying them with Marshal Copy?