Hey Everyone,
I've been tasked to add a feature in are Xamarin.froms App for drawing over an image from the users gallery or recent photo then save the edited image back into the gallery.
Half of this feature is completed thanks to the media plugin. My Issue would come to editing the image to draw over it in xamarin. Luckily, I found the SkiaSharp nuget package that can help in creating 2D graphics in a cross-platform application.
I have not made a feature like this before in xamarin. I found that the xamarin documents lacked the information to adding the canvas into the xamarin page and that i can't seem to get the current demo of Skiasharp from github to work on my computer. So My question would be:
Is it possible to create the feature of editing an image with Skiasharp? is there an easier method?
as well as:
How can I implement Skiasharp to work in this method?
@PaulRiehle
I was unable to do this in Skiasharp. however I did create a custom render for android (and IOS but I did not added in the demo). you can download it here:
https://forums.xamarin.com/discussion/72968/export-renderer-of-canvas-android-issues
Answers
I was able to get the demo now and took it as base for my own demo. The demo simply takes a pictures then is added to the canvas of the custom Skiaview. Unfortunatly, the custom Renderer and the native Skiaview does not want to call the draw event to view the picture and edit it.Could someone check my code to see what is wrong? I am still pretty new in the custom renders in Xamarin.(Note I only implemented Android in this project)
Edit:
Now if only I could load the entire demo into a zip and posting it here! oh well!
So here's the important bits:
(Note: I'm using the Media Plugin and Skiasharp)
MainPage.xaml
MainPage.xaml.cs
Skiaview.cs
ISkiaViewController.cs
In Android:
SkiaViewRenderer.cs
NativeSkiaView.cs
Here's the link of the small project that I am having trouble with:
https://www.dropbox.com/s/3thpdjraq19gm05/PictureCanvas.zip?dl=0
Here's the Skiasharp Demo I modified to draw on the canvas that works:
https://www.dropbox.com/s/bukcnxbpd8gule8/Skia.Forms.Demo.zip?dl=0
Did you ever figure this out? I am working on a very similar project and I'd love to hear if you fixed the problems you were having.
@PaulRiehle
I was unable to do this in Skiasharp. however I did create a custom render for android (and IOS but I did not added in the demo). you can download it here:
https://forums.xamarin.com/discussion/72968/export-renderer-of-canvas-android-issues
@RichardPresley, this is exactly what I was trying to do (draw over an existing image). Thank you! Any chance you could upload the iOS version as well?
It's a shame that Skiasharp lacks any simple, working examples. Their current model of putting all examples into one big, complex application is really daunting.
Hi! @PaulRiehle and @RichardPresley did you both create custom renderers in order to implement this? As extensive as SkiaSharp is I am hoping that I can manipulate their classes and views to do this, but I can't figure out how to make this happen, which is very frustrating.