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


C# Camera.GetParameters方法代码示例

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


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

示例1: StartPreview

        protected sealed override void StartPreview()
        {
            _camera = Camera.Open((int)CurrentCamera);
            _camera.SetDisplayOrientation(90);

            var parameters = _camera.GetParameters();
            if (parameters.SupportedFocusModes.Contains(Camera.Parameters.FocusModeContinuousPicture))
            {
                parameters.FocusMode = Camera.Parameters.FocusModeContinuousPicture;
            }

            var optimalSize = GetOptimalPreviewSize(_width, _height);
            if (optimalSize != null)
            {
                parameters.SetPreviewSize(optimalSize.Width, optimalSize.Height);
            }

            _camera.SetParameters(parameters);

            try
            {
                _camera.SetPreviewTexture(_surface);
                _camera.StartPreview();
            }
            catch (Java.IO.IOException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
开发者ID:willsb,项目名称:PhotoCaptureView,代码行数:29,代码来源:CameraController.cs

示例2: StartCamera

		protected void StartCamera() {
			if (_Camera == null) {
				_Camera = Camera.Open();
				_CameraSupportedFlashModes = _CameraSupportedFlashModes ?? _Camera.GetParameters().SupportedFlashModes;
				if (_CameraSupportedFlashModes == null || !_CameraSupportedFlashModes.Contains(FlashlightOnMode) || !_CameraSupportedFlashModes.Contains(FlashlightOffMode)) {
					StopCamera();
				}
			}
		}
开发者ID:Vaikesh,项目名称:Flash-Torch_Xamarin.Android,代码行数:9,代码来源:FlashTorchActivity.cs

示例3: Liga

        public bool Liga()
        {
            if (TemFlash)
            {
                camera = Camera.Open();

                var parametros = camera.GetParameters();
                parametros.FlashMode = Camera.Parameters.FlashModeTorch;

                camera.SetParameters(parametros);
                camera.StartPreview();

                return true;
            }
            return false;
        }
开发者ID:RonildoSouza,项目名称:HajaLuz,代码行数:16,代码来源:Flash.cs

示例4: OnSurfaceTextureAvailable

 public void OnSurfaceTextureAvailable (Android.Graphics.SurfaceTexture surface, int width, int height)
 {
     _camera = Camera.Open ();
     
     var previewSize = _camera.GetParameters ().PreviewSize;
     _textureView.LayoutParameters = 
         new FrameLayout.LayoutParams (previewSize.Width, previewSize.Height, (int)GravityFlags.Center);
     
     try {
         _camera.SetPreviewTexture (surface);
         _camera.StartPreview ();
     } catch (Java.IO.IOException ex) {
         Console.WriteLine (ex.Message);
     }
     
     // this is the sort of thing TextureView enables
     _textureView.Rotation = 45.0f;
     _textureView.Alpha = 0.5f;
 }
开发者ID:GSerjo,项目名称:Seminars,代码行数:19,代码来源:TextureViewActivity.cs

示例5: OnPreviewFrame

		public void OnPreviewFrame (byte[] data, Camera camera)
		{
			var parameters = camera.GetParameters ();
			var size = parameters.PreviewSize;

			var barcode = new Image (size.Width, size.Height, "Y800");
			barcode.SetData (data);

			var result = scanner.ScanImage (barcode);

			if (result == 0)
				return;
			

			camera.SetPreviewCallback (null);
			camera.StopPreview ();

			var scannerResult = GetScannerResult ();

			ScanComplete?.Invoke (this, new ScanCompleteEventArgs (scannerResult));
		}
开发者ID:joacar,项目名称:MonoDroid.ZBar,代码行数:21,代码来源:PreviewCallback.cs

示例6: OnPreviewFrame

      public void OnPreviewFrame(byte[] data, Camera camera)
      {
         if (!_busy && ImagePreview != null)
            try
            {
               _busy = true;
               Camera.Size cSize = camera.GetParameters().PreviewSize;
               _imageSize = new Size(cSize.Width, cSize.Height);
               Size size = _imageSize;
               Image<Bgr, Byte> image = _bgrBuffers.GetBuffer(size, 0);

               GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
               using (Image<Gray, Byte> yuv420sp = new Image<Gray, byte>(size.Width, (size.Height >> 1) * 3, size.Width, handle.AddrOfPinnedObject()))
               {
                  ImagePreview(this, new ImagePreviewEventArgs(yuv420sp, image));
               }
               handle.Free();

               Invalidate();
            }
            finally
            {
               _busy = false;
            }

         if (_cameraPreviewCallbackWithBuffer)
            camera.AddCallbackBuffer(data);
      }
开发者ID:reidblomquist,项目名称:emgucv,代码行数:28,代码来源:ProcessedCameraPreview.cs

示例7: SetCameraOptimalPreviewSize

 private static Camera.Size SetCameraOptimalPreviewSize(Camera camera, int w, int h)
 {
    Camera.Parameters parameters = camera.GetParameters();
    IList<Camera.Size> sizes = parameters.SupportedPreviewSizes;
    int maxWidth = 512, maxHeight = 512;
    Camera.Size optimalSize = GetOptimalPreviewSize(sizes, w, h, maxWidth, maxHeight);
    parameters.SetPreviewSize(optimalSize.Width, optimalSize.Height);
    camera.SetParameters(parameters);
    return optimalSize;
 }
开发者ID:reidblomquist,项目名称:emgucv,代码行数:10,代码来源:CameraPreview.cs

示例8: OnPreviewFrame

        public void OnPreviewFrame(byte[] data, Camera camera)
        {
            lock (syncObj)
            {
                if (flgReqTakePic)
                {
                    flgReqTakePic = false;
                }
                else
                {
                    return;
                }

            }

            try
            {

                //JPEG圧縮を行うため、別スレッドで処理を行う
                TaskExt.Run(() =>
                {
                    //データを読み取り
                    Camera.Parameters parameters = camera.GetParameters();
                    Camera.Size size = parameters.PreviewSize;
                    using (Android.Graphics.YuvImage image = new Android.Graphics.YuvImage(data, parameters.PreviewFormat,
                            size.Width, size.Height, null))
                    {

                        //データをJPGに変換してメモリに保持
                        using (MemoryStream ms = new MemoryStream())
                        {
                            image.CompressToJpeg(
                                new Android.Graphics.Rect(0, 0, image.Width, image.Height), 90,
                                ms);

                            ms.Close(); // Closeしてからでないと、ToArrayは正常に取得できない

                            byte[] jpegData = ms.ToArray();
                            OnPictureTaken(new PicData(jpegData, DateTime.Now, new LocationData()));

                        }

                    }
                });
            }
            catch (Exception ex)
            {
                OnError(ex);
            }
        }
开发者ID:butaman,项目名称:AutoSendPic,代码行数:50,代码来源:CameraManager.cs

示例9: 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

示例10: SetCamera

 public void SetCamera(Camera camera)
 {
     mCamera = camera;
     if (mCamera != null) {
         mSupportedPreviewSizes = mCamera.GetParameters ()
         .SupportedPreviewSizes;
         RequestLayout ();
     }
 }
开发者ID:4ndr01d,项目名称:monodroid-samples,代码行数:9,代码来源:CameraFragment.cs

示例11: 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

示例12: GetCamera

		// getting camera parameters
		private void GetCamera() {
			if (camera == null) {
				try {
					camera = Android.Hardware.Camera.Open();
					params1 = camera.GetParameters();
				} catch (Exception e) {
					Log.Error("Camera Error. Failed to Open. Error: ", e.Message);
				}
			}
		}
开发者ID:RamBachkheti,项目名称:Xamarin-Samples,代码行数:11,代码来源:MainActivity.cs


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