Bug 59155 - Skiasharp on an drawcircle overlay for the camera on iPhone (native) does not work.
Summary: Skiasharp on an drawcircle overlay for the camera on iPhone (native) does not...
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-08-31 16:24 UTC by Russell Fustino
Modified: 2017-08-31 19:05 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Here is the code minus the skiasharp libs (nuget) skiasharp and skiasharp.views.ios (483.30 KB, application/x-zip-compressed)
2017-08-31 16:24 UTC, Russell Fustino
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Russell Fustino 2017-08-31 16:24:16 UTC
Created attachment 24505 [details]
Here is the code minus the skiasharp libs (nuget) skiasharp and skiasharp.views.ios

I am trying to create a app that uses skiasharp on an overlay for the camera on iPhone (native). My camera stream appears nicely but no overlay. the initial viewcontroller that creates the stream looks like:
        base.ViewDidLoad();
        await AuthorizeCameraUse();

        imagePicker = new UIImagePickerController();

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

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

        // show the camera controls
        imagePicker.ShowsCameraControls = true;


        imagePicker.CameraOverlayView = new CameraOverlayView();

                    More stuff
now this nicely streams and the CameraOverlayView looks like:
using SkiaSharp;
using SkiaSharp.Views.iOS;

 namespace cameraOverlay
{
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()
    {


        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.
        }
    }


 }
}
I have this working on the android but am stuck here.
Update: ===>
I revised my code to look like the following but the paint event was not called:
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;

    }

    private void CameraOverlayView_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
    {
        throw new NotImplementedException();        //break point here
    }
}


Microsoft Visual Studio Community 2017 
Version 15.2 (26430.12) Release
VisualStudio.15.Release/15.2.0+26430.12
Microsoft .NET Framework
Version 4.7.02046

Installed Version: Community

Visual Basic 2017   00369-60000-00001-AA901
Microsoft Visual Basic 2017

Visual C# 2017   00369-60000-00001-AA901
Microsoft Visual C# 2017

Visual C++ 2017   00369-60000-00001-AA901
Microsoft Visual C++ 2017

Visual F# 4.1   00369-60000-00001-AA901
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.6.00404.2
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.30503.0
ASP.NET and Web Tools 2017

ASP.NET Web Frameworks and Tools 2012   4.0.11203.0
For additional information, visit https://www.asp.net/

ASP.NET Web Frameworks and Tools 2017   5.2.50303.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.30209.0
Azure App Service Tools v3.0.0

Common Azure Tools   1.9
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript UWP Project System   2.0
JavaScript UWP Project System

KofePackagePackage Extension   1.0
KofePackagePackage Visual Studio Extension Detailed Info

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50131.1

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   Mono.Debugging.VisualStudio
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.2.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SQL Server Data Tools   15.1.61702.140
Microsoft SQL Server Data Tools

TypeScript   2.2.2.0
TypeScript tools for Visual Studio

Visual Studio Tools for Universal Windows Apps   15.0.26430.06
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin   4.5.0.476 (1be4f0c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   7.3.1.2 (9dbc4c5)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   10.10.0.35 (4cffddf)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Comment 1 Vincent Dondain [MSFT] 2017-08-31 19:05:37 UTC
Hi Russel,

Looks like you're not using the `CameraOverlayView (CGRect frame) : base (frame)` constructor and because of that the `DrawInSurface` overload is not called.
Nothing to draw into (;

So in your view controller where you currently do:

`imagePicker.CameraOverlayView = new CameraOverlayView();`

Simply do something like:

`imagePicker.CameraOverlayView = new CameraOverlayView (new CGRect (50, 50, 300, 300));`

or better, use the view controller's UIView bounds.

-----

However please note that bugzilla is for bugs against the platform (Xamarin products).

For questions about how to use the APIs the broader developer community is usually the best place to get help.

You can post a question on Stack Overflow [0] or the Xamarin Forums [1].

[0] http://stackoverflow.com/questions/tagged/xamarin
[1] https://forums.xamarin.com/

In case it might also be a helpful reference, you can find some general recommendations on the best places to ask various kinds of questions about Xamarin on:

https://developer.xamarin.com/guides/cross-platform/troubleshooting/support-options

-----

Hope this helps,

Vincent