Save image to Xamarin Forms

1

How to save the image from BD to any folder in the project? I need to create a new folder or save the image to any folder inside the app so I can use it in View .

My code:

byte[] imageBytes;
var FileImage = new Image();
imageBytes = Convert.FromBase64String(Foto); \ Foto já está preenchida, é do tipo string
FileImage.Source = ImageSource.FromStream(() => new MemoryStream(imageBytes));
    
asked by anonymous 07.12.2016 / 16:17

1 answer

3

To save the image you can do the following:

  • Create a MemoryStream by passing its Array to the constructor; / li>
  • Upload the image to stream using Imafe.FromStream
  • Use yourImage.Save ("ImageName", ImageFormat.Jpeg

    var arrayImagem = ObtenhaArrayImagem(); using (var img = Image.FromStream(new MemoryStream(arrayImagem)){img.Save("nomaImagem.jpg", mageFormat.Jpeg);}

  • References:

    SOen

    Xamarin Documentation System.Drawing.Imaging

    Add Visual Studio References

        
    08.12.2016 / 11:39