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.

Can a Android.Graphics.Bitmap be sent from a Web API into Xamarin.Android?

Is it possible for a Web API written in C# to send a Android.Graphics.Bitmap to a Xamarin.Android app so that it could directly display the Bitmap in an ImageView?

Answers

  • AnbuMani27AnbuMani27 USMember ✭✭✭

    Hi @philiphuynh

    The API Returns Values it be Byts[], So Please Decode the Byts[] to Bitmap Values. After that Set the ImageView it will be work

  • philiphuynhphiliphuynh USMember ✭✭

    @AnbuVijay27 said:
    Hi @philiphuynh

    The API Returns Values it be Byts[], So Please Decode the Byts[] to Bitmap Values. After that Set the ImageView it will be work

    Thank you for your answer Anbu, I understand that portion you said. But my question is can the API return a Bitmap value to the android app?

  • AnbuMani27AnbuMani27 USMember ✭✭✭

    @philiphuynh Hi API Returns only Byte[] Values,Reason In the Database we are create Byte[] Column only.

  • philiphuynhphiliphuynh USMember ✭✭

    @AnbuVijay27 said:
    @philiphuynh Hi API Returns only Byte[] Values,Reason In the Database we are create Byte[] Column only.

    But I was thinking if it was possible have the conversion from byte[] to Bitmap in the API so that when the app gets the data it is ready to be shown on the ImageView?

  • AnbuMani27AnbuMani27 USMember ✭✭✭

    @philiphuynh Its Possible,Lets Try Below Code

     Bitmap bmp = BitmapFactory.DecodeByteArray(UserInfoObj[0].user_profile, 0, UserInfoObj[0].user_profile.Length);
     userImageView.SetImageBitmap(bmp);
    
  • philiphuynhphiliphuynh USMember ✭✭

    @AnbuVijay27 said:
    @philiphuynh Its Possible,Lets Try Below Code

     Bitmap bmp = BitmapFactory.DecodeByteArray(UserInfoObj[0].user_profile, 0, UserInfoObj[0].user_profile.Length);
     userImageView.SetImageBitmap(bmp);
    

    Thank you for your quick response. On the WebAPI how would you get the Bitmap class? I found the mono.android.dll file contains this class but it eventually calls jvm.dll which throws an error (System.DllNotFoundException: Unable to load DLL 'jvm.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E))

  • AnbuMani27AnbuMani27 USMember ✭✭✭

    Hi @philiphuynh Can u share me ur Implementation Code

Sign In or Register to comment.