You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I decided against creating a custom image view just for SkiaSharp for several reasons:
re-doing the work of every platform out there
too many features, for too many platforms
existing infrastructure/extensions (loaders/effects) won't work
However... I have provided a way to convert from SkiaSharp types (SkBitmap, SKPicture, SKImage and SKPixmap) into platform types (CGImage, CIImage, UIImage, NSImage, System.Drawing.Bitmap, Android.Graphics.Bitmap, WriteableBitmap).
These are basic extension methods that take a copy of the pixels and hand it over to the OS. Then, these can be used in any UI picture view on the platform - and any custom ones that are in use:
I have also created a set of ImageSource types for Xamarin.Forms (SKBitmapImageSource, SKImageImageSource, SKPictureImageSource and SKPixmapImageSource). These are used as "normal" in XAML:
varimage=newImage{Source=newSKImageImageSource{Image=viewModel.AwesomeImage}}// or with the nice implicit castvarimage=newImage{Source=(SKImageImageSource)viewModel.AwesomeImage}
I am closing this now as I think I have something that will help everyone :) But, feel free to re-open if you need/prefer something else:
you really need a custom image view...
you want some extension method that does NOT copy the pixels (you will have to manage the lifetime of the SkiaSharp instance) - this is also not always possible on some of the platforms
another idea based on displaying a SkiaSharp image in some native way
Activity
mattleibow commentedon Feb 28, 2017
I decided against creating a custom image view just for SkiaSharp for several reasons:
However... I have provided a way to convert from SkiaSharp types (
SkBitmap,SKPicture,SKImageandSKPixmap) into platform types (CGImage,CIImage,UIImage,NSImage,System.Drawing.Bitmap,Android.Graphics.Bitmap,WriteableBitmap).These are basic extension methods that take a copy of the pixels and hand it over to the OS. Then, these can be used in any UI picture view on the platform - and any custom ones that are in use:
I have also created a set of
ImageSourcetypes for Xamarin.Forms (SKBitmapImageSource,SKImageImageSource,SKPictureImageSourceandSKPixmapImageSource). These are used as "normal" in XAML:Or in C#
I am closing this now as I think I have something that will help everyone :) But, feel free to re-open if you need/prefer something else:
nathanielcook commentedon Jul 22, 2017
I see here and also here that there is a way to use SkiaSharp from XAML (Xamarin Forms), but what about AXML (native Android) layouts?
mattleibow commentedon Jul 22, 2017
You can use:
https://github.com/mattleibow/SkiaSharpDemo/blob/master/SkiaSharpNativeDemo/SkiaSharpNativeDemo.Android/Resources/layout/main.axml