If i build an image using SkiaSharp how can I view this one with Xamarin.forms PCL ?
@ttt.5443, thanks for having a look at SkiaSharp. There are several ways, the easiest might be to just use one of he new SkiaSharp Views: http://forums.xamarin.com/discussion/80325/announcing-skiasharp-v1-54-1-and-skiasharp-views
This will allow you to draw onto a canvas. This is great, but as it is a "live" canvas, drawing will happen if the canvas changes for some reason (resized, invalidated) If the image is going to be a static image (fixed size, drawn once), then you can cache the image.
This can be done by creating a new SKSurface
and then taking a snapshot, saving that to disk/stream and displaying that:
// crate a nice surface var surface = SKSurface.Create(new SKImageInfo(100, 100)); // all drawing happens via a canvas var canvas = surface.Canvas; // canvas.DoDraw(); canvas.Flush(); // take a snapshot of the current surface state var image = surface.Snapshot(); // encode the snapshot (default is PNG) var data = image.Encode(); // create the Xamarin.Forms image source var imageSource = ImageSource.FromStream(() => data.AsStream());
That should do it... Let me know if this is what you are looking for.
Answers
@ttt.5443, thanks for having a look at SkiaSharp. There are several ways, the easiest might be to just use one of he new SkiaSharp Views: http://forums.xamarin.com/discussion/80325/announcing-skiasharp-v1-54-1-and-skiasharp-views
This will allow you to draw onto a canvas. This is great, but as it is a "live" canvas, drawing will happen if the canvas changes for some reason (resized, invalidated) If the image is going to be a static image (fixed size, drawn once), then you can cache the image.
This can be done by creating a new
SKSurface
and then taking a snapshot, saving that to disk/stream and displaying that:That should do it... Let me know if this is what you are looking for.
OK It works. Thanks Matthew.