Bitmapdescriptor with ffimageloading ?
readonly Pin _pin = new Pin() { Type = PinType.Place, Label = AppResources.AppResources.DragMe, IsDraggable = true, Icon = BitmapDescriptorFactory.FromBundle("stop.png") };
If I load 50 pins it crashes with out of memory error on android (iphone works fine), the 1G trick doesnt work. So I was hoping I could use FFImageLoading ...but I dont know if it is possible..
Yes, it's possible, FFImageLoading supports multiple targets as destinations. It'll require custom ITarget implementation. I'll try to prepare it and post it here.
Meanwhile you can review standard ImageViewTarget implementation here:
- https://github.com/luberda-molinet/FFImageLoading/blob/617a9a6c04bdb5d9076e58921f42e9a9bd70af3e/source/FFImageLoading.Droid/Work/ImageViewTarget.cs
- https://github.com/luberda-molinet/FFImageLoading/blob/617a9a6c04bdb5d9076e58921f42e9a9bd70af3e/source/FFImageLoading.Droid/TaskParameterExtensions.cs#L20-L34
With https://github.com/luberda-molinet/FFImageLoading/commit/d706b2d60bc1ce3a72b98236fee3f59a641b78a1 you can retrieve native bitmaps as:
- Android:
var nativeBitmapDrawable = await ImageService.Instance.LoadUrl("http://myimage.png").AsBitmapDrawableAsync(); - iOS:
var nativeUIImage = await ImageService.Instance.LoadUrl("http://myimage.png").AsUIImageAsync();
Then you can use it like this on Android:
readonly Pin _pin = new Pin()
{
Type = PinType.Place,
Label = AppResources.AppResources.DragMe,
IsDraggable = true,
Icon = BitmapDescriptorFactory.FromBitmap(nativeBitmapDrawable?.Bitmap)
};