예제 #1
0
        ///// <summary>
        ///// This function returnes number if pixels in image according to format, width and height.
        ///// </summary>
        ///// <param name="pf">Image data format in integer format</param>
        ///// <returns>Dot NET pixel format appropriate to the selected data format</returns>
        //internal PixelFormat XiDataFormatToNETPixelFormatInternal(int pf)
        //{
        //  PixelFormat pixelFormat = PixelFormat.Undefined;
        //  switch (pf)
        //  {
        //    case 0:
        //    case 5:
        //      return PixelFormat.Format8bppIndexed;
        //    case 1:
        //    case 6:
        //      return PixelFormat.Format16bppGrayScale;
        //    case 2:
        //    case 4:
        //      return PixelFormat.Format24bppRgb;
        //    case 3:
        //      return PixelFormat.Format32bppRgb;
        //    default:
        //      throw new xiExc(108, "XiDataFormatToNETPixelFormatInternal");
        //  }
        //}

        /// <summary>
        /// This function acquires image and returns XI_IMG structure.
        /// </summary>
        /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        /// <returns>XI_IMG structure with information about acquired image.</returns>
        public XI_IMG GetXI_IMG(int timeout)
        {
            XI_IMG image = default(XI_IMG);

            image.Clear();
            GetXI_IMG(ref image, timeout);
            return(image);
        }
예제 #2
0
        ///// <summary>
        ///// Gets processed image from processing chain.
        ///// </summary>
        ///// <param name="image">Bitmap image to be returned.</param>
        ///// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        //public void ProcPullImage(out Bitmap image, int timeout)
        //{
        //  XI_IMG img = default(XI_IMG);
        //  img.Clear();
        //  ProcPullImageInternal(out img, timeout);
        //  xiImg xiImg = new xiImg(img);
        //  xiImg.GetBitmapByRef(out image);
        //}

        ///// <summary>
        ///// Gets processed image from processing chain.
        ///// </summary>
        ///// <param name="image">BitmapSource image to be returned.</param>
        ///// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        //public void ProcPullImage(out BitmapSource image, int timeout)
        //{
        //  XI_IMG img = default(XI_IMG);
        //  img.Clear();
        //  ProcPullImageInternal(out img, timeout);
        //  xiImg xiImg = new xiImg(img);
        //  xiImg.GetBitmapSourceByRef(out image);
        //}

        ///// <summary>
        ///// Gets processed image from processing chain.
        ///// </summary>
        ///// <param name="val">WriteableBitmap image to be returned.</param>
        ///// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        //public void ProcPullImage(out WriteableBitmap image, int timeout)
        //{
        //  XI_IMG img = default(XI_IMG);
        //  img.Clear();
        //  ProcPullImageInternal(out img, timeout);
        //  xiImg xiImg = new xiImg(img);
        //  xiImg.GetWriteableBitmapByRef(out image);
        //}

        /// <summary>
        /// Gets processed image from processing chain.
        /// </summary>
        /// <param name="img_arr">Byte array image data to be returned.</param>
        /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        public void ProcPullImage(out byte[] img_arr, int timeout)
        {
            XI_IMG img = default(XI_IMG);

            img.Clear();
            ProcPullImageInternal(out img, timeout);
            xiImg xiImg = new xiImg(img);

            xiImg.GetByteArrayByRef(out img_arr);
        }
예제 #3
0
        /// <summary>
        /// This function acquires image into a byte array. Supports UNSAFE buffer policy mode.
        /// </summary>
        /// <param name="img_arr">Preallocated byte array to be filled</param>
        /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        public void GetImage(out byte[] img_arr, int timeout)
        {
            XI_IMG input_img = default(XI_IMG);

            input_img.Clear();
            input_img = GetImageInternal(input_img, timeout);
            xiImg xiImg = new xiImg(input_img);

            xiImg.GetByteArrayByRef(out img_arr);
        }
예제 #4
0
        /// <summary>
        /// Internal handler of xiProcPullImage for all instances in class.
        /// </summary>
        /// <param name="img">XI_IMG struct to be filled.</param>
        /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        internal unsafe void ProcPullImageInternal(out XI_IMG img, int timeout)
        {
            int    num    = 0;
            XI_IMG xI_IMG = default(XI_IMG);

            xI_IMG.Clear();
            num = ximeaApi.xiProcPullImage((void *)handle, timeout, &xI_IMG);
            if (num != 0)
            {
                throw new xiExc(num, "xiProcPushImage ");
            }
            img = xI_IMG;
        }
예제 #5
0
        /// <summary>
        /// This function acquires image into a byte array. Supports SAFE buffer policy mode.
        /// </summary>
        /// <param name="img_arr">Preallocated byte array to be filled</param>
        /// <param name="timeout">Time interval required to wait for the image (in milliseconds)</param>
        public unsafe void GetImage(byte[] img_arr, int timeout)
        {
            if (img_arr == null)
            {
                throw new xiExc(11, "GetImage");
            }
            int paramInt = GetParamInt("buffer_policy");

            if (paramInt == 1)
            {
                XI_IMG input_img = default(XI_IMG);
                input_img.Clear();
                fixed(byte *bp = &img_arr[0])
                {
                    input_img.bp = bp;
                }

                input_img.bp_size = img_arr.Length;
                input_img         = GetImageInternal(input_img, timeout);
                return;
            }
            throw new xiExc(106, "ERROR: This function supports only UNSAFE buffer policy(BUFF_POLICY.SAFE).");
        }
 /// <summary>
 /// xiImg constructor with internal initializations.
 /// </summary>
 public xiImg()
 {
     img.Clear();
 }
예제 #7
0
 /// <summary>
 /// Constructor to initialize internal structure.
 /// </summary>
 public ImgParams()
 {
     image_params = default(XI_IMG);
     image_params.Clear();
 }