I need to get native bitmap from ImageSource. In Xamarin Forms we have a LoadImageAsync method in IImageSourceHandler. And for example to get bitmap from FontImageSource we needed to create FontImageSourceHandler and call LoadImageAsync.
How to get bitmap in MAUI?
For example, I have a custom entry with property LeadingImageSource of type ImageSource. And I want to use this in handler.
public static void MapImage(IMaterialEntryHandler handler, IMaterialEntry entry)
{
Bitmap bitmap = entry.LeadingImageSource //how to get from ImageSource?
BitmapDrawable leadingDrawable = new BitmapDrawable(handler.MauiContext.Context.Resources, bitmap);
handler.PlatformView.EditText.SetCompoundDrawablesWithIntrinsicBounds(leadingDrawable, null, null, null);
}
I found ImageSourcePartLoader class but this is not clear for me how to use it. I see in maui sources usage like this: new ImageSourcePartLoader(this, () => VirtualView, OnSetImageSource);.
Should I implement IImageSourcePart to get bitmap and use it in OnSetImageSource?
Thanks.