How to load bitmap in imageview but not asynchronous

Shay Wilner 1,746 Reputation points
2021-11-28T19:25:37.677+00:00

Hello

I would like to load bitmap but not assync.
Till now i use
the image is stored in the Asset folder

  var stream = Assets.Open("image.png");
      var bitmap = await BitmapFactory.DecodeStreamAsync(stream);

but i would like to use a not asynchronous method ;
Thank you

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,378 questions
0 comments No comments
{count} votes

Accepted answer
  1. JarvanZhang 23,966 Reputation points
    2021-11-29T01:59:38.887+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    but i would like to use a not asynchronous method

    The BitmapFactory class also provides the DecodeStream method to create a bitmap.

       var img = FindViewById<ImageView>(Resource.Id.img);  
       var stream = Assets.Open("test.png");  
       var imgBitmap = BitmapFactory.DecodeStream(stream);  
       img.SetImageBitmap(imgBitmap);  
    

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.