/// <summary> /// Callback when buffer is acquired. /// </summary> /// <param name="aDisplayThread">The display thread.</param> /// <param name="aBuffer">The buffer.</param> private void OnBufferDisp(PvDisplayThread aDisplayThread, PvBuffer aBuffer) { if (imageIndex == 0) { imageBitmaps.Clear(); } Bitmap snap = new Bitmap(1024, 256); aBuffer.Image.CopyToBitmap(snap); snap = ImagingFun.Crop(snap, (256 + 256 / 2), 0, ccdImageSizeX, ccdImageSizeY); // Take middle 256x256 of frame. Bitmap inverted = ImagingFun.Invert(snap, false); // Invert so that max is white and min is black. imageBitmaps.Add(inverted); double[,] intensity = ImagingFun.BmpToIntensityArray(inverted); int w = intensity.GetLength(0); int h = intensity.GetLength(1); for (int j = 0; j < h; j++) { for (int i = 0; i < w; i++) { counts[imageIndex, i, j] = (int)intensity[i, j]; } } imageAvailable(inverted); imageIndex++; if (imageIndex < numberOfImages && acquiring) { SnapShot(); } else { imageIndex = 0; acquiring = false; } }
/// <summary> /// Callback from display thread delegating buffer display task. /// </summary> /// <param name="aDisplayThread">Display thread</param> /// <param name="aBuffer">Buffer to display</param> void OnBufferDisplay(PvDisplayThread aDisplayThread, PvBuffer aBuffer) { display.Display(aBuffer); }