当前位置: 首页>>代码示例>>C#>>正文


C# Camera.SetPreviewDisplay方法代码示例

本文整理汇总了C#中Android.Hardware.Camera.SetPreviewDisplay方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.SetPreviewDisplay方法的具体用法?C# Camera.SetPreviewDisplay怎么用?C# Camera.SetPreviewDisplay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Hardware.Camera的用法示例。


在下文中一共展示了Camera.SetPreviewDisplay方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SurfaceCreated

			public void SurfaceCreated (ISurfaceHolder holder)
			{
				try {
					camera = Camera.Open ();
					camera.SetPreviewDisplay (holder);
					camera.SetPreviewCallback (this);

				} catch (Exception e) {
					ShutdownCamera ();

					// TODO: log or otherwise handle this exception

					throw;
				}
			}
开发者ID:Redth,项目名称:zxing.MonoTouch,代码行数:15,代码来源:QrScannerActivity.cs

示例2: SurfaceCreated

		public void SurfaceCreated (ISurfaceHolder holder)
		{
			try {
				Console.WriteLine("Surface created");

				camera = Android.Hardware.Camera.Open ();
				camera.SetPreviewDisplay (holder);
				camera.SetPreviewCallback (this);

				Console.WriteLine("Surface Created end");

			} catch (Exception) {
				ShutdownCamera ();
				Console.WriteLine("Exception, shutdown camera");

				// TODO: log or otherwise handle this exception

				//throw;
			}
		}
开发者ID:GSerjo,项目名称:Seminars,代码行数:20,代码来源:ZxingActivity.cs

示例3: SurfaceCreated

        public void SurfaceCreated(ISurfaceHolder holder)
        {
            // The Surface has been created, acquire the camera and tell it where
            // to draw.
            camera = Camera.Open ();

            try {
                camera.SetPreviewDisplay (holder);
            } catch (Exception) {
                camera.Release ();
                camera = null;
                // TODO: add more exception handling logic here
            }
        }
开发者ID:4ndr01d,项目名称:monodroid-samples,代码行数:14,代码来源:CameraPreview.cs

示例4: SurfaceCreated

		public void SurfaceCreated (ISurfaceHolder holder)
		{
			try 
			{
#if __ANDROID_9__

				var numCameras = Android.Hardware.Camera.NumberOfCameras;
				var camInfo = new Android.Hardware.Camera.CameraInfo();
				var found = false;

				for (int i = 0; i < numCameras; i++)
				{
					Android.Hardware.Camera.GetCameraInfo(i, camInfo);
					if (camInfo.Facing == CameraFacing.Back)
					{
						camera = Android.Hardware.Camera.Open(i);
						found = true;
						break;
					}
				}

				if (!found)
				{
					Android.Util.Log.Debug("ZXing.Net.Mobile", "Finding rear camera failed, opening camera 0...");
					camera = Android.Hardware.Camera.Open(0);
				}
#else
				camera = Android.Hardware.Camera.Open();
#endif
				if (camera == null)
					Android.Util.Log.Debug("ZXing.Net.Mobile", "Camera is null :(");


				//camera = Android.Hardware.Camera.Open ();
				camera.SetPreviewDisplay (holder);
				camera.SetPreviewCallback (this);

			} catch (Exception ex) {
				ShutdownCamera ();

				// TODO: log or otherwise handle this exception
				Console.WriteLine("Setup Error: " + ex);
				//throw;
			}
		}
开发者ID:rfosterfrss,项目名称:ZXing.Net.Mobile,代码行数:45,代码来源:ZxingActivity.cs

示例5: CreateCamera

      private bool CreateCamera(int cameraIndex)
      {
#if !DEBUG
         try
#endif
         {
            StopCamera();
            _camera = Camera.Open(cameraIndex);
            _camera.SetPreviewDisplay(_surfaceHolder);
            if (OnCameraCreated != null)
            {
               if (_cameraInfo == null)
                  _cameraInfo = new Android.Hardware.Camera.CameraInfo();

               Camera.GetCameraInfo(cameraIndex, _cameraInfo);
               OnCameraCreated(this, new CameraInfoEventArgs(_camera, _cameraInfo));
            }
         }
#if !DEBUG
         catch (Exception excpt)
         {
            _camera.Release();
            _camera = null;

            while (excpt.InnerException != null)
               excpt = excpt.InnerException;
            
            Report.Error(Context.PackageName, String.Format("Unable to create camera: {0}", excpt.Message));

            return false;
            // TODO: add more exception handling logic here
         }
#endif

         return true;
      }
开发者ID:reidblomquist,项目名称:emgucv,代码行数:36,代码来源:CameraPreview.cs

示例6: SwitchCamera

        public void SwitchCamera(Camera camera)
        {
            SetCamera (camera);
            try {
                camera.SetPreviewDisplay (mHolder);
            } catch (IOException exception) {
                Log.Error (TAG, "IOException caused by setPreviewDisplay()", exception);
            }
            Camera.Parameters parameters = camera.GetParameters ();
            parameters.SetPreviewSize (mPreviewSize.Width, mPreviewSize.Height);
            RequestLayout();

            camera.SetParameters (parameters);
        }
开发者ID:4ndr01d,项目名称:monodroid-samples,代码行数:14,代码来源:CameraFragment.cs

示例7: CreateCamera

        /// <summary>
        /// Create the camera and try to set auto focus with flash
        /// </summary>
        /// <param name="holder"></param>
		public void CreateCamera(ISurfaceHolder holder) {
			try
			{
				_camera = Camera.Open();
				Camera.Parameters p = _camera.GetParameters();
				p.PictureFormat = Android.Graphics.ImageFormatType.Jpeg;
				p.JpegQuality = 100;
				hasAutoFocus = (p.SupportedFocusModes.Contains(Camera.Parameters.FocusModeAuto));
				if (hasAutoFocus)
				{
					p.FocusMode = Camera.Parameters.FocusModeAuto;
					focusReady = true;
				}
				else if (p.SupportedFocusModes.Contains(Camera.Parameters.FocusModeContinuousPicture))
				{
					p.FocusMode = Camera.Parameters.FocusModeContinuousPicture;
				}
				if (p.SupportedFlashModes.Contains(Camera.Parameters.FlashModeOn))
				{
					p.FlashMode = Camera.Parameters.FlashModeOn;
				}
				_camera.SetParameters(p);
				_camera.SetDisplayOrientation(90);
				_camera.SetPreviewCallback(this);
				_camera.Lock();
				_camera.SetPreviewDisplay(holder);
				_camera.StartPreview();
				if (hasAutoFocus)
				{
					Toast.MakeText(this, "Press screen to focus", ToastLength.Long).Show();
				}
			}
			catch (Exception e)
			{
			}
		}
开发者ID:SansSkill,项目名称:Introproject,代码行数:40,代码来源:CameraActivity.cs

示例8: StartPreview

        private bool StartPreview(Camera camera)
        {
            if (camera == null) { return false; }

            StopPreview(camera);

            // Mark preview as started if surface holder not yet created. We will really start it later
            _previewStarted = true;
            if (_surfaceHolder == null) { return false; }

            camera.SetDisplayOrientation(_displayOrientation);
            camera.SetPreviewDisplay(_surfaceHolder);

            try { camera.StartPreview(); }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("StartPreview {0}", ex);
                return false;
            }

            return true;
        }
开发者ID:BenGladman,项目名称:Camdro,代码行数:22,代码来源:Viewfinder.cs


注:本文中的Android.Hardware.Camera.SetPreviewDisplay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。