コード例 #1
0
        private UIImage DisplayImage(UIActivityIndicatorView indicator)
        {
            indicator.Hidden = false;

            CVPixelBuffer pixelBuffer;
            var           frame = currentSession.CurrentFrame;



            try
            {
                pixelBuffer = frame.CapturedImage;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                return(new UIImage());
            }

            CGImage image;

            try
            {
                VTUtilities.ToCGImage(pixelBuffer, out image);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                return(new UIImage());
            }

            var orient       = UIApplication.SharedApplication.StatusBarOrientation;
            var viewportSize = this.View.Bounds.Size;
            var transform    = frame.GetDisplayTransform(orient, viewportSize);

            CIImage newImage = new CIImage(pixelBuffer).ImageByApplyingTransform(transform);

            indicator.Hidden = true;

            return(new UIImage(newImage));
        }