0
I’m developing an app Xamarin.Forms and I’m having difficulty understanding how to fill the parameter to convert an image into byte array, I searched a lot looking for some solution, I found this method to convert to byte array.
public object ConvertImageInArrayByte( object value, Type targetType, object parameter, CultureInfo culture )
{
ImageSource retSource = null;
if (value != null)
{
byte[] imageAsBytes = (byte[])value;
retSource = ImageSource.FromStream(() => new MemoryStream(imageAsBytes));
}
return retSource;
}
The image is loaded in the shampoo:
<Image x:Name="fotosOcorrencia" HorizontalOptions="Center" Source="{Binding Foto}" HeightRequest="180"/>
But I’m not knowing how to fill the parameters, I couldn’t find a place or a way to do it. I’m trying to do this:
arrayByteImagem = ConvertImageInArrayByte(fotosOcorrencia, CultureInfo.CurrentCulture);
I’m very grateful that someone can help me, I know it’s not difficult, but I can’t find the solution.
This can all be reduced to one
System.IO.File.ReadAllBytes(filepath);
.– CypherPotato