0

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 Answers1

0

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

halfer
  • 19,824
  • 17
  • 99
  • 186
TheGeneral
  • 79,002
  • 9
  • 103
  • 141
  • Ok, now I understand how works this SafeArray. Your example works fine, except CopyTo(), beacuse it work only with one dimensional arrays. I used instead Clone(). – KorneliuszM Mar 23 '20 at 12:32