so here is what I have so far:
I'm using long here since that is what is returned from the ASCOM array
uint16 PixInsightASCOMDriver::ASCOMDataToPi( long _i )
{
return _i + 32768;
}
And I made the change you suggested:
void PixInsightASCOMDriver::ImageArray(UInt16Image &theImage)
{
long *imageData;
SafeArrayAccessData(theCameraPtr->ImageArray.parray, (void **)&imageData);
int dims = SafeArrayGetDim(theCameraPtr->ImageArray.parray);
long ubound1, ubound2, lbound1, lbound2;
SafeArrayGetUBound(theCameraPtr->ImageArray.parray,1,&ubound1);
SafeArrayGetUBound(theCameraPtr->ImageArray.parray,2,&ubound2);
SafeArrayGetLBound(theCameraPtr->ImageArray.parray,1,&lbound1);
SafeArrayGetLBound(theCameraPtr->ImageArray.parray,2,&lbound2);
int sizeX = ubound1 - lbound1;
int sizeY = ubound2 - lbound2;
theImage.AllocateData(sizeX, sizeY);
uint16 *piImageData = *theImage;
for( size_type i = 0, N = theImage.NumberOfPixels(); i < N; ++i)
*piImageData++ = ASCOMDataToPi( *imageData++ );
}
Now, the code that calls this is handing a reference to an UInt16Image...however, I am struggling with this.
void ImageAcquisitionSettingsInterface::TestImage()
{
activeCamera->SetConnected(true);
activeCamera->StartExposure(1);
Console().WriteLn("taking exposure");
while(!activeCamera->ImageReady())
{
//Console().WriteLn("camera not ready yet...");
}
activeCamera->SetLogger(&theLogger);
UInt16Image img;
activeCamera->ImageArray(img);
ImageWindow newImageWindow(img.Bounds().Height(),img.Bounds().Width());
Image* vImage = newImageWindow.MainView().Image() = img;
newImageWindow.Show();
}
This is just a test method. I'm trying to create an image window with the resulting data. I've iterated on this a bit, and I think I'm doing something really wrong :-(