Seguí esteblog para agregar una vista superpuesta en la vista previa de mi cámara.
En el fondo, se abre la vista previa de la cámara, y en la parte superior hay un rectángulo exterior superpuesto (en color fucsia) y una forma de círculo en el interior.
Hay dos formas Circle & Heart . Quiero agregar Oval .
Agregué Oval, pero no funcionó.
OverlayView.cs
public enum OverlayShape { Circle, Heart, Oval } public static readonly BindableProperty ShapeProperty = BindableProperty.Create( propertyName: nameof(Shape), returnType: typeof(CameraOverlayShape), declaringType: typeof(CameraOverlayView), defaultValue: CameraOverlayShape.Oval, defaultBindingMode: BindingMode.TwoWay);NativeOverlayView.cs
OverlayShape overlayShape = OverlayShape.Oval; public OverlayShape Shape { get { return overlayShape; } set { overlayShape = value; Redraw(); } } Paint paint = new Paint(PaintFlags.AntiAlias) { Color = OverlayBackgroundColor, Alpha = (int)(255 * Opacity) }; RectF outerRectangle = new RectF(0, 0, width, height); osCanvas.DrawRect(outerRectangle, paint); switch (Shape) { case OverlayShape.Oval: osCanvas.DrawOval(outerRectangle, paint); break; default: // Code }El siguiente código funciona de mi lado.
case OverlayShape.Oval: shapeHeight = (float)(shapeHeight * 0.8); RectF rect = new RectF(width / 2- shapeWidth / 2, height / 2 - shapeHeight / 2, shapeWidth/2+ width/2 , shapeHeight/2+height/2); osCanvas.DrawOval(rect, paint); break;