BarcodeScanner.Mobile icon indicating copy to clipboard operation
BarcodeScanner.Mobile copied to clipboard

Camera Zoom

Open Trainian opened this issue 1 year ago • 3 comments

Is there a possibility and how to use ZOOM cameras ?

Trainian avatar Apr 03 '23 23:04 Trainian

пришлось добавлять самому...

public interface ICameraView : IView
{
///code
        public float ZoomFactor { get; set; }
        public static BindableProperty ZoomFactorProperty { get; set; }
///code
}
public partial class CameraView : View, ICameraView
{
///code
        public static readonly BindableProperty ZoomFactorProperty = BindableProperty.Create(nameof(ZoomFactor), typeof(float), typeof(CameraView), 1f);

        public float ZoomFactor
        {
            get { return (float)GetValue(ZoomFactorProperty); }
            set { SetValue(ZoomFactorProperty, value); }
        }
///code
}

Для ANDROID устройств (в файле CameraViewHandler.android.cs)

public partial class CameraViewHandler
{
///code
        private void CameraCallback()
        {
         ///code after _camera = cameraProvider.BindToLifecycle(lifecycleOwner, cameraSelector, preview, imageAnalyzer);
    
```            SetZoomFactor(VirtualView.ZoomFactor);
         ///code
        }
        private void SetZoomFactor(float zoom)
        {
            if (_camera == null)
                throw new Exception("Zooming Error");
            _camera.CameraControl.SetZoomRatio(zoom);
        }
///code
}

Trainian avatar May 12 '23 20:05 Trainian

@Trainian why don't you create a PR to add this?

or @JimmyPun610 maybe you can add it?

mos379 avatar May 14 '23 08:05 mos379

потому что это далеко не идеальное решение, а временное и используется только при инициализации, без возможности менять на лету. Разработчики дополнения гораздо лучше и эффективней могут сделать, чем моё решение.

because this is far from an ideal solution, but a temporary one and is used only during initialization, without the ability to change on the fly. The developers of the add-on can do much better and more efficiently than my solution.

Trainian avatar May 17 '23 16:05 Trainian