2017-08-15 29 views
0

iPhone(ネイティブ)でカメラのオーバーレイにskiasharpを使用するアプリケーションを作成しようとしています。私のカメラのストリームはうまく表示されますが、オーバーレイは表示されません。ストリームがどのように見える作成した初期のViewController:skiasharpカメラオーバーレイを作成するxamarin ios

public async override void ViewDidLoad() 
    { 
     base.ViewDidLoad(); 
     await AuthorizeCameraUse(); 

     imagePicker = new UIImagePickerController(); 

     // set our source to the camera 
     imagePicker.SourceType = UIImagePickerControllerSourceType.Camera; 

     // set 
     imagePicker.MediaTypes = new string[] { "public.image" }; 



     imagePicker.CameraOverlayView = new CameraOverlayView(); 

     imagePicker.ModalPresentationStyle = UIModalPresentationStyle.CurrentContext; 
     . . . 

私CameraOverlayViewは、次のようになります。私はそれがない単純な例では、このコードを実行する場合

public class CameraOverlayView :SKCanvasView 
{ 
    public CameraOverlayView() : base() 
    { 
     Initialize(); 
    } 
    public CameraOverlayView(CGRect frame) : base(frame) { 
     Initialize(); 
    } 
    SKPaint paint = new SKPaint 
    { 
     Style = SKPaintStyle.Fill, 
     Color = SKColors.Red, 
     StrokeWidth = 25 
    }; 

    protected void Initialize() 
    { 

     this.PaintSurface += CameraOverlayView_PaintSurface; 
     //using (var surface = SKSurface.Create(640, 480, SKColorType.Rgba8888, SKAlphaType.Premul)) 
     //{ 
     // SKCanvas myCanvas = surface.Canvas; 
     // myCanvas.DrawCircle(300, 300, 100, paint); 
     // // Your drawing code goes here. 
     //} 
    } 

    private void CameraOverlayView_PaintSurface(object sender, SKPaintSurfaceEventArgs e) 
    { 
     var surface = e.Surface; 
     // then we get the canvas that we can draw on 
     var canvas = surface.Canvas; 
     // clear the canvas/view 
     canvas.Clear(SKColors.White); 


     // DRAWING SHAPES 

     // create the paint for the filled circle 
     var circleFill = new SKPaint 
     { 
      IsAntialias = true, 
      Style = SKPaintStyle.Fill, 
      Color = SKColors.Blue 
     }; 
     // draw the circle fill 
     canvas.DrawCircle(100, 100, 40, circleFill); 
    } 
} 

私のPaintイベントは、解雇されることはありません。

答えて

0

Russ FustinoのおかげでCameraOverlayView (CGRect frame) : base (frame)コンストラクタを使用していなかったので、DrawInSurfaceオーバーロードが呼び出されないためです。 何も描画されません。私がこれをしたとき、ペイントイベントが発生しました。

関連する問題