0

I have an issue when converting a string URL to bitmap.

"Cannot convert from Java.IO.FileInputStream to System.IO.Stream"

Is There a solution to fix this? or how can I convert imgUrl to Bitmap so I need to upload it to firebase storage?

  public static Bitmap GetBitmap(string imgUrl)
        {
            File imageFile = new File(imgUrl);
            FileInputStream fs = null;
            Bitmap bm = null;
            fs = new FileInputStream(imgUrl);
            bm = BitmapFactory.DecodeStream(fs);
            return bm;
        }
Anas Alweish
  • 2,818
  • 4
  • 30
  • 44
Amv
  • 39
  • 4
  • 2
    Use a `System.IO.FileStream` (via `File.OpenRead`) instead of the Java framework... – SushiHangover May 26 '19 at 17:36
  • I'm using a directory, so it throws exceptions that I don't have enough permissions. What should I do? System.UnauthorizedAccessException: Access to the path "/storage/emulated/0/Pictures/Instagram/IMG_20190226_195851_668.jpg" is denied. This is my code => Bitmap bm = null; FileStream fs = System.IO.File.OpenWrite(imgUrl); bm = BitmapFactory.DecodeStream(fs); – Amv May 26 '19 at 18:53
  • If you are trying to write|read to|from the *public* Pictures directory (that is outside of your app's sandbox), first you need to add manifest permission, second you need to request runtime permission. There are many SOs about this (i.e. https://stackoverflow.com/questions/46911486/xamarin-system-unauthorizedaccessexception-access-to-the-path-is-denied) and Xamarin-based blog posts (i.e. https://devblogs.microsoft.com/xamarin/requesting-runtime-permissions-in-android-marshmallow/), etc... – SushiHangover May 26 '19 at 19:01
  • Possible duplicate of [Load image from url to ImageView - C#](https://stackoverflow.com/questions/23860511/load-image-from-url-to-imageview-c-sharp) – FreakyAli May 27 '19 at 06:48

0 Answers0