/// <summary> /// Extracts an 8-bit image reducing bit depth if necessary /// </summary> /// <param name="imageOut">The container to recieve the image</param> /// <param name="requestedFrame">The framenumber to request</param> /// <returns>The frame number actually retrieved from the buffer</returns> public uint Extract(Image8 imageOut, uint requestedFrame) { uint frameActual, indexActual; if (_bytesPerPixel == 2) { //this requires acquisition into our internal buffer first //followed by handing out a downsized copy frameActual = Extract(_imgDownsize, requestedFrame); //if our bit-depth is not 16 we have a problem - we need //to scale our image first to really fill the 16bits otherwise we run into //problems later... if (_bitsPerPixel < 16) { ip.ippiMulC_16u_C1IRSfs(_scaleFactor, _imgDownsize.Image, _imgDownsize.Stride, _imgDownsize.Size, 0); } //we got handed 8 bits _imgDownsize.ReduceTo8U(imageOut); } else { NIImaq.CheckError(NIImaq.imgSessionCopyBufferByNumber(_sid, requestedFrame, (IntPtr)imageOut.Image, IMG_OVERWRITE_MODE.IMG_OVERWRITE_GET_NEWEST, out frameActual, out indexActual)); if (frameActual != requestedFrame) { System.Diagnostics.Debug.WriteLine("Requested frame {0}; obtained frame {1}", requestedFrame, frameActual); } } _acquiredFrames++; return(frameActual); }
/// <summary> /// Extracts a 16-bit image /// </summary> /// <param name="imageOut">The container to recieve the image</param> /// <param name="requestedFrame">The framenumber to request</param> /// <returns>The frame number actually retrieved from the buffer</returns> public uint Extract(Image16 imageOut, uint requestedFrame) { uint frameActual, indexActual; if (_bytesPerPixel == 1) { System.Diagnostics.Debug.WriteLine("Acquired 8 bit image into 16bit structure"); } NIImaq.CheckError(NIImaq.imgSessionCopyBufferByNumber(_sid, requestedFrame, (IntPtr)imageOut.Image, IMG_OVERWRITE_MODE.IMG_OVERWRITE_GET_NEWEST, out frameActual, out indexActual)); if (frameActual != requestedFrame) { System.Diagnostics.Debug.WriteLine("Requested frame {0}; obtained frame {1}", requestedFrame, frameActual); } _acquiredFrames++; return(frameActual); }