Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to create Drawable from Bitmap?

igorkr_10igorkr_10 Member ✭✭✭✭
edited October 8 in Xamarin.Android

I need to create Drawable from Bitmap.
I use the next code but this is obsolete.

private async Task<Drawable> CreateLeftDrawable()
        {
            return new BitmapDrawable(await Element.LeadingImageSource.GetBitmap(this.Context, new System.Threading.CancellationToken()));
        }

Is there any another way to get Drawable from Bitmap?

Tagged:

Best Answer

  • ColeXColeX Member, Xamarin Team Xamurai
    edited October 9 Accepted Answer

    Try

    return new BitmapDrawable( this.Context.Resources, await Element.LeadingImageSource.GetBitmap(this.Context, new System.Threading.CancellationToken()));
    

    Refer to https://stackoverflow.com/a/9978952/8187800 .

Answers

  • ColeXColeX Member, Xamarin Team Xamurai
    edited October 9 Accepted Answer

    Try

    return new BitmapDrawable( this.Context.Resources, await Element.LeadingImageSource.GetBitmap(this.Context, new System.Threading.CancellationToken()));
    

    Refer to https://stackoverflow.com/a/9978952/8187800 .

Sign In or Register to comment.