Convert object(int[,]} to int[,]

102 views Asked by At

I'm trying to write simple program to get image from astronomy camera, image data is read as object{int[,]} according to this doc: ASCOM.DriverAccess.Camera.ImageArray

To display and convert this data to image I want to convert it to 2D int array. Could someone help me how to do this? Or maybe it's better, simpler way to convert this image object array to image...

1

There are 1 answers

1
TheGeneral On

What you seemingly have is a SafeArray.

The application must inspect the Safearray parameters to determine the dimensions.

You may be able to do this

Array ct = (Array)SomeFunkyArrayTypeYouGet;
int[,] content = new int[ct.GetUpperBound(0), ct.GetUpperBound(1)];
ct.CopyTo(content, 0);

Note : I have not tested this, nor confident it will work, it's based on a result I found with a quick web search